Skip to content

Commit 812a547

Browse files
committed
Tokenizer/PHP: document handling of \true/\false/\null
The handling as documented here is 100% in line with the way PHP 8.0+ handles this natively.
1 parent 865a228 commit 812a547

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

tests/Core/Tokenizers/PHP/NamespacedNameSingleTokenTest.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ class MyClass
133133

134134
/* testInstanceOfPartiallyQualified */
135135
$is = $obj instanceof Partially\ClassName;
136+
137+
/* testFullyQualifiedNull */
138+
$a = \NULL;
139+
140+
/* testFullyQualifiedFalse */
141+
$a = \false;
142+
143+
/* testFullyQualifiedTrue */
144+
$a = \True;
136145
}
137146
}
138147

tests/Core/Tokenizers/PHP/NamespacedNameSingleTokenTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,45 @@ public static function dataIdentifierTokenization()
868868
],
869869
],
870870
],
871+
'fully qualified "null"' => [
872+
'testMarker' => '/* testFullyQualifiedNull */',
873+
'expectedTokens' => [
874+
[
875+
'type' => 'T_NAME_FULLY_QUALIFIED',
876+
'content' => '\NULL',
877+
],
878+
[
879+
'type' => 'T_SEMICOLON',
880+
'content' => ';',
881+
],
882+
],
883+
],
884+
'fully qualified "false"' => [
885+
'testMarker' => '/* testFullyQualifiedFalse */',
886+
'expectedTokens' => [
887+
[
888+
'type' => 'T_NAME_FULLY_QUALIFIED',
889+
'content' => '\false',
890+
],
891+
[
892+
'type' => 'T_SEMICOLON',
893+
'content' => ';',
894+
],
895+
],
896+
],
897+
'fully qualified "true"' => [
898+
'testMarker' => '/* testFullyQualifiedTrue */',
899+
'expectedTokens' => [
900+
[
901+
'type' => 'T_NAME_FULLY_QUALIFIED',
902+
'content' => '\True',
903+
],
904+
[
905+
'type' => 'T_SEMICOLON',
906+
'content' => ';',
907+
],
908+
],
909+
],
871910
'function call, namespace relative, with whitespace (invalid in PHP 8)' => [
872911
'testMarker' => '/* testInvalidInPHP8Whitespace */',
873912
'expectedTokens' => [

0 commit comments

Comments
 (0)