Skip to content

Commit

Permalink
Merge pull request #8085 from junichi11/php83-arbitrary_static_variab…
Browse files Browse the repository at this point in the history
…le_initializers

PHP 8.3 Support: Arbitrary static variable initializers
  • Loading branch information
junichi11 authored Dec 23, 2024
2 parents 4f09e4c + 551c611 commit be051eb
Show file tree
Hide file tree
Showing 67 changed files with 3,062 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,18 @@ public void visit(StaticStatement node) {
List<Expression> expressions = node.getExpressions();
for (Expression expression : expressions) {
addAllUntilOffset(expression.getStartOffset());
// e.g. static $variable = new class() {}
boolean addIndent = !(expression instanceof Assignment
&& isAnonymousClass(((Assignment) expression).getRightHandSide()));
if (moveNext() && lastIndex < ts.index()) {
addFormatToken(formatTokens); // add the first token of the expression and then add the indentation
formatTokens.add(new FormatToken.IndentToken(ts.offset() + ts.token().length(), options.continualIndentSize));
if (addIndent) {
formatTokens.add(new FormatToken.IndentToken(ts.offset() + ts.token().length(), options.continualIndentSize));
}
scan(expression);
formatTokens.add(new FormatToken.IndentToken(expression.getEndOffset(), -1 * options.continualIndentSize));
if (addIndent) {
formatTokens.add(new FormatToken.IndentToken(expression.getEndOffset(), -1 * options.continualIndentSize));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
// Tue May 14 21:41:03 NOVT 2024
// Thu Dec 19 14:22:13 JST 2024
//----------------------------------------------------

package org.netbeans.modules.php.editor.parser;
Expand All @@ -30,7 +30,7 @@
import org.openide.util.Pair;

/** CUP v0.11a beta 20060608 generated parser.
* @version Tue May 14 21:41:03 NOVT 2024
* @version Thu Dec 19 14:22:13 JST 2024
*/
@org.netbeans.api.annotations.common.SuppressWarnings({"EI_EXPOSE_REP", "MS_PKGPROTECT", "BC_BAD_CAST_TO_CONCRETE_COLLECTION"})
public class ASTPHP5Parser extends java_cup.runtime.lr_parser {
Expand Down Expand Up @@ -2343,67 +2343,75 @@ public class ASTPHP5Parser extends java_cup.runtime.lr_parser {
"\324\u038f\327\u038e\001\001\000\002\001\001\000\002\001" +
"\001\000\002\001\001\000\002\001\001\000\002\001\001" +
"\000\002\001\001\000\002\001\001\000\002\001\001\000" +
"\002\001\001\000\002\001\001\000\002\001\001\000\032" +
"\004\346\074\336\075\u0625\077\335\101\352\167\354\177" +
"\333\200\337\307\344\311\334\312\341\315\356\001\001" +
"\000\002\001\001\000\034\004\346\074\336\076\u0627\077" +
"\u024a\100\u024b\101\352\167\354\177\333\200\337\307\344" +
"\311\334\312\341\315\356\001\001\000\002\001\001\000" +
"\004\150\u0629\001\001\000\002\001\001\000\024\043\u062b" +
"\046\u0221\047\u0223\210\u0225\272\u0224\274\u021f\323\135\324" +
"\u0220\333\u0222\001\001\000\002\001\001\000\004\255\u062d" +
"\001\001\000\002\001\001\000\004\017\u062f\001\001\000" +
"\156\004\125\016\u038c\020\u038a\021\144\066\151\067\133" +
"\070\013\071\064\074\042\102\132\106\110\110\166\113" +
"\130\114\101\115\124\116\213\123\136\124\211\125\117" +
"\126\226\137\222\147\023\151\057\167\054\170\041\171" +
"\146\172\131\173\100\174\060\175\066\177\172\200\051" +
"\216\016\217\070\220\046\231\203\232\076\233\040\234" +
"\010\235\175\256\105\260\163\261\021\263\157\266\043" +
"\277\221\300\216\302\031\303\075\304\074\316\165\323" +
"\135\324\u038f\327\u038e\001\001\000\002\001\001\000\136" +
"\004\125\050\u0632\051\u020f\052\u01fb\053\u0203\066\u0211\067" +
"\133\070\013\071\064\074\042\102\132\106\u01ad\115\124" +
"\116\213\123\136\124\211\125\117\126\226\137\222\147" +
"\023\150\u0201\167\054\170\041\171\146\172\131\173\100" +
"\174\060\175\066\177\172\200\051\202\u019c\203\u01fc\220" +
"\u01ff\256\105\260\163\261\021\263\157\266\043\277\221" +
"\300\216\302\031\303\075\304\074\316\165\323\135\324" +
"\u01ab\001\001\000\002\001\001\000\002\001\001\000\002" +
"\001\001\000\002\001\001\000\004\104\u0638\001\001\000" +
"\010\177\u0635\200\337\325\u063a\001\001\000\002\001\001" +
"\000\002\001\001\000\002\001\001\000\136\004\125\050" +
"\u063c\051\u020f\052\u01fb\053\u0203\066\u0211\067\133\070\013" +
"\071\064\074\042\102\132\106\u01ad\115\124\116\213\123" +
"\136\124\211\125\117\126\226\137\222\147\023\150\u0201" +
"\167\054\170\041\171\146\172\131\173\100\174\060\175" +
"\066\177\172\200\051\202\u019c\203\u01fc\220\u01ff\256\105" +
"\260\163\261\021\263\157\266\043\277\221\300\216\302" +
"\031\303\075\304\074\316\165\323\135\324\u01ab\001\001" +
"\000\002\001\001\000\002\001\001\000\002\001\001\000" +
"\002\001\001\000\056\070\013\071\064\123\u026a\124\211" +
"\125\117\126\226\137\222\170\041\173\u0266\174\060\177" +
"\172\200\051\220\u0643\256\u0642\261\021\263\157\266\043" +
"\300\u0267\302\031\303\075\304\074\316\165\001\001\000" +
"\002\001\001\000\002\001\001\000\002\001\001\000\120" +
"\004\125\066\151\067\133\070\013\071\064\074\042\102" +
"\132\106\u0645\115\124\116\213\123\136\124\211\125\117" +
"\132\106\u0625\115\124\116\213\123\136\124\211\125\117" +
"\126\226\137\222\147\023\167\054\170\041\171\146\172" +
"\131\173\100\174\060\175\066\177\172\200\051\220\046" +
"\256\105\260\163\261\021\263\157\266\043\277\221\300" +
"\216\302\031\303\075\304\074\316\165\323\135\324\u01ab" +
"\001\001\000\002\001\001\000\002\001\001\000\004\055" +
"\u0649\001\001\000\002\001\001\000\002\001\001\000\006" +
"\145\u0543\266\u0542\001\001\000\002\001\001\000\136\004" +
"\125\050\u064d\051\u020f\052\u01fb\053\u0203\066\u0211\067\133" +
"\001\001\000\002\001\001\000\120\004\125\066\151\067" +
"\133\070\013\071\064\074\042\102\132\106\u0627\115\124" +
"\116\213\123\136\124\211\125\117\126\226\137\222\147" +
"\023\167\054\170\041\171\146\172\131\173\100\174\060" +
"\175\066\177\172\200\051\220\046\256\105\260\163\261" +
"\021\263\157\266\043\277\221\300\216\302\031\303\075" +
"\304\074\316\165\323\135\324\u01ab\001\001\000\002\001" +
"\001\000\004\150\u0629\001\001\000\002\001\001\000\024" +
"\043\u062b\046\u0221\047\u0223\210\u0225\272\u0224\274\u021f\323" +
"\135\324\u0220\333\u0222\001\001\000\002\001\001\000\004" +
"\255\u062d\001\001\000\002\001\001\000\004\017\u062f\001" +
"\001\000\156\004\125\016\u038c\020\u038a\021\144\066\151" +
"\067\133\070\013\071\064\074\042\102\132\106\110\110" +
"\166\113\130\114\101\115\124\116\213\123\136\124\211" +
"\125\117\126\226\137\222\147\023\151\057\167\054\170" +
"\041\171\146\172\131\173\100\174\060\175\066\177\172" +
"\200\051\216\016\217\070\220\046\231\203\232\076\233" +
"\040\234\010\235\175\256\105\260\163\261\021\263\157" +
"\266\043\277\221\300\216\302\031\303\075\304\074\316" +
"\165\323\135\324\u038f\327\u038e\001\001\000\002\001\001" +
"\000\136\004\125\050\u0632\051\u020f\052\u01fb\053\u0203\066" +
"\u0211\067\133\070\013\071\064\074\042\102\132\106\u01ad" +
"\115\124\116\213\123\136\124\211\125\117\126\226\137" +
"\222\147\023\150\u0201\167\054\170\041\171\146\172\131" +
"\173\100\174\060\175\066\177\172\200\051\202\u019c\203" +
"\u01fc\220\u01ff\256\105\260\163\261\021\263\157\266\043" +
"\277\221\300\216\302\031\303\075\304\074\316\165\323" +
"\135\324\u01ab\001\001\000\002\001\001\000\002\001\001" +
"\000\002\001\001\000\002\001\001\000\004\104\u0638\001" +
"\001\000\010\177\u0635\200\337\325\u063a\001\001\000\002" +
"\001\001\000\002\001\001\000\002\001\001\000\136\004" +
"\125\050\u063c\051\u020f\052\u01fb\053\u0203\066\u0211\067\133" +
"\070\013\071\064\074\042\102\132\106\u01ad\115\124\116" +
"\213\123\136\124\211\125\117\126\226\137\222\147\023" +
"\150\u0201\167\054\170\041\171\146\172\131\173\100\174" +
"\060\175\066\177\172\200\051\202\u019c\203\u01fc\220\u01ff" +
"\256\105\260\163\261\021\263\157\266\043\277\221\300" +
"\216\302\031\303\075\304\074\316\165\323\135\324\u01ab" +
"\001\001\000\002\001\001\000\002\001\001\000\002\001" +
"\001\000\002\001\001\000\002\001\001" });
"\001\000\002\001\001\000\056\070\013\071\064\123\u026a" +
"\124\211\125\117\126\226\137\222\170\041\173\u0266\174" +
"\060\177\172\200\051\220\u0643\256\u0642\261\021\263\157" +
"\266\043\300\u0267\302\031\303\075\304\074\316\165\001" +
"\001\000\002\001\001\000\002\001\001\000\002\001\001" +
"\000\120\004\125\066\151\067\133\070\013\071\064\074" +
"\042\102\132\106\u0645\115\124\116\213\123\136\124\211" +
"\125\117\126\226\137\222\147\023\167\054\170\041\171" +
"\146\172\131\173\100\174\060\175\066\177\172\200\051" +
"\220\046\256\105\260\163\261\021\263\157\266\043\277" +
"\221\300\216\302\031\303\075\304\074\316\165\323\135" +
"\324\u01ab\001\001\000\002\001\001\000\002\001\001\000" +
"\004\055\u0649\001\001\000\002\001\001\000\002\001\001" +
"\000\006\145\u0543\266\u0542\001\001\000\002\001\001\000" +
"\136\004\125\050\u064d\051\u020f\052\u01fb\053\u0203\066\u0211" +
"\067\133\070\013\071\064\074\042\102\132\106\u01ad\115" +
"\124\116\213\123\136\124\211\125\117\126\226\137\222" +
"\147\023\150\u0201\167\054\170\041\171\146\172\131\173" +
"\100\174\060\175\066\177\172\200\051\202\u019c\203\u01fc" +
"\220\u01ff\256\105\260\163\261\021\263\157\266\043\277" +
"\221\300\216\302\031\303\075\304\074\316\165\323\135" +
"\324\u01ab\001\001\000\002\001\001\000\002\001\001\000" +
"\002\001\001\000\002\001\001\000\002\001\001" });

/** Access to <code>reduce_goto</code> table. */
public short[][] reduce_table() {return _reduce_table;}
Expand Down Expand Up @@ -8361,7 +8369,7 @@ public final java_cup.runtime.Symbol fakeMethod300to399(
return CUP$ASTPHP5Parser$result;

/*. . . . . . . . . . . . . . . . . . . .*/
case 325: // static_var_list ::= static_var_list T_COMMA T_VARIABLE T_EQUAL static_scalar
case 325: // static_var_list ::= static_var_list T_COMMA T_VARIABLE T_EQUAL expr
{
List RESULT =null;
int listleft = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.elementAt(CUP$ASTPHP5Parser$top-4)).left;
Expand Down Expand Up @@ -8401,7 +8409,7 @@ public final java_cup.runtime.Symbol fakeMethod300to399(
return CUP$ASTPHP5Parser$result;

/*. . . . . . . . . . . . . . . . . . . .*/
case 327: // static_var_list ::= T_VARIABLE T_EQUAL static_scalar_with_class_instance
case 327: // static_var_list ::= T_VARIABLE T_EQUAL expr
{
List RESULT =null;
int varleft = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.elementAt(CUP$ASTPHP5Parser$top-2)).left;
Expand Down
Loading

0 comments on commit be051eb

Please sign in to comment.