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

False positive PSR1.Files.SideEffects.FoundWithSymbols when using php8 attribute #3283

Closed
dakorpar opened this issue Mar 29, 2021 · 2 comments

Comments

@dakorpar
Copy link

Describe the bug
Simple attribute class gives warning

Code sample

<?php declare(strict_types = 1);

namespace My\Namespace;

#[\Attribute]
class Cached
{

}

Custom ruleset

<?xml version="1.0"?>
<ruleset name="My Custom Standard">
  <description>If you are using a custom ruleset, please enter it here.</description>
 <rule ref="PSR1.Files.SideEffects.FoundWithSymbols"></rule
</ruleset>

To reproduce
Steps to reproduce the behavior:
3. See error message displayed

FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 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 6 and
   |         | the first side effect is on line 5.

Expected behavior

Versions (please complete the following information):

  • OS: [e.g., Windows 10, MacOS 10.15]
  • PHP: [8.0]
  • PHPCS: [dev-master]
  • Standard: [PSR1]
@jrfnl
Copy link
Contributor

jrfnl commented Mar 29, 2021

As per #3182 and #3203, attributes are not yet supported in PHPCS, not even in dev-master. Testing of #3203 could help move it forward, but without that PR (or an iteration of it) being merged, it won't be possible to start making sniffs compatible with attributes yet.

@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Mar 29, 2021
@gsherwood gsherwood added this to the 3.6.0 milestone Mar 29, 2021
@gsherwood
Copy link
Member

Now that attribute support has been merged, I've updated this sniff to ignore attributes, which fixes this problem. Thanks for reporting it.

PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
PHPCS v3 Development
Ready for Release
Development

No branches or pull requests

3 participants