aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaloyan Raev2013-11-15 02:43:58 (EST)
committerKaloyan Raev2013-11-18 05:13:14 (EST)
commit3f8a9fc4cffe3482d3bcd4da29a2348ed72c29a4 (patch)
tree4c87bb59dde3be5d7c02b0c399ab91f8ed6a1d76
parentf12ef90156e00f760d598200997c536082f6c111 (diff)
downloadorg.eclipse.pdt-3f8a9fc4cffe3482d3bcd4da29a2348ed72c29a4.zip
org.eclipse.pdt-3f8a9fc4cffe3482d3bcd4da29a2348ed72c29a4.tar.gz
org.eclipse.pdt-3f8a9fc4cffe3482d3bcd4da29a2348ed72c29a4.tar.bz2
Bug 421328 - fix for performance issue with TraitUtils.parse()refs/changes/84/18484/3
The initial patch in https://git.eclipse.org/r/18220 assumed that PHP types (classes, interfaces and traits) can be defined only in the global scope or inside a namespace. This is incomplete - types can be defined also in the scope of other blocks like if-then-else, while/for/foreach loops, try-catch, etc as long as the respective block is outside of another type declaration (in PHP types cannot be nested). This patch covers these additional use cases. Tests added to the suite. Bug: 421328 Change-Id: I5283d687386e4aaac60f96e44f5add1e519762a4 Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/TraitUseStatementVisitor.java (renamed from plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/TraitUseStatementASTVisitor.java)48
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/TypeDeclarationVisitor.java105
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/TraitUtils.java4
-rw-r--r--tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/AllTests.java6
-rw-r--r--tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/compiler_ast/parser/TraitUseStatementVisitorTests.java (renamed from tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/compiler_ast/parser/TraitUseStatementASTVisitorTests.java)10
-rw-r--r--tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/compiler_ast/parser/TypeDeclarationVisitorTests.java128
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testDeclare.pdtt10
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testFor.pdtt10
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testForEach.pdtt10
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testFunction.pdtt10
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testIfThenElse.pdtt17
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testSimple.pdtt8
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testSwitch.pdtt16
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testWhile.pdtt10
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testDeclare.pdtt12
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testFor.pdtt12
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testForEach.pdtt12
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testFunction.pdtt12
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testIfThenElse.pdtt23
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testSimple.pdtt10
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testSwitch.pdtt20
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testTryCatch.pdtt17
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testWhile.pdtt12
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php53/testAnonymousFunction.pdtt13
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php53/testNamespace.pdtt12
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testAnonymousFunction.pdtt15
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testDeclare.pdtt14
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testFor.pdtt14
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testForEach.pdtt14
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testFunction.pdtt14
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testIfThenElse.pdtt29
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testNamespace.pdtt14
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testSimple.pdtt12
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testSwitch.pdtt24
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testTryCatch.pdtt21
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testWhile.pdtt14
-rw-r--r--tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php55/testTryCatchFinally.pdtt28
37 files changed, 705 insertions, 55 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/TraitUseStatementASTVisitor.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/TraitUseStatementVisitor.java
index b969f76..08cfd56 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/TraitUseStatementASTVisitor.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/TraitUseStatementVisitor.java
@@ -10,15 +10,7 @@
*******************************************************************************/
package org.eclipse.php.internal.core.compiler.ast.visitor;
-import org.eclipse.dltk.ast.ASTNode;
-import org.eclipse.dltk.ast.ASTVisitor;
-import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
-import org.eclipse.dltk.ast.declarations.TypeDeclaration;
-import org.eclipse.dltk.ast.expressions.Expression;
-import org.eclipse.dltk.ast.statements.Block;
import org.eclipse.dltk.ast.statements.Statement;
-import org.eclipse.php.internal.core.compiler.ast.nodes.ClassDeclaration;
-import org.eclipse.php.internal.core.compiler.ast.nodes.NamespaceDeclaration;
import org.eclipse.php.internal.core.compiler.ast.nodes.TraitUseStatement;
/**
@@ -33,34 +25,7 @@ import org.eclipse.php.internal.core.compiler.ast.nodes.TraitUseStatement;
*
* @author Kaloyan Raev
*/
-public abstract class TraitUseStatementASTVisitor extends ASTVisitor {
-
- /**
- * The visitor must always look inside {@link ModuleDeclaration}s.
- */
- @Override
- public boolean visit(ModuleDeclaration s) throws Exception {
- return true;
- }
-
- /**
- * The visitor must look into an {@link Expression} only if it is a
- * {@link Block} (because it can be a block of a class declaration).
- */
- @Override
- public boolean visit(Expression s) throws Exception {
- return s instanceof Block;
- }
-
- /**
- * The visitor must look into a {@link TypeDeclaration} only if it is a
- * {@link NamespaceDeclaration} or a {@link ClassDeclaration}.
- */
- @Override
- public boolean visit(TypeDeclaration s) throws Exception {
- return s instanceof NamespaceDeclaration
- || s instanceof ClassDeclaration;
- }
+public abstract class TraitUseStatementVisitor extends TypeDeclarationVisitor {
/**
* The visitor must check if a {@link Statement} is a
@@ -73,7 +38,7 @@ public abstract class TraitUseStatementASTVisitor extends ASTVisitor {
if (s instanceof TraitUseStatement) {
return visit((TraitUseStatement) s);
}
- return false;
+ return super.visit(s);
}
/**
@@ -88,13 +53,4 @@ public abstract class TraitUseStatementASTVisitor extends ASTVisitor {
*/
public abstract boolean visit(TraitUseStatement s) throws Exception;
- /**
- * In all other cases the visitor must not look deeper into the AST tree -
- * there is no chance to find an {@link TraitUseStatement} there.
- */
- @Override
- public boolean visitGeneral(ASTNode node) throws Exception {
- return false;
- }
-
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/TypeDeclarationVisitor.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/TypeDeclarationVisitor.java
new file mode 100644
index 0000000..b834c02
--- /dev/null
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/visitor/TypeDeclarationVisitor.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Zend Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Zend Technologies - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.php.internal.core.compiler.ast.visitor;
+
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.declarations.TypeDeclaration;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.statements.Block;
+import org.eclipse.php.internal.core.compiler.ast.nodes.ClassDeclaration;
+import org.eclipse.php.internal.core.compiler.ast.nodes.NamespaceDeclaration;
+
+/**
+ * AST visitor optimized for finding type declarations in PHP source modules.
+ *
+ * <p>
+ * Types are classes, interfaces and traits. Namespaces are not considered as
+ * types in this implementation although {@link NamespaceDeclaration} extends
+ * {@link TypeDeclaration} in the AST hierarchy.
+ * </p>
+ *
+ * <p>
+ * This visitor is optimized for performance to look not deeper than the
+ * necessary level in the AST tree. It builds on the rule the classes in PHP
+ * cannot be nested. Therefore, there is no sense to look inside a
+ * {@link TypeDeclaration} for finding other {@link TypeDeclaration}s.
+ * </p>
+ *
+ * @author Kaloyan Raev
+ */
+public abstract class TypeDeclarationVisitor extends ASTVisitor {
+
+ /**
+ * Flag that indicates that the visitor is traversing inside a
+ * {@link TypeDeclaration}.
+ */
+ private boolean insideType = false;
+
+ /**
+ * The visitor must always look into {@link Block}s. A block wraps
+ * {@link ClassDeclaration} children and it must be traversed in order to
+ * visit class' children.
+ */
+ @Override
+ public boolean visit(Expression s) throws Exception {
+ return s instanceof Block || super.visit(s);
+ }
+
+ /**
+ * The visitor must look into a {@link TypeDeclaration}s. If class,
+ * interface or trait (i.e. different than {@link NamespaceDeclaration})
+ * then raise the {@link #insideType} flag.
+ */
+ @Override
+ public boolean visit(TypeDeclaration s) throws Exception {
+ if (!(s instanceof NamespaceDeclaration)) {
+ insideType = true;
+ visitType(s);
+ }
+ // return true to make sure endVisit() will be called
+ return true;
+ }
+
+ /**
+ * Pull the {@link #insideType} flag down when ending visiting class,
+ * interface or trait.
+ */
+ @Override
+ public boolean endvisit(TypeDeclaration s) throws Exception {
+ if (!(s instanceof NamespaceDeclaration)) {
+ insideType = false;
+ }
+ return false;
+ }
+
+ /**
+ * Subclasses may implement this method to process the found
+ * {@link TypeDeclaration} nodes.
+ *
+ * @param s
+ * the visited AST node
+ * @throws Exception
+ */
+ public void visitType(TypeDeclaration s) throws Exception {
+ // do nothing be default
+ }
+
+ /**
+ * In all other cases the visitor must look deeper into the AST tree only
+ * and if only it is outside of a <code>TypeDecalaration</code>.
+ */
+ @Override
+ public boolean visitGeneral(ASTNode node) throws Exception {
+ return !insideType;
+ }
+
+}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/TraitUtils.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/TraitUtils.java
index 976af52..e367b70 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/TraitUtils.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/TraitUtils.java
@@ -19,7 +19,7 @@ import org.eclipse.dltk.internal.core.SourceField;
import org.eclipse.dltk.internal.core.SourceMethod;
import org.eclipse.php.core.compiler.PHPFlags;
import org.eclipse.php.internal.core.compiler.ast.nodes.*;
-import org.eclipse.php.internal.core.compiler.ast.visitor.TraitUseStatementASTVisitor;
+import org.eclipse.php.internal.core.compiler.ast.visitor.TraitUseStatementVisitor;
import org.eclipse.php.internal.core.model.PhpModelAccess;
/**
@@ -37,7 +37,7 @@ public class TraitUtils {
final ISourceRange sourceRange = type.getSourceRange();
ModuleDeclaration moduleDeclaration = SourceParserUtil
.getModuleDeclaration(sourceModule);
- moduleDeclaration.traverse(new TraitUseStatementASTVisitor() {
+ moduleDeclaration.traverse(new TraitUseStatementVisitor() {
@Override
public boolean visit(TraitUseStatement s) throws Exception {
if (s.sourceStart() > sourceRange.getOffset()
diff --git a/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/AllTests.java b/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/AllTests.java
index c5829de..f52148d 100644
--- a/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/AllTests.java
+++ b/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/AllTests.java
@@ -19,7 +19,8 @@ import org.eclipse.php.core.tests.compiler_ast.parser.CompilerParserTests;
import org.eclipse.php.core.tests.compiler_ast.parser.FindUseStatementByAliasTests;
import org.eclipse.php.core.tests.compiler_ast.parser.FindUseStatementByNamespaceTests;
import org.eclipse.php.core.tests.compiler_ast.parser.GetUseStatementsByTests;
-import org.eclipse.php.core.tests.compiler_ast.parser.TraitUseStatementASTVisitorTests;
+import org.eclipse.php.core.tests.compiler_ast.parser.TraitUseStatementVisitorTests;
+import org.eclipse.php.core.tests.compiler_ast.parser.TypeDeclarationVisitorTests;
import org.eclipse.php.core.tests.compiler_ast.phpdoc.PHPDocAwareDeclarationTests;
import org.eclipse.php.core.tests.compiler_ast.phpdoc.PHPDocParserTests;
import org.eclipse.php.core.tests.document.lexer.DocumentLexerTests;
@@ -53,7 +54,8 @@ public class AllTests {
suite.addTest(FindUseStatementByAliasTests.suite());
suite.addTest(FindUseStatementByNamespaceTests.suite());
suite.addTest(GetUseStatementsByTests.suite());
- suite.addTest(TraitUseStatementASTVisitorTests.suite());
+ suite.addTest(TypeDeclarationVisitorTests.suite());
+ suite.addTest(TraitUseStatementVisitorTests.suite());
suite.addTest(ErrorReportingTests.suite());
suite.addTest(ASTRewriteTests.suite());
suite.addTest(ASTMatcherTests.suite());
diff --git a/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/compiler_ast/parser/TraitUseStatementASTVisitorTests.java b/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/compiler_ast/parser/TraitUseStatementVisitorTests.java
index e2bf11c..69e8d2c 100644
--- a/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/compiler_ast/parser/TraitUseStatementASTVisitorTests.java
+++ b/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/compiler_ast/parser/TraitUseStatementVisitorTests.java
@@ -28,10 +28,10 @@ import org.eclipse.php.internal.core.PHPVersion;
import org.eclipse.php.internal.core.compiler.ast.nodes.TraitUseStatement;
import org.eclipse.php.internal.core.compiler.ast.parser.AbstractPHPSourceParser;
import org.eclipse.php.internal.core.compiler.ast.parser.PHPSourceParserFactory;
-import org.eclipse.php.internal.core.compiler.ast.visitor.TraitUseStatementASTVisitor;
+import org.eclipse.php.internal.core.compiler.ast.visitor.TraitUseStatementVisitor;
import org.eclipse.php.internal.core.project.ProjectOptions;
-public class TraitUseStatementASTVisitorTests extends AbstractPDTTTest {
+public class TraitUseStatementVisitorTests extends AbstractPDTTTest {
protected static final Map<PHPVersion, String[]> TESTS = new LinkedHashMap<PHPVersion, String[]>();
static {
@@ -40,13 +40,13 @@ public class TraitUseStatementASTVisitorTests extends AbstractPDTTTest {
new String[] { "/workspace/astutils/trait_use_statement_visitor/php54" });
};
- public TraitUseStatementASTVisitorTests(String description) {
+ public TraitUseStatementVisitorTests(String description) {
super(description);
}
public static Test suite() {
- TestSuite suite = new TestSuite("Trait Use Statement Tests");
+ TestSuite suite = new TestSuite("Trait Use Statement Visitor Tests");
for (final PHPVersion phpVersion : TESTS.keySet()) {
TestSuite phpVerSuite = new TestSuite(phpVersion.getAlias());
@@ -75,7 +75,7 @@ public class TraitUseStatementASTVisitorTests extends AbstractPDTTTest {
final StringBuilder builder = new StringBuilder();
moduleDeclaration
- .traverse(new TraitUseStatementASTVisitor() {
+ .traverse(new TraitUseStatementVisitor() {
@Override
public boolean visit(
TraitUseStatement s)
diff --git a/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/compiler_ast/parser/TypeDeclarationVisitorTests.java b/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/compiler_ast/parser/TypeDeclarationVisitorTests.java
new file mode 100644
index 0000000..507073d
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/src/org/eclipse/php/core/tests/compiler_ast/parser/TypeDeclarationVisitorTests.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Zend Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Zend Technologies - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.php.core.tests.compiler_ast.parser;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStreamReader;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.ast.declarations.TypeDeclaration;
+import org.eclipse.php.core.tests.AbstractPDTTTest;
+import org.eclipse.php.core.tests.PdttFile;
+import org.eclipse.php.internal.core.PHPVersion;
+import org.eclipse.php.internal.core.compiler.ast.parser.AbstractPHPSourceParser;
+import org.eclipse.php.internal.core.compiler.ast.parser.PHPSourceParserFactory;
+import org.eclipse.php.internal.core.compiler.ast.visitor.TypeDeclarationVisitor;
+import org.eclipse.php.internal.core.project.ProjectOptions;
+
+public class TypeDeclarationVisitorTests extends AbstractPDTTTest {
+
+ protected static final Map<PHPVersion, String[]> TESTS = new LinkedHashMap<PHPVersion, String[]>();
+ static {
+ TESTS.put(
+ PHPVersion.PHP4,
+ new String[] { "/workspace/astutils/type_declaration_visitor/php4" });
+ TESTS.put(
+ PHPVersion.PHP5,
+ new String[] { "/workspace/astutils/type_declaration_visitor/php5" });
+ TESTS.put(PHPVersion.PHP5_3, new String[] {
+ "/workspace/astutils/type_declaration_visitor/php5",
+ "/workspace/astutils/type_declaration_visitor/php53" });
+ TESTS.put(
+ PHPVersion.PHP5_4,
+ new String[] { "/workspace/astutils/type_declaration_visitor/php54" });
+ TESTS.put(PHPVersion.PHP5_5, new String[] {
+ "/workspace/astutils/type_declaration_visitor/php54",
+ "/workspace/astutils/type_declaration_visitor/php55" });
+ };
+
+ public TypeDeclarationVisitorTests(String description) {
+ super(description);
+ }
+
+ public static Test suite() {
+
+ TestSuite suite = new TestSuite("Type Declaration Visitor Tests");
+
+ for (final PHPVersion phpVersion : TESTS.keySet()) {
+ TestSuite phpVerSuite = new TestSuite(phpVersion.getAlias());
+ final AbstractPHPSourceParser parser = PHPSourceParserFactory
+ .createParser(phpVersion);
+
+ for (String testsDirectory : TESTS.get(phpVersion)) {
+
+ for (final String fileName : getPDTTFiles(testsDirectory)) {
+ try {
+ final PdttFile pdttFile = new PdttFile(fileName);
+ phpVerSuite.addTest(new CompilerParserTests(phpVersion
+ .getAlias() + " - /" + fileName) {
+
+ protected void runTest() throws Throwable {
+
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(
+ pdttFile.getFile().trim().getBytes());
+ ModuleDeclaration moduleDeclaration = (ModuleDeclaration) parser
+ .parse(new InputStreamReader(
+ inputStream),
+ null,
+ ProjectOptions
+ .useShortTags((IProject) null));
+
+ final StringBuilder builder = new StringBuilder();
+
+ moduleDeclaration
+ .traverse(new TypeDeclarationVisitor() {
+ @Override
+ public void visitType(
+ TypeDeclaration s) {
+ builder.append(s.getName());
+ builder.append('\n');
+ }
+ });
+
+ String actual = builder.toString();
+ String expected = pdttFile.getExpected();
+
+ assertContents(expected, actual);
+ }
+ });
+ } catch (final Exception e) {
+ // dummy test indicating PDTT file parsing failure
+ phpVerSuite.addTest(new TestCase(fileName) {
+ protected void runTest() throws Throwable {
+ throw e;
+ }
+ });
+ }
+ }
+ }
+ suite.addTest(phpVerSuite);
+ }
+
+ // Create a setup wrapper
+ TestSetup setup = new TestSetup(suite) {
+ protected void setUp() throws Exception {
+ }
+
+ protected void tearDown() throws Exception {
+ }
+ };
+ return setup;
+ }
+}
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testDeclare.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testDeclare.pdtt
new file mode 100644
index 0000000..9d5fca3
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testDeclare.pdtt
@@ -0,0 +1,10 @@
+--TEST--
+Get type declarations inside a declare block
+--FILE--
+<?php
+declare(x=1) {
+ class MyClass {}
+}
+?>
+--EXPECT--
+MyClass
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testFor.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testFor.pdtt
new file mode 100644
index 0000000..e70ceb3
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testFor.pdtt
@@ -0,0 +1,10 @@
+--TEST--
+Get type declarations inside a for loop
+--FILE--
+<?php
+for (;;) {
+ class MyClass {}
+}
+?>
+--EXPECT--
+MyClass
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testForEach.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testForEach.pdtt
new file mode 100644
index 0000000..d4b2f8f
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testForEach.pdtt
@@ -0,0 +1,10 @@
+--TEST--
+Get type declarations inside a for-each loop
+--FILE--
+<?php
+foreach (array() as $x) {
+ class MyClass {}
+}
+?>
+--EXPECT--
+MyClass
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testFunction.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testFunction.pdtt
new file mode 100644
index 0000000..8773ef9
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testFunction.pdtt
@@ -0,0 +1,10 @@
+--TEST--
+Get type declarations inside a function
+--FILE--
+<?php
+function foo() {
+ class MyClass {}
+}
+?>
+--EXPECT--
+MyClass
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testIfThenElse.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testIfThenElse.pdtt
new file mode 100644
index 0000000..ccf64c9
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testIfThenElse.pdtt
@@ -0,0 +1,17 @@
+--TEST--
+Get type declarations inside an if-then-else block
+--FILE--
+<?php
+$i = 0;
+if ($i = 0) {
+ class MyClass {}
+} elseif ($i = 1) {
+ class MyClass2 {}
+} else {
+ class MyClass3 {}
+}
+?>
+--EXPECT--
+MyClass
+MyClass2
+MyClass3
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testSimple.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testSimple.pdtt
new file mode 100644
index 0000000..b6edcb3
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testSimple.pdtt
@@ -0,0 +1,8 @@
+--TEST--
+Get type declarations in a simple example
+--FILE--
+<?php
+class MyClass {}
+?>
+--EXPECT--
+MyClass
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testSwitch.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testSwitch.pdtt
new file mode 100644
index 0000000..fd028a4
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testSwitch.pdtt
@@ -0,0 +1,16 @@
+--TEST--
+Get type declarations inside a switch block
+--FILE--
+<?php
+$i = 0;
+switch ($i) {
+ case 0:
+ class MyClass {}
+ break;
+ default:
+ class MyClass2 {}
+}
+?>
+--EXPECT--
+MyClass
+MyClass2
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testWhile.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testWhile.pdtt
new file mode 100644
index 0000000..59dc59c
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php4/testWhile.pdtt
@@ -0,0 +1,10 @@
+--TEST--
+Get type declarations inside a while loop
+--FILE--
+<?php
+while (true) {
+ class MyClass {}
+}
+?>
+--EXPECT--
+MyClass
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testDeclare.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testDeclare.pdtt
new file mode 100644
index 0000000..4ccafd9
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testDeclare.pdtt
@@ -0,0 +1,12 @@
+--TEST--
+Get type declarations inside a declare block
+--FILE--
+<?php
+declare(x=1) {
+ class MyClass {}
+ interface MyInterface {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testFor.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testFor.pdtt
new file mode 100644
index 0000000..ffb07ce
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testFor.pdtt
@@ -0,0 +1,12 @@
+--TEST--
+Get type declarations inside a for loop
+--FILE--
+<?php
+for (;;) {
+ class MyClass {}
+ interface MyInterface {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testForEach.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testForEach.pdtt
new file mode 100644
index 0000000..e212abd
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testForEach.pdtt
@@ -0,0 +1,12 @@
+--TEST--
+Get type declarations inside a for-each loop
+--FILE--
+<?php
+foreach (array() as $x) {
+ class MyClass {}
+ interface MyInterface {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testFunction.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testFunction.pdtt
new file mode 100644
index 0000000..d885426
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testFunction.pdtt
@@ -0,0 +1,12 @@
+--TEST--
+Get type declarations inside a function
+--FILE--
+<?php
+function foo() {
+ class MyClass {}
+ interface MyInterface {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testIfThenElse.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testIfThenElse.pdtt
new file mode 100644
index 0000000..f490420
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testIfThenElse.pdtt
@@ -0,0 +1,23 @@
+--TEST--
+Get type declarations inside an if-then-else block
+--FILE--
+<?php
+$i = 0;
+if ($i = 0) {
+ class MyClass {}
+ interface MyInterface {}
+} elseif ($i = 1) {
+ class MyClass2 {}
+ interface MyInterface2 {}
+} else {
+ class MyClass3 {}
+ interface MyInterface3 {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyClass2
+MyInterface2
+MyClass3
+MyInterface3
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testSimple.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testSimple.pdtt
new file mode 100644
index 0000000..16d19e9
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testSimple.pdtt
@@ -0,0 +1,10 @@
+--TEST--
+Get type declarations in a simple example
+--FILE--
+<?php
+class MyClass {}
+interface MyInterface {}
+?>
+--EXPECT--
+MyClass
+MyInterface
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testSwitch.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testSwitch.pdtt
new file mode 100644
index 0000000..93948c8
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testSwitch.pdtt
@@ -0,0 +1,20 @@
+--TEST--
+Get type declarations inside a switch block
+--FILE--
+<?php
+$i = 0;
+switch ($i) {
+ case 0:
+ class MyClass {}
+ interface MyInterface {}
+ break;
+ default:
+ class MyClass2 {}
+ interface MyInterface2 {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyClass2
+MyInterface2
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testTryCatch.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testTryCatch.pdtt
new file mode 100644
index 0000000..6d1671e
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testTryCatch.pdtt
@@ -0,0 +1,17 @@
+--TEST--
+Get type declarations inside a try-catch block
+--FILE--
+<?php
+try {
+ class MyClass {}
+ interface MyInterface {}
+} catch (Exception $e) {
+ class MyClass2 {}
+ interface MyInterface2 {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyClass2
+MyInterface2
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testWhile.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testWhile.pdtt
new file mode 100644
index 0000000..622aa30
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php5/testWhile.pdtt
@@ -0,0 +1,12 @@
+--TEST--
+Get type declarations inside a while loop
+--FILE--
+<?php
+while (true) {
+ class MyClass {}
+ interface MyInterface {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php53/testAnonymousFunction.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php53/testAnonymousFunction.pdtt
new file mode 100644
index 0000000..6427a6e
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php53/testAnonymousFunction.pdtt
@@ -0,0 +1,13 @@
+--TEST--
+Get type declarations inside an anonymous function
+--FILE--
+<?php
+$greet = function($name) {
+ class MyClass {}
+ interface MyInterface {}
+};
+$greet('World');
+?>
+--EXPECT--
+MyClass
+MyInterface
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php53/testNamespace.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php53/testNamespace.pdtt
new file mode 100644
index 0000000..039263e
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php53/testNamespace.pdtt
@@ -0,0 +1,12 @@
+--TEST--
+Get type declarations inside a namespace
+--FILE--
+<?php
+namespace NS {
+ class MyClass {}
+ interface MyInterface {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testAnonymousFunction.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testAnonymousFunction.pdtt
new file mode 100644
index 0000000..e3e84d7
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testAnonymousFunction.pdtt
@@ -0,0 +1,15 @@
+--TEST--
+Get type declarations inside an anonymous function
+--FILE--
+<?php
+$greet = function($name) {
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+};
+$greet('World');
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testDeclare.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testDeclare.pdtt
new file mode 100644
index 0000000..2a87132
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testDeclare.pdtt
@@ -0,0 +1,14 @@
+--TEST--
+Get type declarations inside a declare block
+--FILE--
+<?php
+declare(x=1) {
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testFor.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testFor.pdtt
new file mode 100644
index 0000000..306556a
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testFor.pdtt
@@ -0,0 +1,14 @@
+--TEST--
+Get type declarations inside a for loop
+--FILE--
+<?php
+for (;;) {
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testForEach.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testForEach.pdtt
new file mode 100644
index 0000000..cd0b24d
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testForEach.pdtt
@@ -0,0 +1,14 @@
+--TEST--
+Get type declarations inside a for-each loop
+--FILE--
+<?php
+foreach (array() as $x) {
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testFunction.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testFunction.pdtt
new file mode 100644
index 0000000..b2dbbca
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testFunction.pdtt
@@ -0,0 +1,14 @@
+--TEST--
+Get type declarations inside a function
+--FILE--
+<?php
+function foo() {
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testIfThenElse.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testIfThenElse.pdtt
new file mode 100644
index 0000000..2d399f9
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testIfThenElse.pdtt
@@ -0,0 +1,29 @@
+--TEST--
+Get type declarations inside an if-then-else block
+--FILE--
+<?php
+$i = 0;
+if ($i = 0) {
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+} elseif ($i = 1) {
+ class MyClass2 {}
+ interface MyInterface2 {}
+ trait MyTrait2 {}
+} else {
+ class MyClass3 {}
+ interface MyInterface3 {}
+ trait MyTrait3 {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
+MyClass2
+MyInterface2
+MyTrait2
+MyClass3
+MyInterface3
+MyTrait3
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testNamespace.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testNamespace.pdtt
new file mode 100644
index 0000000..964f092
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testNamespace.pdtt
@@ -0,0 +1,14 @@
+--TEST--
+Get type declarations inside a namespace
+--FILE--
+<?php
+namespace NS {
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testSimple.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testSimple.pdtt
new file mode 100644
index 0000000..384348b
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testSimple.pdtt
@@ -0,0 +1,12 @@
+--TEST--
+Get type declarations in a simple example
+--FILE--
+<?php
+class MyClass {}
+interface MyInterface {}
+trait MyTrait {}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait \ No newline at end of file
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testSwitch.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testSwitch.pdtt
new file mode 100644
index 0000000..9935685
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testSwitch.pdtt
@@ -0,0 +1,24 @@
+--TEST--
+Get type declarations inside a switch block
+--FILE--
+<?php
+$i = 0;
+switch ($i) {
+ case 0:
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+ break;
+ default:
+ class MyClass2 {}
+ interface MyInterface2 {}
+ trait MyTrait2 {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
+MyClass2
+MyInterface2
+MyTrait2
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testTryCatch.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testTryCatch.pdtt
new file mode 100644
index 0000000..8f4890f
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testTryCatch.pdtt
@@ -0,0 +1,21 @@
+--TEST--
+Get type declarations inside a try-catch block
+--FILE--
+<?php
+try {
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+} catch (Exception $e) {
+ class MyClass2 {}
+ interface MyInterface2 {}
+ trait MyTrait2 {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
+MyClass2
+MyInterface2
+MyTrait2
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testWhile.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testWhile.pdtt
new file mode 100644
index 0000000..d2f5d5e
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php54/testWhile.pdtt
@@ -0,0 +1,14 @@
+--TEST--
+Get type declarations inside a while loop
+--FILE--
+<?php
+while (true) {
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
diff --git a/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php55/testTryCatchFinally.pdtt b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php55/testTryCatchFinally.pdtt
new file mode 100644
index 0000000..df8d20c
--- /dev/null
+++ b/tests/org.eclipse.php.core.tests/workspace/astutils/type_declaration_visitor/php55/testTryCatchFinally.pdtt
@@ -0,0 +1,28 @@
+--TEST--
+Get type declarations inside a try-catch block
+--FILE--
+<?php
+try {
+ class MyClass {}
+ interface MyInterface {}
+ trait MyTrait {}
+} catch (Exception $e) {
+ class MyClass2 {}
+ interface MyInterface2 {}
+ trait MyTrait2 {}
+} finally {
+ class MyClass3 {}
+ interface MyInterface3 {}
+ trait MyTrait3 {}
+}
+?>
+--EXPECT--
+MyClass
+MyInterface
+MyTrait
+MyClass2
+MyInterface2
+MyTrait2
+MyClass3
+MyInterface3
+MyTrait3