phpstan-drupal
phpstan-drupal copied to clipboard
Support checking method_exists for backward compatibility support
if (method_exists($this->moduleHandler, 'invokeAllWIth')) {
$this->moduleHandler->invokeAllWith('mail', function (callable $hook, string $module) use (&$list) {
$list[$module] = $this->moduleHandler->getName($module);
});
}
else {
foreach ($this->moduleHandler->getImplementations('mail') as $module) {
$list[$module] = $this->moduleHandler->getName($module);
}
}
Let's see if the latter can not error. It currently does
Actually, I'm not sure if this is possible since the error comes from phpstan-deprecation-rules
Maybe there is some kind of hack that can be done with \PhpParser\NodeVisitorAbstract
Can't be done. We need folks to use // @phpstan-ignore-next-line
when providing backward compatibility support via if/else
This is possible now that https://github.com/phpstan/phpstan-deprecation-rules/pull/99 has been merged, but depends on PHPStan 11.0.
The issue was merged and it was released into the 1.10 branch, we can continue this without waiting for 1.11 :)
Oh it did get released? I'll queue this up
Since the pattern of the BC fixes in rector is pretty much done. Perhaps it is time to see if you can support that. Otherwise the Rector rule will need to be rewritten a little to support the ignore comment.
https://github.com/palantirnet/drupal-rector/pull/250
I'll need to find some time for this. I did an investigation and the scope provided by PHPStan is not in-depth enough to make this kind of scope decisions. We don't know about the being processed. We may need drupal-rector to add the comment :/
I feel like the the deprecated scope thingies should be able to do this. But only if the referred arguments on the deprecatedhelper class are anonimous functions. I understand that calls to other methods as arguments might not work. But anonimous functions should be doable?
This isn't needed now that we have DeprecatedScopeResolver (#714)