Skip to content

Commit 4eeb4dd

Browse files
committed
Merge branch 'feature/tokenizer-php-bugfix-namespaced-type-decl-vs-union-types' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents 41a9bef + 52f2e80 commit 4eeb4dd

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/Tokenizers/PHP.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,6 +2584,7 @@ protected function processAdditional()
25842584
T_STATIC => T_STATIC,
25852585
T_FALSE => T_FALSE,
25862586
T_NULL => T_NULL,
2587+
T_NAMESPACE => T_NAMESPACE,
25872588
T_NS_SEPARATOR => T_NS_SEPARATOR,
25882589
];
25892590

tests/Core/Tokenizer/BitwiseOrTest.inc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ class TypeUnion
2424
/* testTypeUnionPropertyMulti3 */
2525
| null $arrayOrFalse;
2626

27+
/* testTypeUnionPropertyNamespaceRelative */
28+
public namespace\Sub\NameA|namespace\Sub\NameB $namespaceRelative;
29+
30+
/* testTypeUnionPropertyPartiallyQualified */
31+
public Partially\Qualified\NameA|Partially\Qualified\NameB $partiallyQual;
32+
33+
/* testTypeUnionPropertyFullyQualified */
34+
public \Fully\Qualified\NameA|\Fully\Qualified\NameB $fullyQual;
35+
2736
public function paramTypes(
2837
/* testTypeUnionParam1 */
2938
int|float $paramA /* testBitwiseOrParamDefaultValue */ = CONSTANT_A | CONSTANT_B,
@@ -35,6 +44,15 @@ class TypeUnion
3544
return (($a1 ^ $b1) |($a2 ^ $b2)) + $c;
3645
}
3746

47+
public function identifierNames(
48+
/* testTypeUnionParamNamespaceRelative */
49+
namespace\Sub\NameA|namespace\Sub\NameB $paramA,
50+
/* testTypeUnionParamPartiallyQualified */
51+
Partially\Qualified\NameA|Partially\Qualified\NameB $paramB,
52+
/* testTypeUnionParamFullyQualified */
53+
\Fully\Qualified\NameA|\Fully\Qualified\NameB $paramC,
54+
) {}
55+
3856
/* testTypeUnionReturnType */
3957
public function returnType() : int|false {}
4058

@@ -43,6 +61,15 @@ class TypeUnion
4361

4462
/* testTypeUnionAbstractMethodReturnType1 */
4563
abstract public function abstractMethod(): object|array /* testTypeUnionAbstractMethodReturnType2 */ |false;
64+
65+
/* testTypeUnionReturnTypeNamespaceRelative */
66+
public function identifierNamesReturnRelative() : namespace\Sub\NameA|namespace\Sub\NameB {}
67+
68+
/* testTypeUnionReturnPartiallyQualified */
69+
public function identifierNamesReturnPQ() : Partially\Qualified\NameA|Partially\Qualified\NameB {}
70+
71+
/* testTypeUnionReturnFullyQualified */
72+
public function identifierNamesReturnFQ() : \Fully\Qualified\NameA|\Fully\Qualified\NameB {}
4673
}
4774

4875
/* testTypeUnionClosureParamIllegalNullable */

tests/Core/Tokenizer/BitwiseOrTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,22 @@ public function dataTypeUnion()
102102
['/* testTypeUnionPropertyMulti1 */'],
103103
['/* testTypeUnionPropertyMulti2 */'],
104104
['/* testTypeUnionPropertyMulti3 */'],
105+
['/* testTypeUnionPropertyNamespaceRelative */'],
106+
['/* testTypeUnionPropertyPartiallyQualified */'],
107+
['/* testTypeUnionPropertyFullyQualified */'],
105108
['/* testTypeUnionParam1 */'],
106109
['/* testTypeUnionParam2 */'],
107110
['/* testTypeUnionParam3 */'],
111+
['/* testTypeUnionParamNamespaceRelative */'],
112+
['/* testTypeUnionParamPartiallyQualified */'],
113+
['/* testTypeUnionParamFullyQualified */'],
108114
['/* testTypeUnionReturnType */'],
109115
['/* testTypeUnionConstructorPropertyPromotion */'],
110116
['/* testTypeUnionAbstractMethodReturnType1 */'],
111117
['/* testTypeUnionAbstractMethodReturnType2 */'],
118+
['/* testTypeUnionReturnTypeNamespaceRelative */'],
119+
['/* testTypeUnionReturnPartiallyQualified */'],
120+
['/* testTypeUnionReturnFullyQualified */'],
112121
['/* testTypeUnionClosureParamIllegalNullable */'],
113122
['/* testTypeUnionWithReference */'],
114123
['/* testTypeUnionWithSpreadOperator */'],

0 commit comments

Comments
 (0)