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
syntax error with phpstan starting with 2.6.7 #4614
Comments
I am currently having the same problem. |
hm, maybe api-platform should avoid php8-only syntax until php8 is required? |
It tries to avoid that https://github.com/api-platform/core/blob/4ec515837cf696788e828a61005594fffc4cf244/src/Util/ClientTrait.php :) |
yeah, but phpstan parses all referenced files anyway and then fails (I don't think it knows anything about PHP_VERSION_ID). And phpstan doesn't provide a way to skip files before parsing, only after parsing :( |
How your ApiTest looks like? |
This resulted in phpstan to fail if the active PHP version is <8.0: Internal error: syntax error, unexpected 'static' (T_STATIC) In case a project depending on api-platform/core would use ClientTrait directly, or indirectly, phpstan would try to parse it and fail with the above syntax error. Move the type declarations into a comment instead. Fixes api-platform#4614
This is enough to trigger the error: <?php
declare(strict_types=1);
namespace App\Tests;
use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Client;
class Test extends ApiTestCase
{
protected function setUp(): void
{
parent::setUp();
static::createClient();
}
} |
Since #4636 (comment) says this is a phpstan issue I've opened a bug report with phpstan: phpstan/phpstan#6386 |
This is going to be fixed in PHPStan 1.4.2 which is going to be released soon. |
Confirmed. Thank you! 🙏 |
I use phpstan in my project and after the update to 2.6.7 phpstan fails with a "syntax error":
The internal error is (I'm using php 7.4):
Does anyone know how to work around that?
The text was updated successfully, but these errors were encountered: