-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Labels
Milestone
Description
Bug report
If you perform an assertion based on the result of a function/method which is dependant on some external state PHPStan still remembers the result. A simple example using date/time functions which is where I originally noticed this issue:
\assert(idate('s') === 30);
\PHPStan\dumpType(idate('s')); // Should be int|false not 30However it seems file related functions are also affected:
\assert(file_get_contents('foo') === 'testing');
\PHPStan\dumpType(file_get_contents('foo')); // Should not be 'testing'It appears the Pure annotation has a parameter which could probably help with solving this: https://github.com/JetBrains/phpstorm-stubs/blob/b475de05d2bc6b6f048c62c9f4bfc9c32ffb2944/meta/attributes/Pure.php#L19
Code snippet that reproduces the problem
https://phpstan.org/r/4f51152c-e1e0-470c-a4f9-42f454b75af1
https://phpstan.org/r/a608f304-d845-4de4-b13f-4b4e93a5e0a9
Expected output
N/A
Reactions are currently unavailable