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

error_log() is impure #2884

Merged
merged 2 commits into from Jan 22, 2024
Merged

error_log() is impure #2884

merged 2 commits into from Jan 22, 2024

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jan 21, 2024

@staabm staabm marked this pull request as ready for review January 21, 2024 14:43
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@@ -1423,6 +1423,7 @@ public function dataFileAsserts(): iterable
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-10302-interface-extends.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-10302-trait-extends.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-10302-trait-implements.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/impure-error-log.php');
Copy link
Member

Choose a reason for hiding this comment

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

Please don't put at the end, but somewhere random in the middle. This is to prevent conflicts when merging into 1.11.x

$logfile = 'bar/baz.txt';
if (!error_log($message, 3, $logfile)) {
assertType('bool', error_log($message, 3, $logfile));
}
Copy link
Member

Choose a reason for hiding this comment

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

Please always put the code you're testing into an anonymous function. The root scope behaves a little bit differently (see Scope::canAnyVariableExist()) and when we are not testing something specific to the root scope I like to avoid issues with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, forgot about that. thanks for the headsup.

@ondrejmirtes ondrejmirtes merged commit 7c75d21 into phpstan:1.10.x Jan 22, 2024
426 of 428 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
3 participants