Skip to content
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

Problem with PHPStan #2101

Closed
TristanPouliquen opened this issue Jan 4, 2022 · 5 comments
Closed

Problem with PHPStan #2101

TristanPouliquen opened this issue Jan 4, 2022 · 5 comments

Comments

@TristanPouliquen
Copy link

TristanPouliquen commented Jan 4, 2022

API Platform version(s) affected: 2.6.7

Description
After updating dependencies to last version, we get these errors in our PHPStan installation:

ParseError (syntax error, unexpected 'static' (T_STATIC)) thrown        
         while looking for class ApiPlatform\Core\Util\ClientTrait80.            
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols   

The PHPStan message isn't very clear, so I'm not sure of what causes the issue as the code inside ClientTrait80 seems fine.

Or is it the static return type on the withOptions method that raises such an alarm?

We are running under PHP7.4

@dpinheiro
Copy link

dpinheiro commented Jan 17, 2022

Having the same problem

Update:
The problem seems to be caused by the ClientTrait

<?php

if (\PHP_VERSION_ID >= 80000) {
    trait ClientTrait
    {
        use ClientTrait80;
    }
} else {
    trait ClientTrait
    {
        use ClientTrait72;
    }
}

for my understanding PHPStand doesn't interpret the if condition so it tries to load the ClientTrait80 and then fails because the method withOptions tries to return static

@dpinheiro
Copy link

btw, just found out this is a duplicate of api-platform/core#4614, and an issue has been already created on phpstan repo phpstan/phpstan#6386

guess this could be closed

@TristanPouliquen
Copy link
Author

Well spotted, I hadn't found it! :-) Closing the issue then

@ondrejmirtes
Copy link

This is going to be fixed in PHPStan 1.4.2 which is going to be released soon.

@ondrejmirtes
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants