You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PSR12.Files.ImportStatement sniff is being applied to use statements within a class, where they are used to implement traits. The sniff should not be applied in this scenario.
The PSR-12 documentation in section 3 applies to import statements before the class definition as described in the list at the top of the section (class-based, function-based, constant-based).
Traits are documented separately in section 4.2 and describe the requirements for the use keyword to implement traits, but does not require that the value does not start with a backslash.
h2. Current behaviour
<?phpnamespaceMyNamespace;
classMyClass
{
use \MyTrait;
}
$ phpcs --standard=PSR12 test.php -1-
FILE: test.php
---------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------
7 | ERROR | Import statements must not begin with a leading backslash
---------------------------------------------------------------------------------
h2. Expected behaviour
With the same example, no error is found.
The text was updated successfully, but these errors were encountered:
The
PSR12.Files.ImportStatement
sniff is being applied touse
statements within a class, where they are used to implement traits. The sniff should not be applied in this scenario.The PSR-12 documentation in section 3 applies to import statements before the class definition as described in the list at the top of the section (class-based, function-based, constant-based).
Traits are documented separately in section 4.2 and describe the requirements for the
use
keyword to implement traits, but does not require that the value does not start with a backslash.h2. Current behaviour
h2. Expected behaviour
With the same example, no error is found.
The text was updated successfully, but these errors were encountered: