File tree Expand file tree Collapse file tree 4 files changed +47
-25
lines changed
tests/Core/Tokenizers/PHP Expand file tree Collapse file tree 4 files changed +47
-25
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ // Intentional parse error.
4+ // This must be the only test in the file.
5+
6+ /* testInvalidAttribute */
7+ #[ThisIsNotAnAttribute
8+ function invalid_attribute_test() {}
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Tests the support of PHP 8 attributes
4+ *
5+ * @author Alessandro Chitolina <alekitto@gmail.com>
6+ * @copyright 2019 Squiz Pty Ltd (ABN 77 084 670 600)
7+ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/HEAD/licence.txt BSD Licence
8+ */
9+
10+ namespace PHP_CodeSniffer \Tests \Core \Tokenizers \PHP ;
11+
12+ use PHP_CodeSniffer \Tests \Core \Tokenizers \AbstractTokenizerTestCase ;
13+
14+ final class AttributesParseError1Test extends AbstractTokenizerTestCase
15+ {
16+
17+
18+ /**
19+ * Test that invalid attribute (or comment starting with #[ and without ]) are parsed correctly.
20+ *
21+ * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize
22+ * @covers PHP_CodeSniffer\Tokenizers\PHP::findCloser
23+ * @covers PHP_CodeSniffer\Tokenizers\PHP::parsePhpAttribute
24+ *
25+ * @return void
26+ */
27+ public function testInvalidAttribute ()
28+ {
29+ $ tokens = $ this ->phpcsFile ->getTokens ();
30+
31+ $ attribute = $ this ->getTargetToken ('/* testInvalidAttribute */ ' , T_ATTRIBUTE );
32+
33+ $ this ->assertArrayHasKey ('attribute_closer ' , $ tokens [$ attribute ]);
34+ $ this ->assertNull ($ tokens [$ attribute ]['attribute_closer ' ]);
35+
36+ }//end testInvalidAttribute()
37+
38+
39+ }//end class
Original file line number Diff line number Diff line change @@ -84,7 +84,3 @@ function attribute_containing_text_looking_like_close_tag() {}
8484 'reason: <https://some-website/reason?> '
8585)]
8686function attribute_containing_mulitline_text_looking_like_close_tag () {}
87-
88- /* testInvalidAttribute */
89- #[ThisIsNotAnAttribute
90- function invalid_attribute_test() {}
Original file line number Diff line number Diff line change @@ -581,27 +581,6 @@ public static function dataAttributeOnTextLookingLikeCloseTag()
581581 }//end dataAttributeOnTextLookingLikeCloseTag()
582582
583583
584- /**
585- * Test that invalid attribute (or comment starting with #[ and without ]) are parsed correctly.
586- *
587- * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize
588- * @covers PHP_CodeSniffer\Tokenizers\PHP::findCloser
589- * @covers PHP_CodeSniffer\Tokenizers\PHP::parsePhpAttribute
590- *
591- * @return void
592- */
593- public function testInvalidAttribute ()
594- {
595- $ tokens = $ this ->phpcsFile ->getTokens ();
596-
597- $ attribute = $ this ->getTargetToken ('/* testInvalidAttribute */ ' , T_ATTRIBUTE );
598-
599- $ this ->assertArrayHasKey ('attribute_closer ' , $ tokens [$ attribute ]);
600- $ this ->assertNull ($ tokens [$ attribute ]['attribute_closer ' ]);
601-
602- }//end testInvalidAttribute()
603-
604-
605584 /**
606585 * Test that nested attributes are parsed correctly.
607586 *
You can’t perform that action at this time.
0 commit comments