diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index b914bccddc..5ef96a6566 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -1152,6 +1152,7 @@ protected function tokenize($string) if ($tokenType === T_FUNCTION || $tokenType === T_FN || isset(Util\Tokens::$methodPrefixes[$tokenType]) === true + || $tokenType === T_VAR ) { if (PHP_CODESNIFFER_VERBOSITY > 1) { echo "\t\t* token $stackPtr changed from ? to T_NULLABLE".PHP_EOL; diff --git a/tests/Core/File/GetMemberPropertiesTest.inc b/tests/Core/File/GetMemberPropertiesTest.inc index f882f80731..af52ff75df 100644 --- a/tests/Core/File/GetMemberPropertiesTest.inc +++ b/tests/Core/File/GetMemberPropertiesTest.inc @@ -6,7 +6,7 @@ class TestMemberProperties var $varA = true; /* testVarType */ - var int $varA = true; + var ?int $varA = true; /* testPublic */ public $varB = true; @@ -30,7 +30,7 @@ class TestMemberProperties static $varE = true; /* testStaticType */ - static string $varE = true; + static ?string $varE = true; /* testStaticVar */ static var $varF = true; diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index eb649a959e..a4bff22133 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -61,8 +61,8 @@ public function dataGetMemberProperties() 'scope' => 'public', 'scope_specified' => false, 'is_static' => false, - 'type' => 'int', - 'nullable_type' => false, + 'type' => '?int', + 'nullable_type' => true, ], ], [ @@ -141,8 +141,8 @@ public function dataGetMemberProperties() 'scope' => 'public', 'scope_specified' => false, 'is_static' => true, - 'type' => 'string', - 'nullable_type' => false, + 'type' => '?string', + 'nullable_type' => true, ], ], [