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

InvalidArgument error introduced in 5.24 #10971

Open
michnovka opened this issue May 11, 2024 · 2 comments
Open

InvalidArgument error introduced in 5.24 #10971

michnovka opened this issue May 11, 2024 · 2 comments

Comments

@michnovka
Copy link
Contributor

Getting this error:

ERROR: InvalidArgument
at /home/superuser/scripts/dockontrol2/src/Twig/AppExtension.php:18:44
Argument 2 of Twig\TwigFilter::__construct expects a public static callable, but a non-static callable provided (see https://psalm.dev/004)
new TwigFilter('time_tooltip', [TimeRuntime::class, 'createTimeTooltip'], [

With the below code

new TwigFilter('time_tooltip', [TimeRuntime::class, 'createTimeTooltip'], [
    'is_safe' => ['html'],
])

Note that the TwigFilter source does not specify static nor public property for callable:

final class TwigFilter
{
    /**
     * @param callable|array{class-string, string}|null $callable A callable implementing the filter. If null, you need to overwrite the "node_class" option to customize compilation.
     */
    public function __construct(string $name, $callable = null, array $options = [])
    {

I am unable to reproduce this on psalm.dev

I am getting this on all projects with psalm 5.24, but it works fine with 5.23

@michnovka
Copy link
Contributor Author

I did check for any stubs used, but in the whole project there is no stub for TwigFilter class. I do use psalm/plugin-symfony v 5.1.0, but this stub is not there. So Id assume it reads signature from the source code (vendor/twig/twig/src/TwigFilter.php)

@michnovka
Copy link
Contributor Author

Also please note that this syntax is in line with official Symfony docs for Lazy loaded twig extensions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant