Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Stan support #260

Open
sandeshjangam opened this issue Oct 3, 2023 · 6 comments
Open

PHP Stan support #260

sandeshjangam opened this issue Oct 3, 2023 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@sandeshjangam
Copy link

sandeshjangam commented Oct 3, 2023

It doesn't throw errors in PHPStan if args type, numbers etc. mismatches...

namespace App\Authentication\Actions;

use Lorisleiva\Actions\Concerns\AsAction;

class UpdateUserPassword
{
    use AsAction;

    public function handle(User $user, string $newPassword)
    {
        $user->password = Hash::make($newPassword);
        $user->save();
    }
}
// Equivalent to "UpdateUserPassword::make()->handle($user, 'secret')".
UpdateUserPassword::run($user, 'secret');

If I use this - UpdateUserPassword::make()->handle($user, 'secret')
Larstan properly check args type, count etc

For this - UpdateUserPassword::run($user, 'secret')
Larstand doesn't trigger any error

How can I add support to this? I am open to creating a PR. A little head start will be good...

@sandeshjangam
Copy link
Author

@lorisleiva I am open to creating a PR. A little head start will be good...

@Wulfheart
Copy link
Collaborator

I don’t think that this can be achieved in this package due to the dynamic nature of the package.

Did you try the ide-helper package yet?

@sandeshjangam
Copy link
Author

I don’t think that this can be achieved in this package due to the dynamic nature of the package.

Did you try the ide-helper package yet?

Nope, I haven't yet. I am not sure how the ide-helper package will help to get it compatible with Larstan(PHPStan)?

Can you please elaborate?

@Patabugen
Copy link

@sandeshjangam The ide-helper package generates docblocks (or other files/annotations) based on your actual code which phpStan can use to understand your code better.

For example, it might add a docblock bit which can tell phpStan the arguments for UpdateUserPassword::run()

There's an extension for ide-helper just for laravel-actions which might help:

https://github.com/Wulfheart/laravel-actions-ide-helper

@kylemilloy
Copy link

I think this is possible with generics, yes? Would really like to have this since everything getting set to "mixed" isn't terribly helpful.

@Wulfheart Wulfheart added enhancement New feature or request help wanted Extra attention is needed labels Oct 17, 2024
@Wulfheart
Copy link
Collaborator

This topic definitely needs more love.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants