Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions tests/Core/Tokenizers/PHP/NullableVsInlineThenTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,58 @@ abstract class Nullable
abstract ?string $prop5 { get; }
}

$closure = function (
/* testClosureParamTypeNullableInt */
?Int $a,
/* testClosureParamTypeNullableCallable */
? Callable $b
/* testClosureReturnTypeNullableInt */
) :?INT{};

/* testFunctionReturnTypeNullableCallable */
function testCallableReturn() : ? callable {}

class InlineThen
{
/* testInlineThenInPropertyDefaultValue */
public int $prop = self::SOMECONT ? PHP_CONST ? OTHER_CONST;
}

/* testInlineThenWithArrayDeclaration */
$ternary = true ? array() : null;

/* testInlineThenWithUnqualifiedNameAndNothingElse */
$ternary = true ? CONSTANT_NAME : null;

/* testInlineThenWithUnqualifiedNameAndParens */
$ternary = true ? callMe() : null;

/* testInlineThenWithUnqualifiedNameAndDoubleColon */
$ternary = true ? ClassName::callMe() : null;

/* testInlineThenWithFullyQualifiedNameAndNothingElse */
$ternary = true ? \CONSTANT_NAME : null;

/* testInlineThenWithFullyQualifiedNameAndParens */
$ternary = true ? \Fully\callMe() : null;

/* testInlineThenWithFullyQualifiedNameAndDoubleColon */
$ternary = true ? \Fully\ClassName::callMe() : null;

/* testInlineThenWithPartiallyQualifiedNameAndNothingElse */
$ternary = true ? Partially\CONSTANT_NAME : null;

/* testInlineThenWithPartiallyQualifiedNameAndParens */
$ternary = true ? Partially\callMe() : null;

/* testInlineThenWithPartiallyQualifiedNameAndDoubleColon */
$ternary = true ? Partially\ClassName::callMe() : null;

/* testInlineThenWithNamespaceRelativeNameAndNothingElse */
$ternary = true ? Partially\CONSTANT_NAME : null;

/* testInlineThenWithNamespaceRelativeNameAndParens */
$ternary = true ? Partially\callMe() : null;

/* testInlineThenWithNamespaceRelativeNameAndDoubleColon */
$ternary = true ? Partially\ClassName::callMe() : null;
25 changes: 24 additions & 1 deletion tests/Core/Tokenizers/PHP/NullableVsInlineThenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public static function dataNullable()
'property declaration, public and protected set' => ['/* testNullablePublicProtectedSet */'],
'property declaration, final, no visibility' => ['/* testNullableFinalOnly */'],
'property declaration, abstract, no visibility' => ['/* testNullableAbstractOnly */'],

'closure param type, nullable int' => ['/* testClosureParamTypeNullableInt */'],
'closure param type, nullable callable' => ['/* testClosureParamTypeNullableCallable */'],
'closure return type, nullable int' => ['/* testClosureReturnTypeNullableInt */'],
'function return type, nullable callable' => ['/* testFunctionReturnTypeNullableCallable */'],
];

}//end dataNullable()
Expand Down Expand Up @@ -91,7 +96,25 @@ public function testInlineThen($testMarker)
public static function dataInlineThen()
{
return [
'ternary in property default value' => ['/* testInlineThenInPropertyDefaultValue */'],
'ternary in property default value' => ['/* testInlineThenInPropertyDefaultValue */'],

'ternary ? followed by array declaration' => ['/* testInlineThenWithArrayDeclaration */'],

'ternary ? followed by unqualified constant' => ['/* testInlineThenWithUnqualifiedNameAndNothingElse */'],
'ternary ? followed by unqualified function call' => ['/* testInlineThenWithUnqualifiedNameAndParens */'],
'ternary ? followed by unqualified static method call' => ['/* testInlineThenWithUnqualifiedNameAndDoubleColon */'],

'ternary ? followed by fully qualified constant' => ['/* testInlineThenWithFullyQualifiedNameAndNothingElse */'],
'ternary ? followed by fully qualified function call' => ['/* testInlineThenWithFullyQualifiedNameAndParens */'],
'ternary ? followed by fully qualified static method call' => ['/* testInlineThenWithFullyQualifiedNameAndDoubleColon */'],

'ternary ? followed by partially qualified constant' => ['/* testInlineThenWithPartiallyQualifiedNameAndNothingElse */'],
'ternary ? followed by partially qualified function call' => ['/* testInlineThenWithPartiallyQualifiedNameAndParens */'],
'ternary ? followed by partially qualified static method call' => ['/* testInlineThenWithPartiallyQualifiedNameAndDoubleColon */'],

'ternary ? followed by namespace relative constant' => ['/* testInlineThenWithNamespaceRelativeNameAndNothingElse */'],
'ternary ? followed by namespace relative function call' => ['/* testInlineThenWithNamespaceRelativeNameAndParens */'],
'ternary ? followed by namespace relative static method call' => ['/* testInlineThenWithNamespaceRelativeNameAndDoubleColon */'],
];

}//end dataInlineThen()
Expand Down
Loading