Package org.sonar.php.tree.symbols
Class DeclarationVisitor
- java.lang.Object
-
- org.sonar.plugins.php.api.visitors.PHPVisitorCheck
-
- org.sonar.php.tree.symbols.DeclarationVisitor
-
- All Implemented Interfaces:
PHPCheck
,VisitorCheck
public class DeclarationVisitor extends PHPVisitorCheck
-
-
Field Summary
-
Fields inherited from class org.sonar.plugins.php.api.visitors.PHPVisitorCheck
MAX_DEPTH
-
-
Method Summary
-
Methods inherited from class org.sonar.plugins.php.api.visitors.PHPVisitorCheck
analyze, analyze, analyze, context, getFullyQualifiedName, init, newIssue, scan, scan, visitArrayAccess, visitArrayAssignmentPattern, visitArrayAssignmentPatternElement, visitArrayInitializerBracket, visitArrayInitializerFunction, visitArrayPair, visitArrowFunctionExpression, visitAssignmentExpression, visitAttribute, visitAttributeGroup, visitBinaryExpression, visitBlock, visitBreakStatement, visitBuiltInType, visitCallArgument, visitCaseClause, visitCastExpression, visitCatchBlock, visitClassPropertyDeclaration, visitCompoundVariable, visitComputedVariable, visitConditionalExpression, visitConstDeclaration, visitContinueStatement, visitDeclareStatement, visitDefaultClause, visitDoWhileStatement, visitEchoTagStatement, visitElseClause, visitElseifClause, visitEmptyStatement, visitExecutionOperator, visitExpandableStringCharacters, visitExpandableStringLiteral, visitExpressionListStatement, visitExpressionStatement, visitForEachStatement, visitForStatement, visitGlobalStatement, visitGotoStatement, visitHeredoc, visitIfStatement, visitInlineHTML, visitLabel, visitLexicalVariables, visitListExpression, visitLiteral, visitMatchConditionClause, visitMatchDefaultClause, visitMatchExpression, visitMemberAccess, visitNameIdentifier, visitNamespaceName, visitNewExpression, visitParameter, visitParameterList, visitParenthesisedExpression, visitPostfixExpression, visitPrefixedCastExpression, visitPrefixExpression, visitReferenceVariable, visitReturnTypeClause, visitScript, visitSpreadArgument, visitStaticStatement, visitSwitchStatement, visitThrowExpression, visitThrowStatement, visitToken, visitTraitAlias, visitTraitMethodReference, visitTraitPrecedence, visitTrivia, visitTryStatement, visitType, visitUnionType, visitUnsetVariableStatement, visitUseClause, visitUseTraitDeclaration, visitVariableDeclaration, visitVariableIdentifier, visitVariableVariable, visitWhileStatement
-
-
-
-
Method Detail
-
visitCompilationUnit
public void visitCompilationUnit(CompilationUnitTree tree)
- Specified by:
visitCompilationUnit
in interfaceVisitorCheck
- Overrides:
visitCompilationUnit
in classPHPVisitorCheck
-
visitClassDeclaration
public void visitClassDeclaration(ClassDeclarationTree tree)
- Specified by:
visitClassDeclaration
in interfaceVisitorCheck
- Overrides:
visitClassDeclaration
in classPHPVisitorCheck
-
visitAnonymousClass
public void visitAnonymousClass(AnonymousClassTree tree)
- Specified by:
visitAnonymousClass
in interfaceVisitorCheck
- Overrides:
visitAnonymousClass
in classPHPVisitorCheck
-
visitMethodDeclaration
public void visitMethodDeclaration(MethodDeclarationTree tree)
- Specified by:
visitMethodDeclaration
in interfaceVisitorCheck
- Overrides:
visitMethodDeclaration
in classPHPVisitorCheck
-
visitFunctionDeclaration
public void visitFunctionDeclaration(FunctionDeclarationTree tree)
- Specified by:
visitFunctionDeclaration
in interfaceVisitorCheck
- Overrides:
visitFunctionDeclaration
in classPHPVisitorCheck
-
visitReturnStatement
public void visitReturnStatement(ReturnStatementTree tree)
- Specified by:
visitReturnStatement
in interfaceVisitorCheck
- Overrides:
visitReturnStatement
in classPHPVisitorCheck
-
visitYieldExpression
public void visitYieldExpression(YieldExpressionTree tree)
- Specified by:
visitYieldExpression
in interfaceVisitorCheck
- Overrides:
visitYieldExpression
in classPHPVisitorCheck
-
visitFunctionExpression
public void visitFunctionExpression(FunctionExpressionTree tree)
- Specified by:
visitFunctionExpression
in interfaceVisitorCheck
- Overrides:
visitFunctionExpression
in classPHPVisitorCheck
-
visitFunctionCall
public void visitFunctionCall(FunctionCallTree tree)
- Specified by:
visitFunctionCall
in interfaceVisitorCheck
- Overrides:
visitFunctionCall
in classPHPVisitorCheck
-
classSymbolData
public Collection<ClassSymbolData> classSymbolData()
-
classSymbolIndex
public ClassSymbolIndex classSymbolIndex()
-
functionSymbolData
public Collection<FunctionSymbolData> functionSymbolData()
-
functionSymbolIndex
public FunctionSymbolIndex functionSymbolIndex()
-
currentNamespace
public SymbolQualifiedName currentNamespace()
-
visitNamespaceStatement
public void visitNamespaceStatement(NamespaceStatementTree tree)
- Specified by:
visitNamespaceStatement
in interfaceVisitorCheck
- Overrides:
visitNamespaceStatement
in classPHPVisitorCheck
-
isBracketedNamespace
public boolean isBracketedNamespace(NamespaceStatementTree tree)
-
visitUseStatement
public void visitUseStatement(UseStatementTree tree)
- Specified by:
visitUseStatement
in interfaceVisitorCheck
- Overrides:
visitUseStatement
in classPHPVisitorCheck
-
getFullyQualifiedName
public QualifiedName getFullyQualifiedName(NamespaceNameTree name, Symbol.Kind kind)
Resolution rules are defined in http://php.net/manual/en/language.namespaces.rules.phpIf unqualified name (see above link for definition) is a class symbol we resolve it in the current namespace. If it's a function we check if it's declared in current namespace, and if not we resolve as if it was in global namespace. This is imprecise heuristics, because function could be declared in current namespace, but in another source file, thus we will incorrectly consider such functions to be in the global namespace
-
-