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
error_log() is impure #2884
Conversation
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'); |
There was a problem hiding this comment.
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)); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Thank you. |
closes phpstan/phpstan#10437