Skip to content

Commit

Permalink
Fixed bug #2665 : PSR12.Files.ImportStatement should not apply to traits
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Oct 24, 2019
1 parent 35256b6 commit cc1069d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2663 : Generic.NamingConventions.ConstructorName complains about old constructor in interfaces
- Fixed bug #2664 : PSR12.Files.OpenTag incorrectly identifies PHP file with only an opening tag
- Fixed bug #2665 : PSR12.Files.ImportStatement should not apply to traits
</notes>
<contents>
<dir name="/">
Expand Down
5 changes: 5 additions & 0 deletions src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

if ($phpcsFile->hasCondition($stackPtr, Tokens::$ooScopeTokens) === true) {
// This rule inly applies to import statements.
return;
}

if ($tokens[$next]['code'] === T_STRING
&& (strtolower($tokens[$next]['content']) === 'function'
|| strtolower($tokens[$next]['content']) === 'const')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function getErrorList()
2 => 1,
4 => 1,
7 => 1,
14 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit cc1069d

Please sign in to comment.