-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Generic InlineControlStructureSniff does not support alternative SWITCH syntax #497
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
Comments
Thanks for the report and sample code. The problem was actually with the core tokenizer not supporting the alternate syntax for SWITCH, although it did for other control structures. This is fixed now. |
Nice. And seeing how small changes needed are to support this syntax are even nicer. |
@gsherwood Thanks a lot for your reply and debugging. Unfortunatly I would like you to reopen the issue, since the problem is not fixed entirely. I encountered the same problem in a different spot: test.phtml:
Output:
Repair attempt:
edit / hint: when removing the |
I'll take a look. |
@gsherwood Thanks for your fast reply. Please note my edit / hint |
The problem is actually the lack of a breaking statement for the The end result is a mismatch of statements in the tokenizer, which causes the sniff to see the original IF statement as having no opener and no closer. |
…switch didnt close case statements with no break (further fix for #497)
I've pushed a fix for this. |
Thanks. Now short control structure syntax users will be happy. |
Thanks a lot for fixing! |
This commit adds tests to safeguard against regressions related to squizlabs/PHP_CodeSniffer#497. The commit related to this issue (b24b96b) originally added a few tests to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to squizlabs/PHP_CodeSniffer#497. The commit related to this issue (b24b96b) originally added a few tests to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored in a previous commit to use different control structure.
…tion-call-argument-spacing Generic/FunctionCallArgumentSpacing: improve code coverage
This commit adds tests to safeguard against regressions related to b24b96b which was added to fix one of the issues in squizlabs/PHP_CodeSniffer#497. b24b96b originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. This test was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` is missing shares the closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to b24b96b which was added to fix one of the issues in squizlabs/PHP_CodeSniffer#497. b24b96b originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. This test was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` is missing shares the closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to b24b96b which was added to fix one of the issues in squizlabs/PHP_CodeSniffer#497. b24b96b originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. This test was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` is missing shares the closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to b24b96b which was added to fix one of the issues in squizlabs/PHP_CodeSniffer#497. b24b96b originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. This test was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` is missing shares the closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to b24b96b which was added to fix one of the issues in squizlabs/PHP_CodeSniffer#497. b24b96b originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. This test was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` is missing shares the closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` is missing shares the closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to b24b96b which was added to fix one of the issues in squizlabs/PHP_CodeSniffer#497. b24b96b originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. This test was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored in a previous commit to use different control structure.
This commit adds tests to safeguard against regressions related to fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a originally added a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored in a previous commit to use different control structure.
This commit moves a sniff test to the tokenizer tests. Originally, the moved test was added in b24b96b which is part of squizlabs/PHP_CodeSniffer#497. b24b96b introduce a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. The commit also adds a test to unsure scope is set correctly when using the normal switch syntax. This was not part of b24b96b, but relevant anyway as there are no previous tokenizer test covering this part. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored to use different control structure.
This commit moves a sniff test to tokenizer tests. Originally, the test was added in fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored to use different control structure.
This commit moves a sniff test to the tokenizer tests. Originally, the moved test was added in b24b96b which is part of squizlabs/PHP_CodeSniffer#497. b24b96b introduce a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. The commit also adds a test to unsure scope is set correctly when using the normal switch syntax. This was not part of b24b96b, but relevant anyway as there are no previous tokenizer test covering this part. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored to use different control structure.
This commit moves a sniff test to tokenizer tests. Originally, the test was added in fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored to use different control structure.
This commit moves a sniff test to the tokenizer tests. Originally, the moved test was added in b24b96b which is part of squizlabs/PHP_CodeSniffer#497. b24b96b introduce a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. The commit also adds a test to unsure scope is set correctly when using the normal switch syntax. This was not part of b24b96b, but relevant anyway as there are no previous tokenizer test covering this part. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored to use different control structure.
This commit moves a sniff test to tokenizer tests. Originally, the test was added in fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored to use different control structure.
This commit moves a sniff test to the tokenizer tests. Originally, the moved test was added in b24b96b which is part of squizlabs/PHP_CodeSniffer#497. b24b96b introduce a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. The commit also adds a test to unsure scope is set correctly when using the normal switch syntax. This was not part of b24b96b, but relevant anyway as there are no previous tokenizer test covering this part. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored to use different control structure.
This commit moves a sniff test to tokenizer tests. Originally, the test was added in fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored to use different control structure.
This commit moves a sniff test to the tokenizer tests. Originally, the moved test was added in b24b96b which is part of squizlabs/PHP_CodeSniffer#497. b24b96b introduce a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the T_SWITCH token when handling a `switch` that uses the alternative syntax. The commit also adds a test to unsure scope is set correctly when using the normal switch syntax. This was not part of b24b96b, but relevant anyway as there are no previous tokenizer test covering this part. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in b24b96b became useless and thus was refactored to use different control structure.
This commit moves a sniff test to tokenizer tests. Originally, the test was added in fddc61a which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to a sniff test (InlineControlStructureUnitTest.php) as back then there were no Tokenizer tests. Those tests were added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with `T_SWITCH`. Now that the InlineControlStructure sniff doesn't listen for the T_SWITCH token anymore, the original test added in fddc61a became useless and thus was refactored to use different control structure.
This commit copies, with some modifications, a sniff test to the tokenizer tests. The original test was added in b24b96b, part of squizlabs/PHP_CodeSniffer#497. b24b96b introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_SWITCH` token when handling a `switch` that uses the alternative syntax. This commit also adds a test to ensure the scope is correctly set when using the normal switch syntax. This was not part of b24b96b, but it is relevant anyway, as no other tokenizer test covers this part. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in b24b96b became useless and thus was refactored to use a different control structure. The sniff test was kept as testing code that uses a control structure, and opening and closing PHP tags is an interesting case not covered in other tests.
This commit copies, with some modifications, a sniff test to the tokenizer tests. The original test was added in fddc61a, which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. The test was added to ensure that Tokenizer::recurseScopeMap() correctly adds scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with T_SWITCH`. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in fddc61a became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses nested alternative syntax control structures is still valid and is not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. The original test was added in b24b96b, part of squizlabs/PHP_CodeSniffer#497. b24b96b introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_SWITCH` token when handling a `switch` that uses the alternative syntax. This commit also adds a test to ensure the scope is correctly set when using the normal switch syntax. This was not part of b24b96b, but it is relevant anyway, as no other tokenizer test covers this part. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in b24b96b became useless and thus was refactored to use a different control structure. The sniff test was kept as testing code that uses a control structure, and opening and closing PHP tags is an interesting case not covered in other tests.
This commit copies, with some modifications, a sniff test to the tokenizer tests. The original test was added in fddc61a, which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. The test was added to ensure that Tokenizer::recurseScopeMap() correctly adds scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with T_SWITCH`. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in fddc61a became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses nested alternative syntax control structures is still valid and is not covered in other tests.
This commit copies, with some modifications, a sniff test to the tokenizer tests. The original test was added in fddc61a, which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. The test was added to ensure that Tokenizer::recurseScopeMap() correctly adds scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with T_SWITCH`. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in fddc61a became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses nested alternative syntax control structures is still valid and is not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. Two new tokenizer tests are created as the result of this copy. One to ensure that the scope of `T_CASE` is correctly set when the case shares the scope closer with `T_SWITCH` (no `T_BREAK`). And another to ensure that the scope of `T_IF` is correctly set when there is a nested `T_SWITCH` and `T_CASE` without a `T_BREAK`. The original sniff test was added in fddc61a, which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. The test was added to ensure that Tokenizer::recurseScopeMap() correctly adds scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with T_SWITCH`. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in fddc61a became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses nested alternative syntax control structures is still valid and is not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. The original test was added in b24b96b, part of squizlabs/PHP_CodeSniffer#497. b24b96b introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_SWITCH` token when handling a `switch` that uses the alternative syntax. This commit also adds a test to ensure the scope is correctly set when using the normal switch syntax. This was not part of b24b96b, but it is relevant anyway, as no other tokenizer test covers this part. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in b24b96b became useless and thus was refactored to use a different control structure. The sniff test was kept as testing code that uses a control structure, and opening and closing PHP tags is an interesting case not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. Two new tokenizer tests are created as the result of this copy. One to ensure that the scope of `T_CASE` is correctly set when the case shares the scope closer with `T_SWITCH` (no `T_BREAK`). And another to ensure that the scope of `T_IF` is correctly set when there is a nested `T_SWITCH` and `T_CASE` without a `T_BREAK`. The original sniff test was added in fddc61a, which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. The test was added to ensure that Tokenizer::recurseScopeMap() correctly adds scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with T_SWITCH`. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in fddc61a became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses nested alternative syntax control structures is still valid and is not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. The original test was added in b24b96b, part of squizlabs/PHP_CodeSniffer#497. b24b96b introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_SWITCH` token when handling a `switch` that uses the alternative syntax. This commit also adds a test to ensure the scope is correctly set when using the normal switch syntax. This was not part of b24b96b, but it is relevant anyway, as no other tokenizer test covers this part. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in b24b96b became useless and thus was refactored to use a different control structure. The sniff test was kept as testing code that uses a control structure, and opening and closing PHP tags is an interesting case not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. Two new tokenizer tests are created as the result of this copy. One to ensure that the scope of `T_CASE` is correctly set when the case shares the scope closer with `T_SWITCH` (no `T_BREAK`). And another to ensure that the scope of `T_IF` is correctly set when there is a nested `T_SWITCH` and `T_CASE` without a `T_BREAK`. The original sniff test was added in fddc61a, which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. The test was added to ensure that Tokenizer::recurseScopeMap() correctly adds scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with T_SWITCH`. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in fddc61a became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses nested alternative syntax control structures is still valid and is not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. The original test was added in b24b96b, part of squizlabs/PHP_CodeSniffer#497. b24b96b introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_SWITCH` token when handling a `switch` that uses the alternative syntax. This commit also adds a test to ensure the scope is correctly set when using the normal switch syntax. This was not part of b24b96b, but it is relevant anyway, as no other tokenizer test covers this part. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in b24b96b became useless and thus was refactored to use a different control structure. The sniff test was kept as testing code that uses a control structure, and opening and closing PHP tags is an interesting case not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. Two new tokenizer tests are created as the result of this copy. One to ensure that the scope of `T_CASE` is correctly set when the case shares the scope closer with `T_SWITCH` (no `T_BREAK`). And another to ensure that the scope of `T_IF` is correctly set when there is a nested `T_SWITCH` and `T_CASE` without a `T_BREAK`. The original sniff test was added in fddc61a, which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. The test was added to ensure that Tokenizer::recurseScopeMap() correctly adds scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with T_SWITCH`. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in fddc61a became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses nested alternative syntax control structures is still valid and is not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. The original test was added in b24b96b, part of squizlabs/PHP_CodeSniffer#497. b24b96b introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_SWITCH` token when handling a `switch` that uses the alternative syntax. This commit also adds a test to ensure the scope is correctly set when using the normal switch syntax. This was not part of b24b96b, but it is relevant anyway, as no other tokenizer test covers this part. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in b24b96b became useless and thus was refactored to use a different control structure. The sniff test was kept as testing code that uses a control structure, and opening and closing PHP tags is an interesting case not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. Two new tokenizer tests are created as the result of this copy. One to ensure that the scope of `T_CASE` is correctly set when the case shares the scope closer with `T_SWITCH` (no `T_BREAK`). And another to ensure that the scope of `T_IF` is correctly set when there is a nested `T_SWITCH` and `T_CASE` without a `T_BREAK`. The original sniff test was added in fddc61a, which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. The test was added to ensure that Tokenizer::recurseScopeMap() correctly adds scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with T_SWITCH`. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in fddc61a became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses nested alternative syntax control structures is still valid and is not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. The original test was added in b24b96b, part of squizlabs/PHP_CodeSniffer#497. b24b96b introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_SWITCH` token when handling a `switch` that uses the alternative syntax. This commit also adds a test to ensure the scope is correctly set when using the normal switch syntax. This was not part of b24b96b, but it is relevant anyway, as no other tokenizer test covers this part. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in b24b96b became useless and thus was refactored to use a different control structure. The sniff test was kept as testing code that uses a control structure, and opening and closing PHP tags is an interesting case not covered in other tests.
This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. Two new tokenizer tests are created as the result of this copy. One to ensure that the scope of `T_CASE` is correctly set when the case shares the scope closer with `T_SWITCH` (no `T_BREAK`). And another to ensure that the scope of `T_IF` is correctly set when there is a nested `T_SWITCH` and `T_CASE` without a `T_BREAK`. The original sniff test was added in fddc61a, which is part of squizlabs/PHP_CodeSniffer#497. fddc61a introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. The test was added to ensure that Tokenizer::recurseScopeMap() correctly adds scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with T_SWITCH`. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in fddc61a became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses nested alternative syntax control structures is still valid and is not covered in other tests.
test.phtml: (it's a Zend view script / template)
phpcs.xml:
Output:
The BIG problem is that after running
phpcbf
the code is broken:test.phtml: (after repair attempt)
Now there are wrong brackets:
Hope you can reproduce this.
The text was updated successfully, but these errors were encountered: