phpcsFile->getTokens();
$target = $this->getTargetToken($testMarker, [T_NULLABLE, T_INLINE_THEN]);
$tokenArray = $tokens[$target];
$this->assertSame(T_NULLABLE, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_NULLABLE (code)');
$this->assertSame('T_NULLABLE', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_NULLABLE (type)');
}//end testNullable()
/**
* Data provider.
*
* @see testNullable()
*
* @return array>
*/
public static function dataNullable()
{
return [
'property declaration, readonly, no visibility' => ['/* testNullableReadonlyOnly */'],
'property declaration, private set' => ['/* testNullablePrivateSet */'],
'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 param type, nullable string with comment, issue #1216' => ['/* testClosureParamTypeNullableStringWithAttributeAndSlashComment */'],
'closure return type, nullable int' => ['/* testClosureReturnTypeNullableInt */'],
'function return type, nullable callable' => ['/* testFunctionReturnTypeNullableCallable */'],
];
}//end dataNullable()
/**
* Test that a "?" when used as part of a ternary expression is tokenized as `T_INLINE_THEN`.
*
* @param string $testMarker The comment which prefaces the target token in the test file.
*
* @dataProvider dataInlineThen
*
* @return void
*/
public function testInlineThen($testMarker)
{
$tokens = $this->phpcsFile->getTokens();
$target = $this->getTargetToken($testMarker, [T_NULLABLE, T_INLINE_THEN]);
$tokenArray = $tokens[$target];
$this->assertSame(T_INLINE_THEN, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_INLINE_THEN (code)');
$this->assertSame('T_INLINE_THEN', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_INLINE_THEN (type)');
}//end testInlineThen()
/**
* Data provider.
*
* @see testInlineThen()
*
* @return array>
*/
public static function dataInlineThen()
{
return [
'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()
}//end class