szepeviktor/phpstan-wordpress

`__return_null()` in `add_filter()` causes error

Closed this issue · 2 comments

__return_null() in add_filter() causes a Filter callback return statement is missing. error. See #220. Is this intended?

Note, there is no error with the lowest supported version of PHPStan.

I see this

protected function validateFilterReturnType(ParametersAcceptor $callbackAcceptor): void
{
$returnType = $callbackAcceptor->getReturnType();
if ($returnType instanceof MixedType) {
return;
}
$accepted = $this->ruleLevelHelper->accepts(
new VoidType(),
$returnType,
true
);
if (! $accepted) {
return;
}
throw new \SzepeViktor\PHPStan\WordPress\HookCallbackException(
'Filter callback return statement is missing.'
);

It's not intended, no.