Closed bfzgaier closed 1 year ago
What you could do in order to fix it right away, is to add a stub file somewhere in your project directory with the following content:
<?php
namespace Psr\EventDispatcher;
interface EventDispatcherInterface
{
/**
* @template TEvent of object
* @param TEvent $event
*
* @return TEvent
*/
public function dispatch(object $event);
}
You also have to include the stub file in your phpstan.neon file https://phpstan.org/user-guide/stub-files
@bfzgaier But maybe it is useful to add such a stub file in this package. I will try to discuss it with @sascha-egerer
@sascha-egerer What do you think? Should we add such a stub file in this package here?
Hello,
I know that psr/event-dispatcher is a 3-party dependency for TYPO3, so it is fine if it is out of scope.
Could you add generic support for
Psr\EventDispatcher\EventDispatcherInterface
. Let's say you have code like this:PHPStan can not resolve the real type of
$event
, therefore it will trigger anCall to an undefined method object::someFunction()
error.The easy solution is to add an annotation for
$event
, but you will need to do it every time you dispatch an event. The possibility to omit the annotation would also allow for dropping the intermediate variable$event
and combining it into one line.Thank you for your effort and this ruleset.