Skip to content

The retry helper stub produces a false-positive #412

@waahhhh

Description

@waahhhh

Describe the bug
A clear and concise description of what the bug is.

Passing an integer variable as the first or third argument to the helper function retry results in an error.

psalm
=====

ERROR: ArgumentTypeCoercion
at ...
Argument 1 of retry expects int<1, max>|list<int>, but parent type int provided (see https://psalm.dev/193)
            $retries,

ERROR: ArgumentTypeCoercion
at ...
Argument 3 of retry expects int<0, max>, but parent type int provided (see https://psalm.dev/193)
            $retrySleep,

In the Laravel framework itself, the types are only declared as integers.
In my opinion the error reported by the stub is a false-positive, because if one of these arguments doesn't match the type of the stub, it won't cause an error.

  • $times as less than 1 would still execute $callback
  • $sleep as less than 0 would still result in a sleep of 0 ms

Impacted Versions
Please paste the output of composer show | grep -E 'psalm|laravel' so we can see what versions are impacted

barryvdh/laravel-ide-helper        3.6.0              Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.
laravel/framework                  11.46.1            The Laravel Framework.
laravel/horizon                    5.40.0             Dashboard and code-driven configuration for Laravel queues.
laravel/octane                     2.13.1             Supercharge your Laravel application's performance.
laravel/prompts                    0.3.7              Add beautiful and user-friendly forms to your command-line applications.
laravel/serializable-closure       2.0.6              Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.
laravel/tinker                     2.10.1             Powerful REPL for the Laravel framework.
spatie/laravel-data                3.12.0             Create unified resources and data transfer objects
spatie/laravel-package-tools       1.92.7             Tools for creating Laravel packages
barryvdh/laravel-ide-helper                    3.5.5              Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.
laravel/prompts                                0.3.7              Add beautiful and user-friendly forms to your command-line applications.
laravel/serializable-closure                   2.0.6              Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.
psalm/plugin-laravel                           3.0.4              Psalm plugin for Laravel
vimeo/psalm                                    6.13.1             A static analysis tool for finding errors in PHP applications

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions