Skip to content

Incorrect class name on use #73

marcghorayeb opened this Issue Apr 11, 2013 · 1 comment

2 participants

Union of RAD member

use app\models\site\Sections as SiteSections;

If there is more than one whitespace after the as, the additional whitespace is considered to be inside the class name and it will look up that class name for the UnusedUseStatements rule.

(of course, the issue is the fact that the double whitespace shouldn't be there in the first place;) )

Union of RAD member

I see the issue. We could fix the use statement issue by changing:

-if (preg_match('/^use (?:([^ ]+ as )|(.*\\\))?(.*);$/i', $line, $matches) === 1) {
+if (preg_match('/^use (?:([^ ]+[ ]+as[ ]+)|(.*\\\))?(.*);$/i', $line, $matches) === 1) {

I think if we do this it should also be added to ControlStructuresHaveCorrectSpacing. It's name has already lost it's meaning.

T_CLASS => array(
    'message' => 'Unexpected T_USE format. Should be: "use foo as bar;" or "use foo;"',
    'patterns' => array(
        "/^use (?:([^ ]+ as )|(.*\\\))?(.*);$/i",

I'll update later, unless you want to tackle a pr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.