Skip to content

Commit 644978d

Browse files
committed
Merge branch 'master' into 4.x
2 parents d04c9bc + 379692d commit 644978d

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

tests/Core/Tokenizers/PHP/NullableVsInlineThenTest.inc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,58 @@ abstract class Nullable
1818
abstract ?string $prop5 { get; }
1919
}
2020

21+
$closure = function (
22+
/* testClosureParamTypeNullableInt */
23+
?Int $a,
24+
/* testClosureParamTypeNullableCallable */
25+
? Callable $b
26+
/* testClosureReturnTypeNullableInt */
27+
) :?INT{};
28+
29+
/* testFunctionReturnTypeNullableCallable */
30+
function testCallableReturn() : ? callable {}
31+
2132
class InlineThen
2233
{
2334
/* testInlineThenInPropertyDefaultValue */
2435
public int $prop = self::SOMECONT ? PHP_CONST ? OTHER_CONST;
2536
}
37+
38+
/* testInlineThenWithArrayDeclaration */
39+
$ternary = true ? array() : null;
40+
41+
/* testInlineThenWithUnqualifiedNameAndNothingElse */
42+
$ternary = true ? CONSTANT_NAME : null;
43+
44+
/* testInlineThenWithUnqualifiedNameAndParens */
45+
$ternary = true ? callMe() : null;
46+
47+
/* testInlineThenWithUnqualifiedNameAndDoubleColon */
48+
$ternary = true ? ClassName::callMe() : null;
49+
50+
/* testInlineThenWithFullyQualifiedNameAndNothingElse */
51+
$ternary = true ? \CONSTANT_NAME : null;
52+
53+
/* testInlineThenWithFullyQualifiedNameAndParens */
54+
$ternary = true ? \Fully\callMe() : null;
55+
56+
/* testInlineThenWithFullyQualifiedNameAndDoubleColon */
57+
$ternary = true ? \Fully\ClassName::callMe() : null;
58+
59+
/* testInlineThenWithPartiallyQualifiedNameAndNothingElse */
60+
$ternary = true ? Partially\CONSTANT_NAME : null;
61+
62+
/* testInlineThenWithPartiallyQualifiedNameAndParens */
63+
$ternary = true ? Partially\callMe() : null;
64+
65+
/* testInlineThenWithPartiallyQualifiedNameAndDoubleColon */
66+
$ternary = true ? Partially\ClassName::callMe() : null;
67+
68+
/* testInlineThenWithNamespaceRelativeNameAndNothingElse */
69+
$ternary = true ? namespace\CONSTANT_NAME : null;
70+
71+
/* testInlineThenWithNamespaceRelativeNameAndParens */
72+
$ternary = true ? namespace\callMe() : null;
73+
74+
/* testInlineThenWithNamespaceRelativeNameAndDoubleColon */
75+
$ternary = true ? namespace\ClassName::callMe() : null;

tests/Core/Tokenizers/PHP/NullableVsInlineThenTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public static function dataNullable()
5555
'property declaration, public and protected set' => ['/* testNullablePublicProtectedSet */'],
5656
'property declaration, final, no visibility' => ['/* testNullableFinalOnly */'],
5757
'property declaration, abstract, no visibility' => ['/* testNullableAbstractOnly */'],
58+
59+
'closure param type, nullable int' => ['/* testClosureParamTypeNullableInt */'],
60+
'closure param type, nullable callable' => ['/* testClosureParamTypeNullableCallable */'],
61+
'closure return type, nullable int' => ['/* testClosureReturnTypeNullableInt */'],
62+
'function return type, nullable callable' => ['/* testFunctionReturnTypeNullableCallable */'],
5863
];
5964

6065
}//end dataNullable()
@@ -91,7 +96,25 @@ public function testInlineThen($testMarker)
9196
public static function dataInlineThen()
9297
{
9398
return [
94-
'ternary in property default value' => ['/* testInlineThenInPropertyDefaultValue */'],
99+
'ternary in property default value' => ['/* testInlineThenInPropertyDefaultValue */'],
100+
101+
'ternary ? followed by array declaration' => ['/* testInlineThenWithArrayDeclaration */'],
102+
103+
'ternary ? followed by unqualified constant' => ['/* testInlineThenWithUnqualifiedNameAndNothingElse */'],
104+
'ternary ? followed by unqualified function call' => ['/* testInlineThenWithUnqualifiedNameAndParens */'],
105+
'ternary ? followed by unqualified static method call' => ['/* testInlineThenWithUnqualifiedNameAndDoubleColon */'],
106+
107+
'ternary ? followed by fully qualified constant' => ['/* testInlineThenWithFullyQualifiedNameAndNothingElse */'],
108+
'ternary ? followed by fully qualified function call' => ['/* testInlineThenWithFullyQualifiedNameAndParens */'],
109+
'ternary ? followed by fully qualified static method call' => ['/* testInlineThenWithFullyQualifiedNameAndDoubleColon */'],
110+
111+
'ternary ? followed by partially qualified constant' => ['/* testInlineThenWithPartiallyQualifiedNameAndNothingElse */'],
112+
'ternary ? followed by partially qualified function call' => ['/* testInlineThenWithPartiallyQualifiedNameAndParens */'],
113+
'ternary ? followed by partially qualified static method call' => ['/* testInlineThenWithPartiallyQualifiedNameAndDoubleColon */'],
114+
115+
'ternary ? followed by namespace relative constant' => ['/* testInlineThenWithNamespaceRelativeNameAndNothingElse */'],
116+
'ternary ? followed by namespace relative function call' => ['/* testInlineThenWithNamespaceRelativeNameAndParens */'],
117+
'ternary ? followed by namespace relative static method call' => ['/* testInlineThenWithNamespaceRelativeNameAndDoubleColon */'],
95118
];
96119

97120
}//end dataInlineThen()

0 commit comments

Comments
 (0)