PATH:
opt
/
cpanel
/
ea-wappspector
/
vendor
/
squizlabs
/
php_codesniffer
/
tests
/
Core
/
Tokenizers
/
PHP
<?php /** * Tests the support of PHP 8 attributes * * @copyright 2025 PHPCSStandards and contributors * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/HEAD/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizers\PHP; use PHP_CodeSniffer\Tests\Core\Tokenizers\AbstractTokenizerTestCase; final class AttributesParseError3Test extends AbstractTokenizerTestCase { /** * Test that invalid attribute (or comment starting with #[ and without ]) are parsed correctly * and that tokens "within" the attribute are not removed. * * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize * @covers PHP_CodeSniffer\Tokenizers\PHP::findCloser * @covers PHP_CodeSniffer\Tokenizers\PHP::parsePhpAttribute * * @return void */ public function testInvalidAttribute() { $tokens = $this->phpcsFile->getTokens(); $attribute = $this->getTargetToken('/* testLiveCoding */', T_ATTRIBUTE); $this->assertArrayHasKey('attribute_closer', $tokens[$attribute]); $this->assertNull($tokens[$attribute]['attribute_closer']); $expectedTokenCodes = [ 'T_ATTRIBUTE', 'T_STRING', 'T_OPEN_PARENTHESIS', 'T_LNUMBER', 'T_CLOSE_PARENTHESIS', 'T_COMMA', 'T_WHITESPACE', 'T_STRING', 'T_OPEN_PARENTHESIS', 'T_WHITESPACE', 'T_WHITESPACE', 'T_PUBLIC', 'T_WHITESPACE', 'T_FINAL', 'T_WHITESPACE', 'T_FUNCTION', ]; $length = count($expectedTokenCodes); $map = array_map( function ($token) { if ($token['code'] === T_ATTRIBUTE) { $this->assertArrayHasKey('attribute_closer', $token); $this->assertNull($token['attribute_closer']); } else { $this->assertArrayNotHasKey('attribute_closer', $token); } return $token['type']; }, array_slice($tokens, $attribute, $length) ); $this->assertSame($expectedTokenCodes, $map); }//end testInvalidAttribute() }//end class
[+]
..
[-] AnonClassParenthesisOwnerTest.inc
[edit]
[-] AnonClassParenthesisOwnerTest.php
[edit]
[-] ArrayKeywordTest.inc
[edit]
[-] ArrayKeywordTest.php
[edit]
[-] AttributesParseError1Test.inc
[edit]
[-] AttributesParseError1Test.php
[edit]
[-] AttributesParseError2Test.inc
[edit]
[-] AttributesParseError2Test.php
[edit]
[-] AttributesParseError3Test.inc
[edit]
[-] AttributesParseError3Test.php
[edit]
[-] AttributesParseError4Test.inc
[edit]
[-] AttributesParseError4Test.php
[edit]
[-] AttributesTest.inc
[edit]
[-] AttributesTest.php
[edit]
[-] BackfillAsymmetricVisibilityTest.inc
[edit]
[-] BackfillAsymmetricVisibilityTest.php
[edit]
[-] BackfillEnumTest.inc
[edit]
[-] BackfillEnumTest.php
[edit]
[-] BackfillExplicitOctalNotationTest.inc
[edit]
[-] BackfillExplicitOctalNotationTest.php
[edit]
[-] BackfillFnTokenParseErrorTest.inc
[edit]
[-] BackfillFnTokenParseErrorTest.php
[edit]
[-] BackfillFnTokenTest.inc
[edit]
[-] BackfillFnTokenTest.php
[edit]
[-] BackfillMatchTokenTest.inc
[edit]
[-] BackfillMatchTokenTest.php
[edit]
[-] BackfillNumericSeparatorTest.inc
[edit]
[-] BackfillNumericSeparatorTest.php
[edit]
[-] BackfillReadonlyTest.inc
[edit]
[-] BackfillReadonlyTest.php
[edit]
[-] BitwiseOrTest.inc
[edit]
[-] BitwiseOrTest.php
[edit]
[-] ContextSensitiveKeywordsTest.inc
[edit]
[-] ContextSensitiveKeywordsTest.php
[edit]
[-] DNFTypesParseError1Test.inc
[edit]
[-] DNFTypesParseError1Test.php
[edit]
[-] DNFTypesParseError2Test.inc
[edit]
[-] DNFTypesParseError2Test.php
[edit]
[-] DNFTypesTest.inc
[edit]
[-] DNFTypesTest.php
[edit]
[-] DefaultKeywordTest.inc
[edit]
[-] DefaultKeywordTest.php
[edit]
[-] DoubleArrowTest.inc
[edit]
[-] DoubleArrowTest.php
[edit]
[-] DoubleQuotedStringTest.inc
[edit]
[-] DoubleQuotedStringTest.php
[edit]
[-] EnumCaseTest.inc
[edit]
[-] EnumCaseTest.php
[edit]
[-] ExitKeywordTest.inc
[edit]
[-] ExitKeywordTest.php
[edit]
[-] FinallyTest.inc
[edit]
[-] FinallyTest.php
[edit]
[-] GotoLabelTest.inc
[edit]
[-] GotoLabelTest.php
[edit]
[-] HeredocNowdocTest.inc
[edit]
[-] HeredocNowdocTest.php
[edit]
[-] HeredocParseErrorTest.inc
[edit]
[-] HeredocParseErrorTest.php
[edit]
[-] HeredocStringTest.inc
[edit]
[-] HeredocStringTest.php
[edit]
[-] NamedFunctionCallArgumentsTest.inc
[edit]
[-] NamedFunctionCallArgumentsTest.php
[edit]
[-] NullableVsInlineThenParseErrorTest.inc
[edit]
[-] NullableVsInlineThenParseErrorTest.php
[edit]
[-] NullableVsInlineThenTest.inc
[edit]
[-] NullableVsInlineThenTest.php
[edit]
[-] NullsafeObjectOperatorTest.inc
[edit]
[-] NullsafeObjectOperatorTest.php
[edit]
[-] OtherContextSensitiveKeywordsTest.inc
[edit]
[-] OtherContextSensitiveKeywordsTest.php
[edit]
[-] PHPOpenTagEOF1Test.inc
[edit]
[-] PHPOpenTagEOF1Test.php
[edit]
[-] PHPOpenTagEOF2Test.inc
[edit]
[-] PHPOpenTagEOF2Test.php
[edit]
[-] PHPOpenTagEOF3Test.inc
[edit]
[-] PHPOpenTagEOF3Test.php
[edit]
[-] ResolveSimpleTokenTest.inc
[edit]
[-] ResolveSimpleTokenTest.php
[edit]
[-] ShortArrayTest.inc
[edit]
[-] ShortArrayTest.php
[edit]
[-] StableCommentWhitespaceTest.inc
[edit]
[-] StableCommentWhitespaceTest.php
[edit]
[-] StableCommentWhitespaceWinTest.inc
[edit]
[-] StableCommentWhitespaceWinTest.php
[edit]
[-] TypeIntersectionTest.inc
[edit]
[-] TypeIntersectionTest.php
[edit]
[-] TypedConstantsTest.inc
[edit]
[-] TypedConstantsTest.php
[edit]
[-] UndoNamespacedNameSingleTokenTest.inc
[edit]
[-] UndoNamespacedNameSingleTokenTest.php
[edit]
[-] YieldTest.inc
[edit]
[-] YieldTest.php
[edit]