TwigFilter可调用参数的诗篇错误。

问题描述 投票:0回答:1

我在psalm的twig扩展中得到这个错误。

null, array{App\Twig\CartExtension&static, string(getOfferDate)} provided

The code in question is:

public function getFilters(): array
    {
        return [
            new TwigFilter(
                'get_offer_date',
                [$this, 'getOfferDate']
            )
        ];
    }

And the TwigFilter signature is

/**
 * @param callable|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 = [])
...

The twig docs recommend this format

[$this, 'getOfferDate']

for the callable: https:

如何解决这个psalm错误或告诉psalm接受它?

php symfony twig psalm-php
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.