Skip to content

Commit

Permalink
Merge branch 'feature/tokenizer-php-bugfix-namespaced-type-decl-vs-un…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Apr 23, 2021
2 parents 41a9bef + 52f2e80 commit 4eeb4dd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Tokenizers/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -2584,6 +2584,7 @@ protected function processAdditional()
T_STATIC => T_STATIC,
T_FALSE => T_FALSE,
T_NULL => T_NULL,
T_NAMESPACE => T_NAMESPACE,
T_NS_SEPARATOR => T_NS_SEPARATOR,
];

Expand Down
27 changes: 27 additions & 0 deletions tests/Core/Tokenizer/BitwiseOrTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ class TypeUnion
/* testTypeUnionPropertyMulti3 */
| null $arrayOrFalse;

/* testTypeUnionPropertyNamespaceRelative */
public namespace\Sub\NameA|namespace\Sub\NameB $namespaceRelative;

/* testTypeUnionPropertyPartiallyQualified */
public Partially\Qualified\NameA|Partially\Qualified\NameB $partiallyQual;

/* testTypeUnionPropertyFullyQualified */
public \Fully\Qualified\NameA|\Fully\Qualified\NameB $fullyQual;

public function paramTypes(
/* testTypeUnionParam1 */
int|float $paramA /* testBitwiseOrParamDefaultValue */ = CONSTANT_A | CONSTANT_B,
Expand All @@ -35,6 +44,15 @@ class TypeUnion
return (($a1 ^ $b1) |($a2 ^ $b2)) + $c;
}

public function identifierNames(
/* testTypeUnionParamNamespaceRelative */
namespace\Sub\NameA|namespace\Sub\NameB $paramA,
/* testTypeUnionParamPartiallyQualified */
Partially\Qualified\NameA|Partially\Qualified\NameB $paramB,
/* testTypeUnionParamFullyQualified */
\Fully\Qualified\NameA|\Fully\Qualified\NameB $paramC,
) {}

/* testTypeUnionReturnType */
public function returnType() : int|false {}

Expand All @@ -43,6 +61,15 @@ class TypeUnion

/* testTypeUnionAbstractMethodReturnType1 */
abstract public function abstractMethod(): object|array /* testTypeUnionAbstractMethodReturnType2 */ |false;

/* testTypeUnionReturnTypeNamespaceRelative */
public function identifierNamesReturnRelative() : namespace\Sub\NameA|namespace\Sub\NameB {}

/* testTypeUnionReturnPartiallyQualified */
public function identifierNamesReturnPQ() : Partially\Qualified\NameA|Partially\Qualified\NameB {}

/* testTypeUnionReturnFullyQualified */
public function identifierNamesReturnFQ() : \Fully\Qualified\NameA|\Fully\Qualified\NameB {}
}

/* testTypeUnionClosureParamIllegalNullable */
Expand Down
9 changes: 9 additions & 0 deletions tests/Core/Tokenizer/BitwiseOrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,22 @@ public function dataTypeUnion()
['/* testTypeUnionPropertyMulti1 */'],
['/* testTypeUnionPropertyMulti2 */'],
['/* testTypeUnionPropertyMulti3 */'],
['/* testTypeUnionPropertyNamespaceRelative */'],
['/* testTypeUnionPropertyPartiallyQualified */'],
['/* testTypeUnionPropertyFullyQualified */'],
['/* testTypeUnionParam1 */'],
['/* testTypeUnionParam2 */'],
['/* testTypeUnionParam3 */'],
['/* testTypeUnionParamNamespaceRelative */'],
['/* testTypeUnionParamPartiallyQualified */'],
['/* testTypeUnionParamFullyQualified */'],
['/* testTypeUnionReturnType */'],
['/* testTypeUnionConstructorPropertyPromotion */'],
['/* testTypeUnionAbstractMethodReturnType1 */'],
['/* testTypeUnionAbstractMethodReturnType2 */'],
['/* testTypeUnionReturnTypeNamespaceRelative */'],
['/* testTypeUnionReturnPartiallyQualified */'],
['/* testTypeUnionReturnFullyQualified */'],
['/* testTypeUnionClosureParamIllegalNullable */'],
['/* testTypeUnionWithReference */'],
['/* testTypeUnionWithSpreadOperator */'],
Expand Down

0 comments on commit 4eeb4dd

Please sign in to comment.