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

StatementWithoutSideEffectsRule with expected exception shouldn't raise error #86

Open
Slamdunk opened this issue Oct 26, 2020 · 1 comment

Comments

@Slamdunk
Copy link

final class MyTest extends \PHPUnit\Framework\TestCase
{
    public function testMe(): void
    {
        $foo = new class([1]) extends ArrayIterator {
            public function current(): void
            {
                throw new RuntimeException('foo');
            }
        };
        
        $this->expectException(\RuntimeException::class);

        iterator_to_array($foo);
    }
}

This code reports Call to function iterator_to_array() on a separate line has no effect., but while it's ok on production code (like in https://phpstan.org/r/ee6218f3-4d37-4b5a-9a85-bc6d6ab44d2b) , with PHPUnit is legit as for expectException expectation.

@ondrejmirtes
Copy link
Member

Hi, I don't know how to differentiate between legitimate and illegitimate use-cases, so feel free to just ignore this in the test case :)

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

No branches or pull requests

2 participants