Skip to content

Resolve substr based on configured PHP version #4061

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

Open
wants to merge 1 commit into
base: 1.12.x
Choose a base branch
from

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Jun 13, 2025

@VincentLanglet VincentLanglet force-pushed the substr branch 2 times, most recently from 6c212e9 to 364fbed Compare June 13, 2025 06:55
@@ -4,7 +4,7 @@

use PHPStan\Testing\TypeInferenceTestCase;

class LooseConstComparisonPhp7Test extends TypeInferenceTestCase
class NodeScopeResolverPhp7Test extends TypeInferenceTestCase
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the neon file is only

parameters:
	phpVersion: 70400 # PHP 7.4

we could use those TestCase for all the configured-phpVersion-related tests instead of creating a TestCase every time.

@VincentLanglet VincentLanglet marked this pull request as ready for review June 13, 2025 07:05
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@@ -0,0 +1,9 @@
<?php
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can add the lint comment which makes the file beeing analyzed in the proper version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint comment is for the runtime PHP version no ? (Like it's done for a lot of NodeScopeResolverPHPTest).

Here I want to allow Analysing this file on both PHP 7 and PHP 8, but telling PHPStan to consider he's in PHP 7.

@staabm
Copy link
Contributor

staabm commented Jun 13, 2025

btw: since phpunit got upgraded on the PHPStan 2.x branch, we need to be careful to send PRs to PHPStan 1.12.x only when easy mergabe into 2.x (attributes got added etc)

@VincentLanglet
Copy link
Contributor Author

btw: since phpunit got upgraded on the PHPStan 2.x branch, we need to be careful to send PRs to PHPStan 1.12.x only when easy mergabe into 2.x (attributes got added etc)

Only change is this attribute
https://github.com/phpstan/phpstan-src/blob/2.1.x/tests/PHPStan/Analyser/LooseConstComparisonPhp7Test.php#L24

I dunno if it will even create a conflict but if ondrej ask, I can target 2.1.x instead :)

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