Completed
Push — renovate/glob-7.x ( 697d78...f7fc07 )
by
unknown
18:21 queued 12:01
created

Visitor::enterNode()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
nc 7
nop 1
dl 0
loc 31
rs 8.4906
c 0
b 0
f 0
1
<?php
2
3
namespace Automattic\Jetpack\Analyzer\Invocations;
4
5
use PhpParser\NodeVisitorAbstract;
6
use PhpParser\Node;
7
use Automattic\Jetpack\Analyzer\Utils;
8
9
class Visitor extends NodeVisitorAbstract {
10
	private $invocations;
11
	private $file_path;
12
13
	public function __construct( $file_path, $invocations ) {
14
		$this->file_path   = $file_path;
15
		$this->invocations = $invocations;
16
	}
17
18
	public function enterNode( Node $node ) {
19
		if ( $node instanceof Node\Expr\New_ ) {
0 ignored issues
show
Bug introduced by
The class PhpParser\Node\Expr\New_ does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
20
			$this->invocations->add(
21
				new New_( $this->file_path, $node->getLine(), Utils::node_to_class_name( $node->class ) )
22
			);
23
		} elseif ( $node instanceof Node\Expr\StaticCall ) {
0 ignored issues
show
Bug introduced by
The class PhpParser\Node\Expr\StaticCall does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
24
			// TODO - args
25
			$this->invocations->add(
26
				new Static_Call( $this->file_path, $node->getLine(), Utils::node_to_class_name( $node->class ), $node->name->name )
27
			);
28
		} elseif ( $node instanceof Node\Expr\StaticPropertyFetch ) {
0 ignored issues
show
Bug introduced by
The class PhpParser\Node\Expr\StaticPropertyFetch does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
29
			$this->invocations->add(
30
				new Static_Property( $this->file_path, $node->getLine(), Utils::node_to_class_name( $node->class ), $node->name->name )
31
			);
32
		} elseif ( $node instanceof Node\Expr\FuncCall ) {
0 ignored issues
show
Bug introduced by
The class PhpParser\Node\Expr\FuncCall does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
33
			// TODO - args
34
			if ( $node->name instanceof Node\Expr\Variable ) {
0 ignored issues
show
Bug introduced by
The class PhpParser\Node\Expr\Variable does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
35
				$function_name = '$' . Utils::maybe_stringify( $node->name->name );
36
			} else {
37
				$function_name = implode( '\\', $node->name->parts );
38
			}
39
40
			$this->invocations->add( new Function_Call( $this->file_path, $node->getLine(), $function_name ) );
41
		} elseif ( $node instanceof Node\Expr\ClassConstFetch ) {
0 ignored issues
show
Bug introduced by
The class PhpParser\Node\Expr\ClassConstFetch does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
42
			$this->invocations->add(
43
				new Static_Const( $this->file_path, $node->getLine(), Utils::node_to_class_name( $node->class ), $node->name->name )
44
			);
45
		} else {
46
			// print_r( $node );
47
		}
48
	}
49
50
	public function leaveNode( Node $node ) {
51
	}
52
}
53