Skip to content

Commit

Permalink
Merge pull request apache#7387 from troizet/php_remove_built_in_type_…
Browse files Browse the repository at this point in the history
…real

PHP: removed built-in type real
  • Loading branch information
junichi11 authored Jul 4, 2024
2 parents 3f27736 + a8c9cd8 commit a450d0f
Show file tree
Hide file tree
Showing 38 changed files with 258 additions and 48 deletions.
2 changes: 1 addition & 1 deletion php/php.editor/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial
nbjavac.ignore.missing.enclosing=**/CUP$ASTPHP5Parser$actions.class
nbm.needs.restart=true
spec.version.base=2.39.0
spec.version.base=2.40.0
release.external/predefined_vars-1.0.zip=docs/predefined_vars.zip
sigtest.gen.fail.on.error=false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private Type() {
public static boolean isPrimitive(String typeName) {
boolean retval = false;
if (BOOL.equals(typeName) || INT.equals(typeName)
|| INTEGER.equals(typeName) || FLOAT.equals(typeName) || REAL.equals(typeName)
|| INTEGER.equals(typeName) || FLOAT.equals(typeName)
|| ARRAY.equals(typeName) || OBJECT.equals(typeName) || MIXED.equals(typeName)
|| NUMBER.equals(typeName) || CALLBACK.equals(typeName) || RESOURCE.equals(typeName)
|| DOUBLE.equals(typeName) || STRING.equals(typeName) || NULL.equals(typeName)
Expand All @@ -125,7 +125,7 @@ public static boolean isPrimitive(String typeName) {

public static boolean isPrimitiveAlias(String typeName) {
boolean retval = false;
if (BOOLEAN.equals(typeName)) {
if (BOOLEAN.equals(typeName) || REAL.equals(typeName)) {
retval = true;
}
return retval;
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
// Sat Dec 09 20:59:16 JST 2023
// Tue May 14 21:41:03 NOVT 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 Sat Dec 09 20:59:16 JST 2023
* @version Tue May 14 21:41:03 NOVT 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 @@ -11184,7 +11184,7 @@ public final java_cup.runtime.Symbol fakeMethod400to499(
int exprright = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()).right;
Expression expr = (Expression)((java_cup.runtime.Symbol) CUP$ASTPHP5Parser$stack.peek()).value;

RESULT = new CastExpression(tokenleft, exprright, expr , CastExpression.Type.REAL);
RESULT = new CastExpression(tokenleft, exprright, expr , CastExpression.Type.FLOAT);

CUP$ASTPHP5Parser$result = parser.getSymbolFactory().newSymbol("expr_without_variable_and_class_instance",53, ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.elementAt(CUP$ASTPHP5Parser$top-1)), ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), RESULT);
}
Expand Down Expand Up @@ -12805,7 +12805,7 @@ public final java_cup.runtime.Symbol fakeMethod500to599(
int scalarright = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()).right;
String scalar = (String)((java_cup.runtime.Symbol) CUP$ASTPHP5Parser$stack.peek()).value;

Scalar s = new Scalar(scalarleft, scalarright, scalar, Scalar.Type.REAL);
Scalar s = new Scalar(scalarleft, scalarright, scalar, Scalar.Type.FLOAT);
RESULT = s;

CUP$ASTPHP5Parser$result = parser.getSymbolFactory().newSymbol("common_scalar",58, ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), RESULT);
Expand Down Expand Up @@ -16735,7 +16735,7 @@ public final java_cup.runtime.Symbol fakeMethod700to799(
int numright = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()).right;
String num = (String)((java_cup.runtime.Symbol) CUP$ASTPHP5Parser$stack.peek()).value;

Scalar scalar = new Scalar(numleft,numright, num, Scalar.Type.REAL);
Scalar scalar = new Scalar(numleft,numright, num, Scalar.Type.FLOAT);
RESULT = scalar;

CUP$ASTPHP5Parser$result = parser.getSymbolFactory().newSymbol("encaps_var_offset",100, ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), RESULT);
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
// Sat Dec 09 20:59:16 JST 2023
// Tue May 14 21:41:03 NOVT 2024
//----------------------------------------------------

package org.netbeans.modules.php.editor.parser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ public class CastExpression extends Expression {

public enum Type {
INT, // 'int'
/**
* @deprecated will be removed in the future, to follow PHP type system,
* use {@link Type#FLOAT} instead
*/
REAL, // 'real'
STRING, // 'string'
ARRAY, // 'array'
OBJECT, // 'object'
BOOL, // 'bool'
UNSET// 'unset'
UNSET,// 'unset'
FLOAT, // 'float'
}

private Expression expression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ public class Scalar extends Expression {

public enum Type {
INT, // 'int'
/**
* @deprecated will be removed in the future, to follow PHP type system,
* use {@link Type#FLOAT} instead
*/
REAL, // 'real'
STRING, // 'string'
UNKNOWN, // unknown scalar in quote expression
SYSTEM // system scalars (__CLASS__ / ...)

SYSTEM, // system scalars (__CLASS__ / ...)
FLOAT // 'float'
}
// 'int'
//public static final int TYPE_INT = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ public void scan(ASTNode node) {
type = Type.INTEGER;
break;
case REAL:
case FLOAT:
type = Type.FLOAT;
break;
case STRING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void visit(Scalar node) {
if (CancelSupport.getDefault().isCancelled()) {
return;
}
if (node.getScalarType().equals(Scalar.Type.REAL) && node.getStringValue().startsWith(BINARY_PREFIX)) {
if ((node.getScalarType().equals(Scalar.Type.FLOAT) || node.getScalarType().equals(Scalar.Type.REAL)) && node.getStringValue().startsWith(BINARY_PREFIX)) {
createError(node);
}
if (node.getScalarType().equals(Scalar.Type.SYSTEM) && "__TRAIT__".equals(node.getStringValue())) { // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private void checkUnpackableArrayElement(UnpackableArrayElement node) {

private void checkNumericLiteralSeparator(Scalar node) {
if (node.getScalarType() == Scalar.Type.INT
|| node.getScalarType() == Scalar.Type.FLOAT
|| node.getScalarType() == Scalar.Type.REAL) {
if (node.getStringValue().contains("_")) { // NOI18N
createError(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ private void checkExplicitOctalNotation(Scalar scalar) {

private boolean isNumber(Scalar scalar) {
return scalar.getScalarType() == Scalar.Type.INT
|| scalar.getScalarType() == Scalar.Type.FLOAT
|| scalar.getScalarType() == Scalar.Type.REAL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16986,7 +16986,7 @@
<ArrayAccess start='15518' end='15523' type='VARIABLE_ARRAY' isDollared='false'>
<ArrayDimension start='15520' end='15523'>
<Index>
<Scalar start='15521' end='15522' type='REAL' value='1'/>
<Scalar start='15521' end='15522' type='FLOAT' value='1'/>
</Index>
</ArrayDimension>
<Name>
Expand Down Expand Up @@ -17102,7 +17102,7 @@
<ArrayAccess start='15717' end='15722' type='VARIABLE_ARRAY' isDollared='false'>
<ArrayDimension start='15719' end='15722'>
<Index>
<Scalar start='15720' end='15721' type='REAL' value='1'/>
<Scalar start='15720' end='15721' type='FLOAT' value='1'/>
</Index>
</ArrayDimension>
<Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<Variable start='7' end='11' isDollared='true'>
<Identifier start='8' end='11' name='int'/>
</Variable>
<Scalar start='14' end='17' type='REAL' value='0b1'/>
<Scalar start='14' end='17' type='FLOAT' value='0b1'/>
</Assignment>
</ExpressionStatement>
<EmptyStatement start='20' end='22'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<Variable start='7' end='11' isDollared='true'>
<Identifier start='8' end='11' name='int'/>
</Variable>
<Scalar start='14' end='17' type='REAL' value='0b0'/>
<Scalar start='14' end='17' type='FLOAT' value='0b0'/>
</Assignment>
</ExpressionStatement>
<EmptyStatement start='20' end='22'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<Variable start='7' end='11' isDollared='true'>
<Identifier start='8' end='11' name='int'/>
</Variable>
<Scalar start='14' end='21' type='REAL' value='0b01010'/>
<Scalar start='14' end='21' type='FLOAT' value='0b01010'/>
</Assignment>
</ExpressionStatement>
<EmptyStatement start='24' end='26'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
</Variable>
<ClassName start='936' end='952'>
<ParenthesisExpression start='936' end='952'>
<CastExpression start='937' end='951' castingType='REAL'>
<CastExpression start='937' end='951' castingType='FLOAT'>
<Variable start='946' end='951' isDollared='true'>
<Identifier start='947' end='951' name='test'/>
</Variable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<ArrayAccess start='841' end='849' type='VARIABLE_ARRAY' isDollared='false'>
<ArrayDimension start='846' end='849'>
<Index>
<Scalar start='847' end='848' type='REAL' value='0'/>
<Scalar start='847' end='848' type='FLOAT' value='0'/>
</Index>
</ArrayDimension>
<Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<ASTError start='815' end='816'/>
<ASTError start='816' end='817'/>
<ExpressionStatement start='817' end='820'>
<Scalar start='817' end='819' type='REAL' value='.0'/>
<Scalar start='817' end='819' type='FLOAT' value='.0'/>
</ExpressionStatement>
</Statements>
</Program>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,23 +296,23 @@
<Identifier start='873' end='882' name='CONSTANT1'/>
</Names>
<Initializers>
<Scalar start='885' end='897' type='REAL' value='123456789.88'/>
<Scalar start='885' end='897' type='FLOAT' value='123456789.88'/>
</Initializers>
</GlobalConstantDeclaration>
<GlobalConstantDeclaration start='899' end='932'>
<Names>
<Identifier start='905' end='914' name='CONSTANT2'/>
</Names>
<Initializers>
<Scalar start='917' end='931' type='REAL' value='123_456_789.88'/>
<Scalar start='917' end='931' type='FLOAT' value='123_456_789.88'/>
</Initializers>
</GlobalConstantDeclaration>
<GlobalConstantDeclaration start='933' end='976'>
<Names>
<Identifier start='939' end='948' name='CONSTANT1'/>
</Names>
<Initializers>
<Scalar start='951' end='975' type='REAL' value='1_234_5678_9.88_888_8_88'/>
<Scalar start='951' end='975' type='FLOAT' value='1_234_5678_9.88_888_8_88'/>
</Initializers>
</GlobalConstantDeclaration>
<ExpressionStatement start='978' end='994'>
Expand All @@ -332,34 +332,34 @@
</Assignment>
</ExpressionStatement>
<ExpressionStatement start='1014' end='1018'>
<Scalar start='1014' end='1017' type='REAL' value='.88'/>
<Scalar start='1014' end='1017' type='FLOAT' value='.88'/>
</ExpressionStatement>
<ExpressionStatement start='1019' end='1026'>
<Scalar start='1019' end='1025' type='REAL' value='.88_00'/>
<Scalar start='1019' end='1025' type='FLOAT' value='.88_00'/>
</ExpressionStatement>
<ExpressionStatement start='1027' end='1037'>
<Scalar start='1027' end='1036' type='REAL' value='.88_000_0'/>
<Scalar start='1027' end='1036' type='FLOAT' value='.88_000_0'/>
</ExpressionStatement>
<ExpressionStatement start='1038' end='1042'>
<Scalar start='1038' end='1041' type='REAL' value='33.'/>
<Scalar start='1038' end='1041' type='FLOAT' value='33.'/>
</ExpressionStatement>
<ExpressionStatement start='1043' end='1050'>
<Scalar start='1043' end='1049' type='REAL' value='33_44.'/>
<Scalar start='1043' end='1049' type='FLOAT' value='33_44.'/>
</ExpressionStatement>
<ExpressionStatement start='1051' end='1065'>
<Scalar start='1051' end='1064' type='REAL' value='33_44_5_6666.'/>
<Scalar start='1051' end='1064' type='FLOAT' value='33_44_5_6666.'/>
</ExpressionStatement>
<ExpressionStatement start='1067' end='1080'>
<Scalar start='1067' end='1079' type='REAL' value='1.234567e-11'/>
<Scalar start='1067' end='1079' type='FLOAT' value='1.234567e-11'/>
</ExpressionStatement>
<ExpressionStatement start='1090' end='1104'>
<Scalar start='1090' end='1103' type='REAL' value='1.234_567e-11'/>
<Scalar start='1090' end='1103' type='FLOAT' value='1.234_567e-11'/>
</ExpressionStatement>
<ExpressionStatement start='1114' end='1130'>
<Scalar start='1114' end='1129' type='REAL' value='1.2_34_567e-1_1'/>
<Scalar start='1114' end='1129' type='FLOAT' value='1.2_34_567e-1_1'/>
</ExpressionStatement>
<ExpressionStatement start='1140' end='1156'>
<Scalar start='1140' end='1155' type='REAL' value='1.2_3456_7E1_11'/>
<Scalar start='1140' end='1155' type='FLOAT' value='1.2_3456_7E1_11'/>
</ExpressionStatement>
<ExpressionStatement start='1167' end='1177'>
<Scalar start='1167' end='1176' type='INT' value='123456789'/>
Expand All @@ -371,22 +371,22 @@
<Scalar start='1213' end='1225' type='INT' value='12_3456_7_89'/>
</ExpressionStatement>
<ExpressionStatement start='1239' end='1250'>
<Scalar start='1239' end='1249' type='REAL' value='0x1234ABCD'/>
<Scalar start='1239' end='1249' type='FLOAT' value='0x1234ABCD'/>
</ExpressionStatement>
<ExpressionStatement start='1266' end='1278'>
<Scalar start='1266' end='1277' type='REAL' value='0x1234_ABCD'/>
<Scalar start='1266' end='1277' type='FLOAT' value='0x1234_ABCD'/>
</ExpressionStatement>
<ExpressionStatement start='1294' end='1308'>
<Scalar start='1294' end='1307' type='REAL' value='0x1_23_4ABC_D'/>
<Scalar start='1294' end='1307' type='FLOAT' value='0x1_23_4ABC_D'/>
</ExpressionStatement>
<ExpressionStatement start='1325' end='1336'>
<Scalar start='1325' end='1335' type='REAL' value='0b01011111'/>
<Scalar start='1325' end='1335' type='FLOAT' value='0b01011111'/>
</ExpressionStatement>
<ExpressionStatement start='1347' end='1359'>
<Scalar start='1347' end='1358' type='REAL' value='0b0101_1111'/>
<Scalar start='1347' end='1358' type='FLOAT' value='0b0101_1111'/>
</ExpressionStatement>
<ExpressionStatement start='1370' end='1384'>
<Scalar start='1370' end='1383' type='REAL' value='0b010_11_1_11'/>
<Scalar start='1370' end='1383' type='FLOAT' value='0b010_11_1_11'/>
</ExpressionStatement>
<ExpressionStatement start='1396' end='1404'>
<Scalar start='1396' end='1403' type='INT' value='0123456'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@
</Variable>
</VariableNames>
<InitialValues>
<Scalar start='1349' end='1352' type='REAL' value='1.2'/>
<Scalar start='1349' end='1352' type='FLOAT' value='1.2'/>
</InitialValues>
</FieldsDeclaration>
<FieldsDeclaration start='1373' end='1421' modifier='private static'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@
</Variable>
</VariableNames>
<InitialValues>
<Scalar start='1349' end='1352' type='REAL' value='1.2'/>
<Scalar start='1349' end='1352' type='FLOAT' value='1.2'/>
</InitialValues>
</FieldsDeclaration>
<FieldsDeclaration start='1373' end='1421' modifier='private static'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<ASTError start='815' end='818'/>
<ASTError start='818' end='819'/>
<ExpressionStatement start='819' end='822'>
<Scalar start='819' end='821' type='REAL' value='.6'/>
<Scalar start='819' end='821' type='FLOAT' value='.6'/>
</ExpressionStatement>
</Statements>
</Program>
Expand Down
Loading

0 comments on commit a450d0f

Please sign in to comment.