@Test public void expressions() throws Exception { assertThat(complexity("$a;")).isEqualTo(0); assertThat(complexity("$a + $b;")).isEqualTo(0); assertThat(complexity("$f();")).isEqualTo(0); assertOneComplexityToken("$a || $b;", "||"); assertOneComplexityToken("$a && $b;", "&&"); assertOneComplexityToken("$a or $b;", "or"); assertOneComplexityToken("$a and $b;", "and"); assertOneComplexityToken("$a ? $b : $c;", "?"); }
public static int complexity(Tree tree) { return complexityTrees(tree).size(); }
ComplexityVisitor extends PHPVisitorCheck { public static int complexity(Tree tree) { return complexityTrees(tree).size(); } }
ComplexityVisitor extends PHPVisitorCheck { public static int complexity(Tree tree) { return complexityTrees(tree).size(); }  }
ComplexityVisitor extends PHPVisitorCheck { public static int complexity(Tree tree) { return complexityTrees(tree).size(); }  @Override void visitCaseClause(CaseClauseTree tree); @Override void visitWhileStatement(WhileStatementTree tree); @Override void visitDoWhileStatement(DoWhileStatementTree tree); @Override void visitIfStatement(IfStatementTree tree); @Override void visitForStatement(ForStatementTree tree); @Override void visitForEachStatement(ForEachStatementTree tree); @Override void visitConditionalExpression(ConditionalExpressionTree tree); @Override void visitBinaryExpression(BinaryExpressionTree tree); @Override void visitMethodDeclaration(MethodDeclarationTree tree); @Override void visitFunctionDeclaration(FunctionDeclarationTree tree); @Override void visitFunctionExpression(FunctionExpressionTree tree); @Override void visitArrowFunctionExpression(ArrowFunctionExpressionTree tree); static int complexity(Tree tree); static List<Tree> complexityTrees(Tree tree); static List<Tree> complexityNodesWithoutNestedFunctions(Tree tree); }
ComplexityVisitor extends PHPVisitorCheck { public static int complexity(Tree tree) { return complexityTrees(tree).size(); }  @Override void visitCaseClause(CaseClauseTree tree); @Override void visitWhileStatement(WhileStatementTree tree); @Override void visitDoWhileStatement(DoWhileStatementTree tree); @Override void visitIfStatement(IfStatementTree tree); @Override void visitForStatement(ForStatementTree tree); @Override void visitForEachStatement(ForEachStatementTree tree); @Override void visitConditionalExpression(ConditionalExpressionTree tree); @Override void visitBinaryExpression(BinaryExpressionTree tree); @Override void visitMethodDeclaration(MethodDeclarationTree tree); @Override void visitFunctionDeclaration(FunctionDeclarationTree tree); @Override void visitFunctionExpression(FunctionExpressionTree tree); @Override void visitArrowFunctionExpression(ArrowFunctionExpressionTree tree); static int complexity(Tree tree); static List<Tree> complexityTrees(Tree tree); static List<Tree> complexityNodesWithoutNestedFunctions(Tree tree);  }