aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2018-08-01 08:54:26 -0400
committerDawid Pakuła2018-08-01 08:54:26 -0400
commitc828e85f9b7e28588f2ae04c057e87c4f747fd9c (patch)
treeeaf3fbf2b8fdae1829f538dcf6636e38bbc344b7
parent809e30ec2527e3a346e10983ab2ffacaacdbc61a (diff)
downloadorg.eclipse.pdt-c828e85f9b7e28588f2ae04c057e87c4f747fd9c.tar.gz
org.eclipse.pdt-c828e85f9b7e28588f2ae04c057e87c4f747fd9c.tar.xz
org.eclipse.pdt-c828e85f9b7e28588f2ae04c057e87c4f747fd9c.zip
Bug 537548 - false positive syntax error for HEREDOC on class constant
Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/ValidatorVisitor.java14
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/errors/php7/invalidConstantExpression6.pdtt13
2 files changed, 22 insertions, 5 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/ValidatorVisitor.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/ValidatorVisitor.java
index d76302cf8..d9316bc74 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/ValidatorVisitor.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/ValidatorVisitor.java
@@ -358,10 +358,10 @@ public class ValidatorVisitor extends PHPASTVisitor implements IValidatorVisitor
}
/**
- * Generic checks to only visit PHPDoc type references whose names are valid php
- * identifier names. See also
- * {@link PHPSelectionEngine#lookForMatchingElements()} for more complete and
- * precise PHPDoc type references handling.
+ * Generic checks to only visit PHPDoc type references whose names are valid
+ * php identifier names. See also
+ * {@link PHPSelectionEngine#lookForMatchingElements()} for more complete
+ * and precise PHPDoc type references handling.
*/
@SuppressWarnings("null")
private void visitCommentType(TypeReference typeReference, ProblemSeverity severity) throws Exception {
@@ -908,7 +908,11 @@ public class ValidatorVisitor extends PHPASTVisitor implements IValidatorVisitor
if (astNode == null || astNode instanceof Scalar || astNode instanceof ConstantReference) {
return;
}
- if (astNode instanceof UnaryOperation) {
+ if (astNode instanceof Quote) {
+ for (ASTNode expr : ((Quote) astNode).getExpressions()) {
+ validateConstantExpression(expr, allowArray);
+ }
+ } else if (astNode instanceof UnaryOperation) {
UnaryOperation op = (UnaryOperation) astNode;
if (version.isLessThan(PHPVersion.PHP5_6) && op.getOperatorType() != UnaryOperation.OP_MINUS
&& op.getOperatorType() != UnaryOperation.OP_PLUS) {
diff --git a/tests/org.eclipse.php.core.tests/workspace/errors/php7/invalidConstantExpression6.pdtt b/tests/org.eclipse.php.core.tests/workspace/errors/php7/invalidConstantExpression6.pdtt
new file mode 100644
index 000000000..a593e37d1
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/errors/php7/invalidConstantExpression6.pdtt
@@ -0,0 +1,13 @@
+--TEST--
+Test unfinished method declaration error reporting
+--FILE--
+<?php
+class MyClass {
+ const FOO = <<<BAR
+SOMETHING $var
+BAR;
+}
+?>
+--EXPECT--
+[line=4, start=55, end=59] Constant expression contains invalid operations
+[line=4, start=55, end=59] Variable '$var' is undefined \ No newline at end of file