File tree Expand file tree Collapse file tree 8 files changed +18
-3
lines changed Expand file tree Collapse file tree 8 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,8 @@ The file documents changes to the PHP_CodeSniffer project.
127127 - Thanks to Dan Wallis (@fredden ) for the patch
128128- Fixed bug #3816 : PSR12/FileHeader: bug fix - false positives on PHP 8.2+ readonly classes
129129 - Thanks to Juliette Reinders Folmer (@jrfnl ) for the patch
130+ - Fixed bug #3867 : Tokenizer/PHP: union type and intersection type operators were not correctly tokenized for static properties without explicit visibility
131+ - Thanks to Juliette Reinders Folmer (@jrfnl ) for the patch
130132- Fixed bug #3877 : Filter names can be case-sensitive. The -h help text will now display the correct case for the available filters
131133 - Thanks to @simonsan for the patch
132134- Fixed bug #3906 : Tokenizer/CSS: fixed a bug related to the unsupported slash comment syntax
Original file line number Diff line number Diff line change @@ -2998,6 +2998,10 @@ protected function processAdditional()
29982998 continue ;
29992999 }
30003000
3001+ if ($ suspectedType === 'property or parameter ' ) {
3002+ unset($ allowed [\T_STATIC ]);
3003+ }
3004+
30013005 $ typeTokenCount = 0 ;
30023006 $ typeOperators = [$ i ];
30033007 $ confirmed = false ;
@@ -3030,6 +3034,7 @@ protected function processAdditional()
30303034 if ($ suspectedType === 'property or parameter '
30313035 && (isset (Util \Tokens::$ scopeModifiers [$ this ->tokens [$ x ]['code ' ]]) === true
30323036 || $ this ->tokens [$ x ]['code ' ] === T_VAR
3037+ || $ this ->tokens [$ x ]['code ' ] === T_STATIC
30333038 || $ this ->tokens [$ x ]['code ' ] === T_READONLY )
30343039 ) {
30353040 // This will also confirm constructor property promotion parameters, but that's fine.
Original file line number Diff line number Diff line change @@ -210,7 +210,8 @@ $anon = class() {
210210
211211 /* testPHP8UnionTypesIllegalTypes */
212212 // Intentional fatal error - types which are not allowed for properties, but that's not the concern of the method.
213- public callable|static |void $ unionTypesIllegalTypes;
213+ // Note: static is also not allowed as a type, but using static for a property type is not supported by the tokenizer.
214+ public callable|void $ unionTypesIllegalTypes ;
214215
215216 /* testPHP8UnionTypesNullable */
216217 // Intentional fatal error - nullability is not allowed with union types, but that's not the concern of the method.
Original file line number Diff line number Diff line change @@ -587,8 +587,7 @@ public function dataGetMemberProperties()
587587 'scope_specified ' => true ,
588588 'is_static ' => false ,
589589 'is_readonly ' => false ,
590- // Missing static, but that's OK as not an allowed syntax.
591- 'type ' => 'callable||void ' ,
590+ 'type ' => 'callable|void ' ,
592591 'nullable_type ' => false ,
593592 ],
594593 ],
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ class TypeUnion
4848 /* testTypeUnionPropertyWithOnlyReadOnlyKeyword */
4949 readonly string |null $ nullableString ;
5050
51+ /* testTypeUnionPropertyWithOnlyStaticKeyword */
52+ static Foo |Bar $ obj ;
53+
5154 public function paramTypes (
5255 /* testTypeUnionParam1 */
5356 int |float $ paramA /* testBitwiseOrParamDefaultValue */ = CONSTANT_A | CONSTANT_B ,
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ public function dataTypeUnion()
110110 ['/* testTypeUnionPropertyWithStaticAndReadOnlyKeywords */ ' ],
111111 ['/* testTypeUnionPropertyWithVarAndReadOnlyKeywords */ ' ],
112112 ['/* testTypeUnionPropertyWithOnlyReadOnlyKeyword */ ' ],
113+ ['/* testTypeUnionPropertyWithOnlyStaticKeyword */ ' ],
113114 ['/* testTypeUnionParam1 */ ' ],
114115 ['/* testTypeUnionParam2 */ ' ],
115116 ['/* testTypeUnionParam3 */ ' ],
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ class TypeIntersection
3636 /* testTypeIntersectionPropertyWithReadOnlyKeyword */
3737 protected readonly Foo &Bar $ fooBar ;
3838
39+ /* testTypeIntersectionPropertyWithStaticKeyword */
40+ static Foo &Bar $ obj ;
41+
3942 public function paramTypes (
4043 /* testTypeIntersectionParam1 */
4144 Foo &Bar $ paramA /* testBitwiseAndParamDefaultValue */ = CONSTANT_A & CONSTANT_B ,
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ public function dataTypeIntersection()
109109 ['/* testTypeIntersectionPropertyPartiallyQualified */ ' ],
110110 ['/* testTypeIntersectionPropertyFullyQualified */ ' ],
111111 ['/* testTypeIntersectionPropertyWithReadOnlyKeyword */ ' ],
112+ ['/* testTypeIntersectionPropertyWithStaticKeyword */ ' ],
112113 ['/* testTypeIntersectionParam1 */ ' ],
113114 ['/* testTypeIntersectionParam2 */ ' ],
114115 ['/* testTypeIntersectionParam3 */ ' ],
You can’t perform that action at this time.
0 commit comments