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

Anonymous class declaration and PSR1.Files.SideEffects.FoundWithSymbols #973

Closed
gsouf opened this issue Apr 25, 2016 · 3 comments
Closed

Comments

@gsouf
Copy link

gsouf commented Apr 25, 2016

Declaring an anonymous class (PHP 7 feature) makes rule PSR1.Files.SideEffects.FoundWithSymbols to fail.

Example:

<?php

$foo = 'bar';

$c =  new class extends Something{

    public function someMethod()
    {
        // ...
    }

};

phpcs error:

/.../test.php:1:1: warning - A file should declare new symbols 
(classes, functions, constants, etc.) and cause no other side effects, 
or it should execute logic with side effects, but should not do both. 
The first symbol is defined on line 7 and the first side effect is on line 3. 
(PSR1.Files.SideEffects.FoundWithSymbols)

Please note that the statement alone will also fail:

<?php

new class extends Something{

    public function someMethod()
    {
        // ...
    }

};
gsherwood added a commit that referenced this issue Apr 26, 2016
@gsherwood
Copy link
Member

The sniff now skips anon classes so it doesn't pick up their methods. Thanks for the report.

@gsouf
Copy link
Author

gsouf commented Apr 26, 2016

Thank you ! Is there a date for the release with the fix ?

@gsherwood
Copy link
Member

No date, but it probably wont be for a few weeks. I only just made the first commits for 2.6.1 this morning, so I've still got to go through the full bug list and spend time testing.

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