Completed
Push — fix/12791-track-upgrade ( 62035b...97a755 )
by
unknown
26:48 queued 17:41
created

Class_Moved   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A to_csv_array() 0 8 1
A type() 0 3 1
A find_invocation_warnings() 0 7 2
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_Moved extends PersistentListItem implements Invocation_Warner {
10
	public $old_declaration;
11
	public $new_declaration;
12
13
	function __construct( $old_declaration, $new_declaration ) {
14
		$this->old_declaration = $old_declaration;
15
		$this->new_declaration = $new_declaration;
16
	}
17
18
	function to_csv_array() {
19
		return array(
20
			$this->type(),
21
			$this->old_declaration->path,
22
			$this->old_declaration->line,
23
			$this->old_declaration->display_name(),
24
		);
25
	}
26
27
	public function type() {
28
		return 'class_moved';
29
	}
30
31
	public function find_invocation_warnings( $invocation, $warnings ) {
32
		if ( $invocation->depends_on( $this->declaration ) ) {
0 ignored issues
show
Bug introduced by
The property declaration does not seem to exist. Did you mean old_declaration?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
33
			$warnings->add(
34
				new Warning( $this->type(), $invocation->path, $invocation->line, 'Class ' . $this->old_declaration->display_name() . ' was moved from ' . $this->old_declaration->path . ' to ' . $this->new_declaration->path, $this->old_declaration )
35
			);
36
		}
37
	}
38
}
39