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

Forbid assertions based on non-pure expressions #4392

Open
morozov opened this issue Oct 21, 2020 · 1 comment
Open

Forbid assertions based on non-pure expressions #4392

morozov opened this issue Oct 21, 2020 · 1 comment

Comments

@morozov
Copy link
Contributor

morozov commented Oct 21, 2020

Currently, such assertions are not reported as an issue: https://psalm.dev/r/d5d33b6c18 but in practice, they are (see doctrine/dbal#4359).

Given that the behavior of the assert() function is different depending on the development/production settings, the side effects within the assertions cannot be relied upon and shouldn't be allowed.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/d5d33b6c18
<?php

function nonPure(): bool {
    echo 'SIDE EFFECT';

    return true;
}

assert(nonPure());
Psalm output (using commit fd43ba7):

No issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants