diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 0fa6d42c17..bd27323366 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -2916,6 +2916,10 @@ protected function processAdditional() continue; } + if ($suspectedType === 'property or parameter') { + unset($allowed[\T_STATIC]); + } + $typeTokenCount = 0; $typeOperators = [$i]; $confirmed = false; @@ -2948,6 +2952,7 @@ protected function processAdditional() if ($suspectedType === 'property or parameter' && (isset(Util\Tokens::$scopeModifiers[$this->tokens[$x]['code']]) === true || $this->tokens[$x]['code'] === T_VAR + || $this->tokens[$x]['code'] === T_STATIC || $this->tokens[$x]['code'] === T_READONLY) ) { // This will also confirm constructor property promotion parameters, but that's fine. diff --git a/tests/Core/File/GetMemberPropertiesTest.inc b/tests/Core/File/GetMemberPropertiesTest.inc index f40b6021f4..0e62babddd 100644 --- a/tests/Core/File/GetMemberPropertiesTest.inc +++ b/tests/Core/File/GetMemberPropertiesTest.inc @@ -210,7 +210,8 @@ $anon = class() { /* testPHP8UnionTypesIllegalTypes */ // Intentional fatal error - types which are not allowed for properties, but that's not the concern of the method. - public callable|static|void $unionTypesIllegalTypes; + // Note: static is also not allowed as a type, but using static for a property type is not supported by the tokenizer. + public callable|void $unionTypesIllegalTypes; /* testPHP8UnionTypesNullable */ // Intentional fatal error - nullability is not allowed with union types, but that's not the concern of the method. diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index 934d8e2890..1a22b20bcd 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -584,8 +584,7 @@ public function dataGetMemberProperties() 'scope_specified' => true, 'is_static' => false, 'is_readonly' => false, - // Missing static, but that's OK as not an allowed syntax. - 'type' => 'callable||void', + 'type' => 'callable|void', 'nullable_type' => false, ], ], diff --git a/tests/Core/Tokenizer/BitwiseOrTest.inc b/tests/Core/Tokenizer/BitwiseOrTest.inc index bfdbdc18c1..b17c4716fb 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.inc +++ b/tests/Core/Tokenizer/BitwiseOrTest.inc @@ -48,6 +48,9 @@ class TypeUnion /* testTypeUnionPropertyWithOnlyReadOnlyKeyword */ readonly string|null $nullableString; + /* testTypeUnionPropertyWithOnlyStaticKeyword */ + static Foo|Bar $obj; + public function paramTypes( /* testTypeUnionParam1 */ int|float $paramA /* testBitwiseOrParamDefaultValue */ = CONSTANT_A | CONSTANT_B, diff --git a/tests/Core/Tokenizer/BitwiseOrTest.php b/tests/Core/Tokenizer/BitwiseOrTest.php index d56e7340aa..c04a9655fa 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.php +++ b/tests/Core/Tokenizer/BitwiseOrTest.php @@ -110,6 +110,7 @@ public function dataTypeUnion() ['/* testTypeUnionPropertyWithStaticAndReadOnlyKeywords */'], ['/* testTypeUnionPropertyWithVarAndReadOnlyKeywords */'], ['/* testTypeUnionPropertyWithOnlyReadOnlyKeyword */'], + ['/* testTypeUnionPropertyWithOnlyStaticKeyword */'], ['/* testTypeUnionParam1 */'], ['/* testTypeUnionParam2 */'], ['/* testTypeUnionParam3 */'], diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.inc b/tests/Core/Tokenizer/TypeIntersectionTest.inc index abf9b85ba8..ad421cba5a 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.inc +++ b/tests/Core/Tokenizer/TypeIntersectionTest.inc @@ -36,6 +36,9 @@ class TypeIntersection /* testTypeIntersectionPropertyWithReadOnlyKeyword */ protected readonly Foo&Bar $fooBar; + /* testTypeIntersectionPropertyWithStaticKeyword */ + static Foo&Bar $obj; + public function paramTypes( /* testTypeIntersectionParam1 */ Foo&Bar $paramA /* testBitwiseAndParamDefaultValue */ = CONSTANT_A & CONSTANT_B, diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.php b/tests/Core/Tokenizer/TypeIntersectionTest.php index 2170021933..be9567b3f6 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.php +++ b/tests/Core/Tokenizer/TypeIntersectionTest.php @@ -109,6 +109,7 @@ public function dataTypeIntersection() ['/* testTypeIntersectionPropertyPartiallyQualified */'], ['/* testTypeIntersectionPropertyFullyQualified */'], ['/* testTypeIntersectionPropertyWithReadOnlyKeyword */'], + ['/* testTypeIntersectionPropertyWithStaticKeyword */'], ['/* testTypeIntersectionParam1 */'], ['/* testTypeIntersectionParam2 */'], ['/* testTypeIntersectionParam3 */'],