Skip to content

A mix of USE statements with and without braces can cause the tokenizer to mismatch brace tokens #1246

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

Merged
merged 1 commit into from
Dec 21, 2016

Conversation

michalbundyra
Copy link
Contributor

Example:

<?php
class MyClass
{
    use MyTrait;
    use AnotherTrait {
        AnotherTrait::method as methodAlias;
    }
}

Current tokens (wrong) - check tokens 8 and 14:

Array
(
    [0] => Array
        (
            [type] => T_OPEN_TAG
            [code] => 379
            [content] => <?php

            [line] => 1
            [column] => 1
            [length] => 5
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [1] => Array
        (
            [code] => 361
            [type] => T_CLASS
            [content] => class
            [line] => 2
            [column] => 1
            [length] => 5
            [scope_condition] => 1
            [scope_opener] => 5
            [scope_closer] => 33
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [2] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 2
            [column] => 6
            [length] => 1
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [3] => Array
        (
            [content] => MyClass
            [code] => 319
            [type] => T_STRING
            [line] => 2
            [column] => 7
            [length] => 7
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [4] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 2
            [column] => 14
            [length] => 0
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [5] => Array
        (
            [type] => T_OPEN_CURLY_BRACKET
            [code] => PHPCS_T_OPEN_CURLY_BRACKET
            [content] => {
            [line] => 3
            [column] => 1
            [length] => 1
            [bracket_opener] => 5
            [bracket_closer] => 33
            [scope_condition] => 1
            [scope_opener] => 5
            [scope_closer] => 33
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [6] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 3
            [column] => 2
            [length] => 0
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [7] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] =>     
            [line] => 4
            [column] => 1
            [length] => 4
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [8] => Array
        (
            [code] => 353
            [type] => T_USE
            [content] => use
            [line] => 4
            [column] => 5
            [length] => 3
            [scope_condition] => 8    // <-- this is use condition for "MyTrait"
            [scope_opener] => 18      // this trait doesn't have scope tokens
            [scope_closer] => 31      // these three values should be for token 14
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [9] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 4
            [column] => 8
            [length] => 1
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [10] => Array
        (
            [content] => MyTrait
            [code] => 319
            [type] => T_STRING
            [line] => 4
            [column] => 9
            [length] => 7
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [11] => Array
        (
            [type] => T_SEMICOLON
            [code] => PHPCS_T_SEMICOLON
            [content] => ;
            [line] => 4
            [column] => 16
            [length] => 1
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [12] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 4
            [column] => 17
            [length] => 0
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [13] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] =>     
            [line] => 5
            [column] => 1
            [length] => 4
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [14] => Array
        (
            [code] => 353
            [type] => T_USE
            [content] => use
            [line] => 5
            [column] => 5
            [length] => 3
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [15] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 5
            [column] => 8
            [length] => 1
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [16] => Array
        (
            [content] => AnotherTrait
            [code] => 319
            [type] => T_STRING
            [line] => 5
            [column] => 9
            [length] => 12
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [17] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 5
            [column] => 21
            [length] => 1
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [18] => Array
        (
            [type] => T_OPEN_CURLY_BRACKET
            [code] => PHPCS_T_OPEN_CURLY_BRACKET
            [content] => {
            [line] => 5
            [column] => 22
            [length] => 1
            [bracket_opener] => 18
            [bracket_closer] => 31
            [scope_condition] => 8
            [scope_opener] => 18
            [scope_closer] => 31
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [19] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 5
            [column] => 23
            [length] => 0
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [20] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] =>         
            [line] => 6
            [column] => 1
            [length] => 8
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [21] => Array
        (
            [type] => T_STRING
            [code] => 319
            [content] => AnotherTrait
            [line] => 6
            [column] => 9
            [length] => 12
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [22] => Array
        (
            [code] => 387
            [type] => T_DOUBLE_COLON
            [content] => ::
            [line] => 6
            [column] => 21
            [length] => 2
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [23] => Array
        (
            [content] => method
            [code] => 319
            [type] => T_STRING
            [line] => 6
            [column] => 23
            [length] => 6
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [24] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 6
            [column] => 29
            [length] => 1
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [25] => Array
        (
            [code] => 338
            [type] => T_AS
            [content] => as
            [line] => 6
            [column] => 30
            [length] => 2
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [26] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 6
            [column] => 32
            [length] => 1
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [27] => Array
        (
            [type] => T_STRING
            [code] => 319
            [content] => methodAlias
            [line] => 6
            [column] => 33
            [length] => 11
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [28] => Array
        (
            [type] => T_SEMICOLON
            [code] => PHPCS_T_SEMICOLON
            [content] => ;
            [line] => 6
            [column] => 44
            [length] => 1
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [29] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 6
            [column] => 45
            [length] => 0
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [30] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] =>     
            [line] => 7
            [column] => 1
            [length] => 4
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [8] => 353
                )

        )

    [31] => Array
        (
            [type] => T_CLOSE_CURLY_BRACKET
            [code] => PHPCS_T_CLOSE_CURLY_BRACKET
            [content] => }
            [line] => 7
            [column] => 5
            [length] => 1
            [bracket_opener] => 18
            [bracket_closer] => 31
            [scope_condition] => 8
            [scope_opener] => 18
            [scope_closer] => 31
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [32] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 7
            [column] => 6
            [length] => 0
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [33] => Array
        (
            [type] => T_CLOSE_CURLY_BRACKET
            [code] => PHPCS_T_CLOSE_CURLY_BRACKET
            [content] => }
            [line] => 8
            [column] => 1
            [length] => 1
            [bracket_opener] => 5
            [bracket_closer] => 33
            [scope_condition] => 1
            [scope_opener] => 5
            [scope_closer] => 33
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [34] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 8
            [column] => 2
            [length] => 0
            [level] => 0
            [conditions] => Array
                (
                )

        )

)

Tokens with fix (correct) - check tokens 8 and 14:

Array
(
    [0] => Array
        (
            [type] => T_OPEN_TAG
            [code] => 379
            [content] => <?php

            [line] => 1
            [column] => 1
            [length] => 5
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [1] => Array
        (
            [code] => 361
            [type] => T_CLASS
            [content] => class
            [line] => 2
            [column] => 1
            [length] => 5
            [scope_condition] => 1
            [scope_opener] => 5
            [scope_closer] => 33
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [2] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 2
            [column] => 6
            [length] => 1
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [3] => Array
        (
            [content] => MyClass
            [code] => 319
            [type] => T_STRING
            [line] => 2
            [column] => 7
            [length] => 7
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [4] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 2
            [column] => 14
            [length] => 0
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [5] => Array
        (
            [type] => T_OPEN_CURLY_BRACKET
            [code] => PHPCS_T_OPEN_CURLY_BRACKET
            [content] => {
            [line] => 3
            [column] => 1
            [length] => 1
            [bracket_opener] => 5
            [bracket_closer] => 33
            [scope_condition] => 1
            [scope_opener] => 5
            [scope_closer] => 33
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [6] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 3
            [column] => 2
            [length] => 0
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [7] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] =>     
            [line] => 4
            [column] => 1
            [length] => 4
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [8] => Array
        (
            [code] => 353
            [type] => T_USE
            [content] => use
            [line] => 4
            [column] => 5
            [length] => 3
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [9] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 4
            [column] => 8
            [length] => 1
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [10] => Array
        (
            [content] => MyTrait
            [code] => 319
            [type] => T_STRING
            [line] => 4
            [column] => 9
            [length] => 7
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [11] => Array
        (
            [type] => T_SEMICOLON
            [code] => PHPCS_T_SEMICOLON
            [content] => ;
            [line] => 4
            [column] => 16
            [length] => 1
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [12] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 4
            [column] => 17
            [length] => 0
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [13] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] =>     
            [line] => 5
            [column] => 1
            [length] => 4
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [14] => Array
        (
            [code] => 353
            [type] => T_USE
            [content] => use
            [line] => 5
            [column] => 5
            [length] => 3
            [scope_condition] => 14
            [scope_opener] => 18
            [scope_closer] => 31
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [15] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 5
            [column] => 8
            [length] => 1
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [16] => Array
        (
            [content] => AnotherTrait
            [code] => 319
            [type] => T_STRING
            [line] => 5
            [column] => 9
            [length] => 12
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [17] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 5
            [column] => 21
            [length] => 1
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [18] => Array
        (
            [type] => T_OPEN_CURLY_BRACKET
            [code] => PHPCS_T_OPEN_CURLY_BRACKET
            [content] => {
            [line] => 5
            [column] => 22
            [length] => 1
            [bracket_opener] => 18
            [bracket_closer] => 31
            [scope_condition] => 14
            [scope_opener] => 18
            [scope_closer] => 31
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [19] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 5
            [column] => 23
            [length] => 0
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [20] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] =>         
            [line] => 6
            [column] => 1
            [length] => 8
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [21] => Array
        (
            [type] => T_STRING
            [code] => 319
            [content] => AnotherTrait
            [line] => 6
            [column] => 9
            [length] => 12
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [22] => Array
        (
            [code] => 387
            [type] => T_DOUBLE_COLON
            [content] => ::
            [line] => 6
            [column] => 21
            [length] => 2
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [23] => Array
        (
            [content] => method
            [code] => 319
            [type] => T_STRING
            [line] => 6
            [column] => 23
            [length] => 6
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [24] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 6
            [column] => 29
            [length] => 1
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [25] => Array
        (
            [code] => 338
            [type] => T_AS
            [content] => as
            [line] => 6
            [column] => 30
            [length] => 2
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [26] => Array
        (
            [code] => 382
            [type] => T_WHITESPACE
            [content] =>  
            [line] => 6
            [column] => 32
            [length] => 1
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [27] => Array
        (
            [type] => T_STRING
            [code] => 319
            [content] => methodAlias
            [line] => 6
            [column] => 33
            [length] => 11
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [28] => Array
        (
            [type] => T_SEMICOLON
            [code] => PHPCS_T_SEMICOLON
            [content] => ;
            [line] => 6
            [column] => 44
            [length] => 1
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [29] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 6
            [column] => 45
            [length] => 0
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [30] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] =>     
            [line] => 7
            [column] => 1
            [length] => 4
            [level] => 2
            [conditions] => Array
                (
                    [1] => 361
                    [14] => 353
                )

        )

    [31] => Array
        (
            [type] => T_CLOSE_CURLY_BRACKET
            [code] => PHPCS_T_CLOSE_CURLY_BRACKET
            [content] => }
            [line] => 7
            [column] => 5
            [length] => 1
            [bracket_opener] => 18
            [bracket_closer] => 31
            [scope_condition] => 14
            [scope_opener] => 18
            [scope_closer] => 31
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [32] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 7
            [column] => 6
            [length] => 0
            [level] => 1
            [conditions] => Array
                (
                    [1] => 361
                )

        )

    [33] => Array
        (
            [type] => T_CLOSE_CURLY_BRACKET
            [code] => PHPCS_T_CLOSE_CURLY_BRACKET
            [content] => }
            [line] => 8
            [column] => 1
            [length] => 1
            [bracket_opener] => 5
            [bracket_closer] => 33
            [scope_condition] => 1
            [scope_opener] => 5
            [scope_closer] => 33
            [level] => 0
            [conditions] => Array
                (
                )

        )

    [34] => Array
        (
            [type] => T_WHITESPACE
            [code] => 382
            [content] => 

            [line] => 8
            [column] => 2
            [length] => 0
            [level] => 0
            [conditions] => Array
                (
                )

        )

)

@aik099
Copy link
Contributor

aik099 commented Dec 17, 2016

Please also add test case for made change.

@gsherwood
Copy link
Member

Please also add test case for made change.

I can't actually find a sniff that breaks with the current code, although the brace matching is obviously wrong. I'd have to write a new sniff to have it properly tested.

@gsherwood gsherwood changed the title USE statement can be defined without scope tokens A mix of USE statements with and without braces can cause the tokenizer to mismatch brace tokens Dec 21, 2016
@gsherwood gsherwood merged commit 1528434 into squizlabs:master Dec 21, 2016
gsherwood added a commit that referenced this pull request Dec 21, 2016
@gsherwood
Copy link
Member

Level map output before:

	*** START LEVEL MAP ***
	Process token 0 on line 1 [col:1;len:5;lvl:0;]: T_OPEN_TAG => <?php\n
	Process token 1 on line 2 [col:1;len:5;lvl:0;]: T_CLASS => class
	Process token 2 on line 2 [col:6;len:1;lvl:0;]: T_WHITESPACE => ·
	Process token 3 on line 2 [col:7;len:7;lvl:0;]: T_STRING => MyClass
	Process token 4 on line 2 [col:14;len:0;lvl:0;]: T_WHITESPACE => \n
	Process token 5 on line 3 [col:1;len:1;lvl:0;]: T_OPEN_CURLY_BRACKET => {
	=> Found scope opener for 1:T_CLASS
		* level increased *
		* token 1:T_CLASS added to conditions array *
		Process token 6 on line 3 [col:2;len:0;lvl:1;conds;T_CLASS;]: T_WHITESPACE => \n
		Process token 7 on line 4 [col:1;len:4;lvl:1;conds;T_CLASS;]: T_WHITESPACE => ····
		Process token 8 on line 4 [col:5;len:3;lvl:1;conds;T_CLASS;]: T_USE => use
		Process token 9 on line 4 [col:8;len:1;lvl:1;conds;T_CLASS;]: T_WHITESPACE => ·
		Process token 10 on line 4 [col:9;len:7;lvl:1;conds;T_CLASS;]: T_STRING => MyTrait
		Process token 11 on line 4 [col:16;len:1;lvl:1;conds;T_CLASS;]: T_SEMICOLON => ;
		Process token 12 on line 4 [col:17;len:0;lvl:1;conds;T_CLASS;]: T_WHITESPACE => \n
		Process token 13 on line 5 [col:1;len:4;lvl:1;conds;T_CLASS;]: T_WHITESPACE => ····
		Process token 14 on line 5 [col:5;len:3;lvl:1;conds;T_CLASS;]: T_USE => use
		Process token 15 on line 5 [col:8;len:1;lvl:1;conds;T_CLASS;]: T_WHITESPACE => ·
		Process token 16 on line 5 [col:9;len:12;lvl:1;conds;T_CLASS;]: T_STRING => AnotherTrait
		Process token 17 on line 5 [col:21;len:1;lvl:1;conds;T_CLASS;]: T_WHITESPACE => ·
		Process token 18 on line 5 [col:22;len:1;lvl:1;conds;T_CLASS;]: T_OPEN_CURLY_BRACKET => {
		=> Found scope opener for 8:T_USE
			* level increased *
			* token 8:T_USE added to conditions array *
			Process token 19 on line 5 [col:23;len:1;lvl:2;conds;T_CLASS,T_USE;]: T_WHITESPACE => ·
			Process token 20 on line 5 [col:24;len:12;lvl:2;conds;T_CLASS,T_USE;]: T_STRING => AnotherTrait
			Process token 21 on line 5 [col:36;len:2;lvl:2;conds;T_CLASS,T_USE;]: T_DOUBLE_COLON => ::
			Process token 22 on line 5 [col:38;len:6;lvl:2;conds;T_CLASS,T_USE;]: T_STRING => method
			Process token 23 on line 5 [col:44;len:1;lvl:2;conds;T_CLASS,T_USE;]: T_WHITESPACE => ·
			Process token 24 on line 5 [col:45;len:2;lvl:2;conds;T_CLASS,T_USE;]: T_AS => as
			Process token 25 on line 5 [col:47;len:1;lvl:2;conds;T_CLASS,T_USE;]: T_WHITESPACE => ·
			Process token 26 on line 5 [col:48;len:11;lvl:2;conds;T_CLASS,T_USE;]: T_STRING => methodAlias
			Process token 27 on line 5 [col:59;len:1;lvl:2;conds;T_CLASS,T_USE;]: T_SEMICOLON => ;
			Process token 28 on line 5 [col:60;len:0;lvl:2;conds;T_CLASS,T_USE;]: T_WHITESPACE => \n
			Process token 29 on line 6 [col:1;len:4;lvl:2;conds;T_CLASS,T_USE;]: T_WHITESPACE => ····
			Process token 30 on line 6 [col:5;len:1;lvl:2;conds;T_CLASS,T_USE;]: T_CLOSE_CURLY_BRACKET => }
			=> Found scope closer for 18:T_OPEN_CURLY_BRACKET
			* token T_USE removed from conditions array *
			* level decreased *
		Process token 31 on line 6 [col:6;len:0;lvl:1;conds;T_CLASS;]: T_WHITESPACE => \n
		Process token 32 on line 7 [col:1;len:1;lvl:1;conds;T_CLASS;]: T_CLOSE_CURLY_BRACKET => }
		=> Found scope closer for 5:T_OPEN_CURLY_BRACKET
		* token T_CLASS removed from conditions array *
		* level decreased *
	Process token 33 on line 7 [col:2;len:0;lvl:0;]: T_WHITESPACE => \n
	*** END LEVEL MAP ***

Level map output after change:

*** START LEVEL MAP ***
	Process token 0 on line 1 [col:1;len:5;lvl:0;]: T_OPEN_TAG => <?php\n
	Process token 1 on line 2 [col:1;len:5;lvl:0;]: T_CLASS => class
	Process token 2 on line 2 [col:6;len:1;lvl:0;]: T_WHITESPACE => ·
	Process token 3 on line 2 [col:7;len:7;lvl:0;]: T_STRING => MyClass
	Process token 4 on line 2 [col:14;len:0;lvl:0;]: T_WHITESPACE => \n
	Process token 5 on line 3 [col:1;len:1;lvl:0;]: T_OPEN_CURLY_BRACKET => {
	=> Found scope opener for 1:T_CLASS
		* level increased *
		* token 1:T_CLASS added to conditions array *
		Process token 6 on line 3 [col:2;len:0;lvl:1;conds;T_CLASS;]: T_WHITESPACE => \n
		Process token 7 on line 4 [col:1;len:4;lvl:1;conds;T_CLASS;]: T_WHITESPACE => ····
		Process token 8 on line 4 [col:5;len:3;lvl:1;conds;T_CLASS;]: T_USE => use
		Process token 9 on line 4 [col:8;len:1;lvl:1;conds;T_CLASS;]: T_WHITESPACE => ·
		Process token 10 on line 4 [col:9;len:7;lvl:1;conds;T_CLASS;]: T_STRING => MyTrait
		Process token 11 on line 4 [col:16;len:1;lvl:1;conds;T_CLASS;]: T_SEMICOLON => ;
		Process token 12 on line 4 [col:17;len:0;lvl:1;conds;T_CLASS;]: T_WHITESPACE => \n
		Process token 13 on line 5 [col:1;len:4;lvl:1;conds;T_CLASS;]: T_WHITESPACE => ····
		Process token 14 on line 5 [col:5;len:3;lvl:1;conds;T_CLASS;]: T_USE => use
		Process token 15 on line 5 [col:8;len:1;lvl:1;conds;T_CLASS;]: T_WHITESPACE => ·
		Process token 16 on line 5 [col:9;len:12;lvl:1;conds;T_CLASS;]: T_STRING => AnotherTrait
		Process token 17 on line 5 [col:21;len:1;lvl:1;conds;T_CLASS;]: T_WHITESPACE => ·
		Process token 18 on line 5 [col:22;len:1;lvl:1;conds;T_CLASS;]: T_OPEN_CURLY_BRACKET => {
		=> Found scope opener for 14:T_USE
			* level increased *
			* token 14:T_USE added to conditions array *
			Process token 19 on line 5 [col:23;len:1;lvl:2;conds;T_CLASS,T_USE;]: T_WHITESPACE => ·
			Process token 20 on line 5 [col:24;len:12;lvl:2;conds;T_CLASS,T_USE;]: T_STRING => AnotherTrait
			Process token 21 on line 5 [col:36;len:2;lvl:2;conds;T_CLASS,T_USE;]: T_DOUBLE_COLON => ::
			Process token 22 on line 5 [col:38;len:6;lvl:2;conds;T_CLASS,T_USE;]: T_STRING => method
			Process token 23 on line 5 [col:44;len:1;lvl:2;conds;T_CLASS,T_USE;]: T_WHITESPACE => ·
			Process token 24 on line 5 [col:45;len:2;lvl:2;conds;T_CLASS,T_USE;]: T_AS => as
			Process token 25 on line 5 [col:47;len:1;lvl:2;conds;T_CLASS,T_USE;]: T_WHITESPACE => ·
			Process token 26 on line 5 [col:48;len:11;lvl:2;conds;T_CLASS,T_USE;]: T_STRING => methodAlias
			Process token 27 on line 5 [col:59;len:1;lvl:2;conds;T_CLASS,T_USE;]: T_SEMICOLON => ;
			Process token 28 on line 5 [col:60;len:0;lvl:2;conds;T_CLASS,T_USE;]: T_WHITESPACE => \n
			Process token 29 on line 6 [col:1;len:4;lvl:2;conds;T_CLASS,T_USE;]: T_WHITESPACE => ····
			Process token 30 on line 6 [col:5;len:1;lvl:2;conds;T_CLASS,T_USE;]: T_CLOSE_CURLY_BRACKET => }
			=> Found scope closer for 18:T_OPEN_CURLY_BRACKET
			* token T_USE removed from conditions array *
			* level decreased *
		Process token 31 on line 6 [col:6;len:0;lvl:1;conds;T_CLASS;]: T_WHITESPACE => \n
		Process token 32 on line 7 [col:1;len:1;lvl:1;conds;T_CLASS;]: T_CLOSE_CURLY_BRACKET => }
		=> Found scope closer for 5:T_OPEN_CURLY_BRACKET
		* token T_CLASS removed from conditions array *
		* level decreased *
	Process token 33 on line 7 [col:2;len:0;lvl:0;]: T_WHITESPACE => \n
	*** END LEVEL MAP ***

So change looks good. All tests pass. Thanks a lot for the PR.

@michalbundyra michalbundyra deleted the hotfix/use-scope branch July 24, 2017 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants