Skip to content

Commit

Permalink
PHP8.1 Support (DOM&Compiler parser) - #149
Browse files Browse the repository at this point in the history
* fix readonly as function name
  • Loading branch information
zulus committed May 3, 2023
1 parent 2d22db6 commit 013bef5
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3335,6 +3335,12 @@ name:list T_OPEN_PARENTHESE function_call_parameter_list:parameters T_CLOSE_PARE
new FunctionName(listleft, listright, parser.ast, list), parameters);
:}

| T_READONLY:list T_OPEN_PARENTHESE function_call_parameter_list:parameters T_CLOSE_PARENTHESE:e
{:
RESULT = new FunctionInvocation(listleft, eright, parser.ast,
new FunctionName(listleft, listright, parser.ast, new NamespaceName(listleft, listright, ast, list, false, false)), parameters);
:}

| class_name:className T_PAAMAYIM_NEKUDOTAYIM member_name:reflectionName T_OPEN_PARENTHESE function_call_parameter_list:parameters T_CLOSE_PARENTHESE:e
{:
RESULT = new StaticMethodInvocation(classNameleft, eright, parser.ast, className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3834,6 +3834,14 @@ name:functionName T_OPEN_PARENTHESE:start function_call_parameter_list:parameter
RESULT = new PHPCallExpression(functionNameleft, endright, null, functionName, parameters);
:}

| T_READONLY:i T_OPEN_PARENTHESE:start function_call_parameter_list:parameters T_CLOSE_PARENTHESE:end
{:
parameters.setStart(startright);
parameters.setEnd(endleft);
FullyQualifiedReference functionName = new FullyQualifiedReference(ileft, iright, i.value, null, FullyQualifiedReference.T_FUNCTION);
RESULT = new PHPCallExpression(ileft, endright, null, functionName, parameters);
:}

| class_name:className T_PAAMAYIM_NEKUDOTAYIM member_name:functionName T_OPEN_PARENTHESE:start function_call_parameter_list:parameters T_CLOSE_PARENTHESE:end
{:
parameters.setStart(startright);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3389,6 +3389,12 @@ name:list T_OPEN_PARENTHESE function_call_parameter_list:parameters T_CLOSE_PARE
new FunctionName(listleft, listright, parser.ast, list), parameters);
:}

| T_READONLY:list T_OPEN_PARENTHESE function_call_parameter_list:parameters T_CLOSE_PARENTHESE:e
{:
RESULT = new FunctionInvocation(listleft, eright, parser.ast,
new FunctionName(listleft, listright, parser.ast, new NamespaceName(listleft, listright, ast, list, false, false)), parameters);
:}

| class_name:className T_PAAMAYIM_NEKUDOTAYIM member_name:reflectionName T_OPEN_PARENTHESE function_call_parameter_list:parameters T_CLOSE_PARENTHESE:e
{:
RESULT = new StaticMethodInvocation(classNameleft, eright, parser.ast, className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3895,6 +3895,14 @@ name:functionName T_OPEN_PARENTHESE:start function_call_parameter_list:parameter
RESULT = new PHPCallExpression(functionNameleft, endright, null, functionName, parameters);
:}

| T_READONLY:i T_OPEN_PARENTHESE:start function_call_parameter_list:parameters T_CLOSE_PARENTHESE:end
{:
parameters.setStart(startright);
parameters.setEnd(endleft);
FullyQualifiedReference functionName = new FullyQualifiedReference(ileft, iright, i.value, null, FullyQualifiedReference.T_FUNCTION);
RESULT = new PHPCallExpression(ileft, endright, null, functionName, parameters);
:}

| class_name:className T_PAAMAYIM_NEKUDOTAYIM member_name:functionName T_OPEN_PARENTHESE:start function_call_parameter_list:parameters T_CLOSE_PARENTHESE:end
{:
parameters.setStart(startright);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
PHP 8.1
--FILE--
<?php
function readonly() {}

readonly();

?>
--EXPECT--
<ModuleDeclaration start="0" end="46">
<PHPMethodDeclaration start="6" end="28" modifiers="" name="readonly">
</PHPMethodDeclaration>
<ExpressionStatement start="30" end="41">
<PHPCallExpression start="30" end="40">
<FullyQualifiedReference start="30" end="38" name="readonly">
</FullyQualifiedReference>
<PHPCallArgumentsList start="39" end="39">
</PHPCallArgumentsList>
</PHPCallExpression>
</ExpressionStatement>
<EmptyStatement start="43" end="45">
</EmptyStatement>
</ModuleDeclaration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--TEST--
PHP 8.1
--FILE--
<?php
function readonly() {}

readonly();

?>
--EXPECT--
<Program start='0' length='45'>
<Statements>
<FunctionDeclaration start='6' length='22' isReference='false'>
<FunctionName>
<Identifier start='15' length='8' name='readonly'/>
</FunctionName>
<FormalParameters>
</FormalParameters>
<FunctionBody>
<Block start='26' length='2' isCurly='true'>
</Block>
</FunctionBody>
</FunctionDeclaration>
<ExpressionStatement start='30' length='11'>
<FunctionInvocation start='30' length='10'>
<FunctionName start='30' length='8'>
<NamespaceName start='30' length='8' global='false' current='false'>
<Identifier start='30' length='8' name='readonly'/>
</NamespaceName>
</FunctionName>
<Parameters>
</Parameters>
</FunctionInvocation>
</ExpressionStatement>
<EmptyStatement start='43' length='2'/>
</Statements>
<Comments>
</Comments>
</Program>

0 comments on commit 013bef5

Please sign in to comment.