mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-12-13 17:47:23 +01:00
588e6a4d4c
Scalar\String_ and Scalar\Encapsed now have an additional "kind" attribute, which may be one of: * String_::KIND_SINGLE_QUOTED * String_::KIND_DOUBLE_QUOTED * String_::KIND_NOWDOC * String_::KIND_HEREDOC Additionally, if the string kind is one of the latter two, an attribute "docLabel" is provided, which contains the doc string label (STR in <<<STR) that was originally used. The pretty printer will try to take the original kind of the string, as well as the used doc string label into account.
154 lines
1.7 KiB
Plaintext
154 lines
1.7 KiB
Plaintext
Literals
|
|
-----
|
|
<?php
|
|
|
|
// magic constants
|
|
__LINE__;
|
|
__FILE__;
|
|
__DIR__;
|
|
__FUNCTION__;
|
|
__CLASS__;
|
|
__TRAIT__;
|
|
__METHOD__;
|
|
__NAMESPACE__;
|
|
|
|
// not actually literals, but close
|
|
null;
|
|
true;
|
|
false;
|
|
NULL;
|
|
TRUE;
|
|
FALSE;
|
|
|
|
// integers (normalized to decimal)
|
|
0;
|
|
11;
|
|
011;
|
|
0x11;
|
|
0b11;
|
|
|
|
// floats (normalized to ... something)
|
|
0.;
|
|
.0;
|
|
0.0;
|
|
0e1000;
|
|
1.0;
|
|
1e100;
|
|
1e1000;
|
|
1E-100;
|
|
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
|
|
378282246310005.0;
|
|
10000000000000002.0;
|
|
|
|
// strings (single quoted)
|
|
'a';
|
|
'a
|
|
b';
|
|
"a";
|
|
"a\nb";
|
|
'a\'b';
|
|
|
|
// strings (double quoted)
|
|
"a'b";
|
|
"a\b";
|
|
"$a";
|
|
"a$b";
|
|
"$a$b";
|
|
"$a $b";
|
|
"a${b}c";
|
|
"a{$b}c";
|
|
"a$a[b]c";
|
|
"\{$A}";
|
|
"\{ $A }";
|
|
"\\{$A}";
|
|
"\\{ $A }";
|
|
"{$$A}[B]";
|
|
"$$A[B]";
|
|
|
|
// make sure indentation doesn't mess anything up
|
|
function foo()
|
|
{
|
|
"a\nb";
|
|
'a
|
|
b';
|
|
'a
|
|
b';
|
|
}
|
|
|
|
// shell exec (similar to double quoted string)
|
|
`foo`;
|
|
`foo$a`;
|
|
`foo{$a}bar`;
|
|
`\`\'\"`;
|
|
-----
|
|
// magic constants
|
|
__LINE__;
|
|
__FILE__;
|
|
__DIR__;
|
|
__FUNCTION__;
|
|
__CLASS__;
|
|
__TRAIT__;
|
|
__METHOD__;
|
|
__NAMESPACE__;
|
|
// not actually literals, but close
|
|
null;
|
|
true;
|
|
false;
|
|
NULL;
|
|
TRUE;
|
|
FALSE;
|
|
// integers (normalized to decimal)
|
|
0;
|
|
11;
|
|
011;
|
|
0x11;
|
|
0b11;
|
|
// floats (normalized to ... something)
|
|
0.0;
|
|
0.0;
|
|
0.0;
|
|
0.0;
|
|
1.0;
|
|
1.0E+100;
|
|
INF;
|
|
1.0E-100;
|
|
1.0E+84;
|
|
378282246310005.0;
|
|
10000000000000002.0;
|
|
// strings (single quoted)
|
|
'a';
|
|
'a
|
|
b';
|
|
"a";
|
|
"a\nb";
|
|
'a\'b';
|
|
// strings (double quoted)
|
|
"a'b";
|
|
"a\\b";
|
|
"{$a}";
|
|
"a{$b}";
|
|
"{$a}{$b}";
|
|
"{$a} {$b}";
|
|
"a{$b}c";
|
|
"a{$b}c";
|
|
"a{$a['b']}c";
|
|
"\\{{$A}}";
|
|
"\\{ {$A} }";
|
|
"\\{$A}";
|
|
"\\{ {$A} }";
|
|
"{${$A}}[B]";
|
|
"\${$A['B']}";
|
|
// make sure indentation doesn't mess anything up
|
|
function foo()
|
|
{
|
|
"a\nb";
|
|
'a
|
|
b';
|
|
'a
|
|
b';
|
|
}
|
|
// shell exec (similar to double quoted string)
|
|
`foo`;
|
|
`foo{$a}`;
|
|
`foo{$a}bar`;
|
|
`\`\\'\\"`; |