website/errors/paramClosureThis.nonClosure.md
<?php declare(strict_types = 1);
class Foo
{
/**
* @param-closure-this Foo $callback
*/
public function register(string $callback): void
{
}
}
The @param-closure-this PHPDoc tag is used on a parameter whose native type is not Closure. The @param-closure-this tag specifies the $this context inside a Closure, so it only makes sense for parameters typed as Closure. Other types (like string, callable, or array) do not bind a $this context in the same way.
Change the parameter type to Closure:
class Foo
{
/**
* @param-closure-this Foo $callback
*/
- public function register(string $callback): void
+ public function register(\Closure $callback): void
{
}
}
Or remove the @param-closure-this tag if the parameter is not intended to be a Closure:
class Foo
{
- /**
- * @param-closure-this Foo $callback
- */
public function register(string $callback): void
{
}
}