Php_codesniffer: PSR2.Namespaces.UseDeclaration not giving error for use statements before the namespace declaration

Created on 6 Feb 2018  路  4Comments  路  Source: squizlabs/PHP_CodeSniffer

The PSR2 Namespaces/UseDeclarationSniff does not seem to be validating the When present, all use declarations MUST go after the namespace declaration. rule properly.

Example (passes without any errors!):

<?php

use DateTime;
use Exception;
use Throwable;

namespace App;

class Foo
{
    protected $bar;
}

phpcs --version
PHP_CodeSniffer version 3.2.2 (stable) by Squiz (http://www.squiz.net)

Running: phpcs -s --standard=PSR2 test.php

Bug

All 4 comments

Any updates on this?

No, I haven't got to this yet.

Thanks for reporting this. Fix will be in 3.3.0.

Neat! Thanks for the support @gsherwood

Was this page helpful?
0 / 5 - 0 ratings