Skip to content

Commit

Permalink
Merge 9df05aa into 2786537
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Sep 13, 2020
2 parents 2786537 + 9df05aa commit 3230751
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
23 changes: 13 additions & 10 deletions PHPCSUtils/Tokens/Collections.php
Expand Up @@ -767,22 +767,24 @@ public static function nullsafeObjectOperatorBC()
*
* @since 1.0.0-alpha4 This method replaces the {@see Collections::$parameterTypeTokens} property.
* @since 1.0.0-alpha4 Added support for PHP 8.0 union types.
* @since 1.0.0-alpha4 Added support for PHP 8.0 identifier name tokens.
*
* @return array <int|string> => <int|string>
*/
public static function parameterTypeTokens()
{
return [
\T_CALLABLE => \T_CALLABLE,
\T_SELF => \T_SELF,
\T_PARENT => \T_PARENT,
\T_FALSE => \T_FALSE, // Union types only.
\T_NULL => \T_NULL, // Union types only.
\T_STRING => \T_STRING,
\T_NAMESPACE => \T_NAMESPACE,
\T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_BITWISE_OR => \T_BITWISE_OR, // Union types.
$tokens = [
\T_CALLABLE => \T_CALLABLE,
\T_SELF => \T_SELF,
\T_PARENT => \T_PARENT,
\T_FALSE => \T_FALSE, // Union types only.
\T_NULL => \T_NULL, // Union types only.
\T_BITWISE_OR => \T_BITWISE_OR, // Union types.
];

$tokens += self::namespacedNameTokens();

return $tokens;
}

/**
Expand All @@ -803,6 +805,7 @@ public static function parameterTypeTokens()
*
* @since 1.0.0-alpha3
* @since 1.0.0-alpha4 Added support for PHP 8.0 union types.
* @since 1.0.0-alpha4 Added support for PHP 8.0 identifier name tokens.
*
* @return array <int|string> => <int|string>
*/
Expand Down
12 changes: 9 additions & 3 deletions Tests/Tokens/Collections/ParameterTypeTokensTest.php
Expand Up @@ -38,12 +38,18 @@ public function testParameterTypeTokens()
\T_PARENT => \T_PARENT,
\T_FALSE => \T_FALSE,
\T_NULL => \T_NULL,
\T_STRING => \T_STRING,
\T_NAMESPACE => \T_NAMESPACE,
\T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_BITWISE_OR => \T_BITWISE_OR,
\T_NS_SEPARATOR => \T_NS_SEPARATOR,
\T_NAMESPACE => \T_NAMESPACE,
\T_STRING => \T_STRING,
];

if (\version_compare(\PHP_VERSION_ID, '80000', '>=') === true) {
$expected[\T_NAME_QUALIFIED] = \T_NAME_QUALIFIED;
$expected[\T_NAME_FULLY_QUALIFIED] = \T_NAME_FULLY_QUALIFIED;
$expected[\T_NAME_RELATIVE] = \T_NAME_RELATIVE;
}

$this->assertSame($expected, Collections::parameterTypeTokens());
}
}

0 comments on commit 3230751

Please sign in to comment.