Completed
Push — try/code-signature-diff ( 4ac422...584f2d )
by
unknown
218:12 queued 209:34
created

Class_Missing::find_invocation_warnings()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 2
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace Automattic\Jetpack\Analyzer\Differences;
4
5
use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem;
6
use Automattic\Jetpack\Analyzer\Invocations\New_;
7
use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses?
8
9
class Class_Missing extends PersistentListItem implements Invocation_Warner {
10
	public $declaration;
11
	public $class_name;
12
13
	function __construct( $declaration ) {
14
		$this->declaration = $declaration;
15
		$this->class_name = $declaration->class_name;
16
	}
17
18
	function to_csv_array() {
19
		return array(
20
			$this->type(),
21
			$this->declaration->path,
22
			$this->declaration->line,
23
			$this->declaration->display_name()
24
		);
25
	}
26
27
	public function type() {
28
		return 'missing';
29
	}
30
31
	public function find_invocation_warnings( $invocation, $warnings ) {
32
		if ( $invocation instanceof New_ ) {
33
			// check if it's instantiating this missing class
34
			echo "Checking " . $invocation->class_name . " matches " . $this->declaration->class_name . "\n";
35
			if ( $invocation->class_name === $this->class_name ) {
36
				$warnings->add( new Warning( $invocation->path, $invocation->line, "Class " . $this->declaration->class_name . " is missing") );
37
			}
38
		}
39
	}
40
}