New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ::class
to get the fully qualified name of the class
#118
Conversation
The 3 failures from the checks are not related to this PR. |
The change makes sense I guess, but I wonder why this behaviour changed in phpstan and if it is a BC break. You don't know what in phpstan broke it do you? |
In string form there must not be a leading backslash. |
Sorry guys, this is too hard for me. |
This is how FQCN should be written #119 FQCN only for docblocks and exception. I'm hesitant with |
You have to know that this repo was not meant to be for PHP code. |
How to go on? |
I think the easiest thing indeed would be to just bump the minimal required phpstan version. People can just update it IMO |
I let other people choose that. |
@herndlm I don't know what causes the issue or whether one of the sources mentioned by @szepeviktor is the cause. @szepeviktor The changes proposed in #119 do not resolve the issue addressed by this PR. Using #119 makes PHPStan "ignore" the dynamic method return type in v1.8.5, v1.8.6 and v1.8.7. |
Using public function getClass(): string
{
return \WP_Theme::class;
} also matches the dynamic return type example from the docs: public function getClass(): string
{
return \Doctrine\ORM\EntityManager::class;
}
public function isMethodSupported(MethodReflection $methodReflection): bool
{
return $methodReflection->getName() === 'merge';
}
public function getTypeFromMethodCall(
MethodReflection $methodReflection,
MethodCall $methodCall,
Scope $scope
): Type
{ ... } |
It is hard to be a repo owner! |
It seems, it was my fault and #119 solves the issue. |
@johnbillion Could you jump in a resolve #118 (comment) wich a single click? 🙃 |
How does the |
👍 + phpstan version bump, no? Otherwise people come with old phpstan versions and complain the slash is missing I guess. If I understood the problem.. |
But sorry, I was just assuming that the fixed version doesn't play nice with an old phpstan. If it does, perfect :) Btw @szepeviktor does it make sense to test with lowest and highest deps in CI maybe to verify things like that? |
@herndlm I know how a full-blown software project looks like :) This is definitely not like that. |
Does anyone know how to get phpstan version in |
What about |
Thank you! and it errored out. Could you try it also? |
That method was added very recently btw, which means most likely that you'd have to bump the phpstan version ;) |
You could require composer 2 and use the native PackageVersions thingy or you could use that package that does the same thing. But another dep might mean another potential conflict and increased complexity I guess :/ Also: rather not use somehing from phpstan internal, this will surely break at some point. Maybe it's namespace is even prefixed or smth like that |
That's probably why the following worked for me (v1.8.2) use PHPStan\Internal\ComposerHelper;
$version = ComposerHelper::getPhpStanVersion();
if (version_compare($version, '1.8.5', '>') ) {
...
} else {
...
}
Good point. |
@IanDelMar Could you please add |
Sure. Take your time. |
@IanDelMar Done in master :) |
Thank you. |
From PHPStan 1.8.6
return '\WP_Theme';
no longer works. PHPStan skips the dynamic return type when analyzing an instance ofWP_Theme
.