diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/VariousUtils.java b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/VariousUtils.java index 84720f7184aa..effffeed3aa0 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/VariousUtils.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/VariousUtils.java @@ -52,7 +52,6 @@ import org.netbeans.modules.php.editor.model.FileScope; import org.netbeans.modules.php.editor.model.FunctionScope; import org.netbeans.modules.php.editor.model.IndexScope; -import org.netbeans.modules.php.editor.model.InterfaceScope; import org.netbeans.modules.php.editor.model.MethodScope; import org.netbeans.modules.php.editor.model.ModelElement; import org.netbeans.modules.php.editor.model.ModelUtils; @@ -1684,7 +1683,8 @@ public static Collection getStaticTypeName(Scope inScope, S csi = (EnumScope) methodInScope; } } - if (inScope instanceof ClassScope || inScope instanceof InterfaceScope) { + if (inScope instanceof TypeScope) { + // e.g. const EXAMPLE = self::UNDEFINED; csi = (TypeScope) inScope; } if (csi != null) { diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/IntroduceSuggestion.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/IntroduceSuggestion.java index 368569f68ab0..2d9c149a5b67 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/IntroduceSuggestion.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/IntroduceSuggestion.java @@ -80,6 +80,7 @@ import org.netbeans.modules.php.editor.parser.astnodes.Expression; import org.netbeans.modules.php.editor.parser.astnodes.FieldAccess; import org.netbeans.modules.php.editor.parser.astnodes.MethodInvocation; +import org.netbeans.modules.php.editor.parser.astnodes.NamespaceName; import org.netbeans.modules.php.editor.parser.astnodes.StaticConstantAccess; import org.netbeans.modules.php.editor.parser.astnodes.StaticFieldAccess; import org.netbeans.modules.php.editor.parser.astnodes.StaticMethodInvocation; @@ -349,7 +350,9 @@ public void visit(StaticConstantAccess staticConstantAccess) { if (CancelSupport.getDefault().isCancelled()) { return; } - if (lineBounds.containsInclusive(staticConstantAccess.getStartOffset())) { + if (!staticConstantAccess.isDynamicName() + && (staticConstantAccess.getDispatcher() instanceof NamespaceName) // e.g. ClassName::CONSTANT, self::CONSTANT + && lineBounds.containsInclusive(staticConstantAccess.getStartOffset())) { String constName = staticConstantAccess.getConstantName().getName(); String clzName = CodeUtils.extractUnqualifiedClassName(staticConstantAccess); diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP55UnhandledError.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP55UnhandledError.java index 6cbb4bfcca43..676018087603 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP55UnhandledError.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP55UnhandledError.java @@ -124,11 +124,15 @@ public void visit(StaticConstantAccess node) { if (CancelSupport.getDefault().isCancelled()) { return; } - Identifier constant = node.getConstantName(); - if (constant != null) { - String constantName = constant.getName(); - if ("class".equals(constantName.toLowerCase())) { //NOI18N - createError(constant); + if (node.isDynamicName()) { + super.visit(node); + } else { + Identifier constant = node.getConstantName(); + if (constant != null) { + String constantName = constant.getName(); + if ("class".equals(constantName.toLowerCase())) { //NOI18N + createError(constant); + } } } } diff --git a/php/php.editor/test/unit/data/testfiles/verification/IntroduceSuggestion/testDynamicClassConstantFetch/testDynamicClassConstantFetch.php b/php/php.editor/test/unit/data/testfiles/verification/IntroduceSuggestion/testDynamicClassConstantFetch/testDynamicClassConstantFetch.php new file mode 100644 index 000000000000..c170a94ab150 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/verification/IntroduceSuggestion/testDynamicClassConstantFetch/testDynamicClassConstantFetch.php @@ -0,0 +1,50 @@ +