Skip to content

Allow getenv(null) for PHP > 8 #4007

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

Merged
merged 8 commits into from
May 22, 2025
Merged

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented May 22, 2025

@VincentLanglet VincentLanglet force-pushed the getenv branch 3 times, most recently from 29e4b96 to c2c7c8b Compare May 22, 2025 08:53
@VincentLanglet VincentLanglet marked this pull request as ready for review May 22, 2025 09:27
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@VincentLanglet VincentLanglet marked this pull request as draft May 22, 2025 09:34
@VincentLanglet VincentLanglet marked this pull request as ready for review May 22, 2025 09:44
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

I tried the delta change myself, it works.

if (PHP_VERSION_ID < 80000) {
yield __DIR__ . '/data/getenv-php74.php';
} else {
yield __DIR__ . '/data/getenv-php80.php';
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't need to be in NodeScopeResolverTest. Move the files to nsrt/ and label them with proper // lint conditions.

Copy link
Contributor Author

@VincentLanglet VincentLanglet May 22, 2025

Choose a reason for hiding this comment

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

There is already similar conditions checks like above

if (PHP_VERSION_ID < 80000) {
			yield __DIR__ . '/data/explode-php74.php';
		} else {
			yield __DIR__ . '/data/explode-php80.php';
		}

The expectated type are different based on the PHP version, that's why I split the files.

The // lint condition is only used for the linter, not for the tests right ?

Copy link
Member

Choose a reason for hiding this comment

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

Files in nsrt/ when testing type inference are filtered based on// lint as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh ! Awesome !

@ondrejmirtes ondrejmirtes merged commit 1220d8e into phpstan:1.12.x May 22, 2025
312 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

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