Skip to content

Add support for newer Symfony versions in tests#483

Open
stof wants to merge 2 commits intophpstan:2.0.xfrom
stof:test_new_symfony
Open

Add support for newer Symfony versions in tests#483
stof wants to merge 2 commits intophpstan:2.0.xfrom
stof:test_new_symfony

Conversation

@stof
Copy link
Copy Markdown
Contributor

@stof stof commented Apr 22, 2026

Symfony 5.4 is in security-only mode since years (and would already be EOL if its maintenance window had not been extended compared to the normal release schedule). Testing only Symfony 5.4 in CI does not reflect current usage of the extension.

@ondrejmirtes
Copy link
Copy Markdown
Member

I started working on something similar here but it's challenging https://github.com/phpstan/phpstan-symfony/pull/447/changes

@VincentLanglet
Copy link
Copy Markdown
Contributor

This would be great ! Thanks for working on it

@stof stof force-pushed the test_new_symfony branch from 0138f6f to a67897f Compare April 22, 2026 15:08
@stof
Copy link
Copy Markdown
Contributor Author

stof commented Apr 22, 2026

@VincentLanglet @ondrejmirtes what is the way to handle those function.alreadyNarrowedType errors reported by phpstan in places where tests have to alter their behavior based on the version of Symfony components being installed ? The reported errors will depend on the jobs (lowest jobs and jobs for older PHP versions will install some older versions of components, that will still have the old deprecated methods, or might not have the newer APIs, depending on the case).
I see that https://github.com/phpstan/phpstan-symfony/pull/447/changes#diff-a03dfdc240bbe0ba15bbac79aee5cb3182b00e9cfde3f5549d455acbd4f762d1 uses new ReflectionClass()->hasMethod() instead if method_exists, which does not seem to trigger narrowing in phpstan for now. Maybe that's an option for now (until phpstan implements such narrowing).

for the test failures themselves, I will handle them (tests relying on the messenger MessageSubscriberInterface must be skipped for versions where the interface does not exist anymore, and we should have alternative tests using the #[AsMessageHandler] attribute instead)

@VincentLanglet
Copy link
Copy Markdown
Contributor

VincentLanglet commented Apr 22, 2026

What about a conditional baseline, like it's done on PHPStan repository with php versions
https://github.com/phpstan/phpstan-src/blob/2.2.x/build/ignore-by-php-version.neon.php
?

But I'm fine with a phpstan-ignore comment

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

Successfully merging this pull request may close these issues.

3 participants