@@ 9-43 (lines=35) @@ | ||
6 | use Automattic\Jetpack\Analyzer\Invocations\Static_Call; |
|
7 | use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? |
|
8 | ||
9 | class Class_Method_Missing extends PersistentListItem implements Invocation_Warner { |
|
10 | public $declaration; |
|
11 | ||
12 | function __construct( $declaration ) { |
|
13 | $this->declaration = $declaration; |
|
14 | } |
|
15 | ||
16 | function to_csv_array() { |
|
17 | return array( |
|
18 | $this->type(), |
|
19 | $this->declaration->path, |
|
20 | $this->declaration->line, |
|
21 | $this->declaration->display_name(), |
|
22 | ); |
|
23 | } |
|
24 | ||
25 | public function type() { |
|
26 | return 'method_missing'; |
|
27 | } |
|
28 | ||
29 | public function display_name() { |
|
30 | return $this->declaration->display_name(); |
|
31 | } |
|
32 | ||
33 | public function find_invocation_warnings( $invocation, $warnings ) { |
|
34 | if ( $invocation instanceof Static_Call ) { |
|
35 | // check if it's instantiating this missing class |
|
36 | if ( $invocation->class_name === $this->declaration->class_name |
|
37 | && $invocation->method_name === $this->declaration->method_name |
|
38 | && $this->declaration->static ) { |
|
39 | $warnings->add( new Warning( $this->type(), $invocation->path, $invocation->line, 'Class static method ' . $this->declaration->display_name() . ' is missing', $this->declaration ) ); |
|
40 | } |
|
41 | } |
|
42 | } |
|
43 | } |
|
44 |
@@ 9-39 (lines=31) @@ | ||
6 | use Automattic\Jetpack\Analyzer\Invocations\Static_Property; |
|
7 | use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? |
|
8 | ||
9 | class Class_Property_Missing extends PersistentListItem implements Invocation_Warner { |
|
10 | public $declaration; |
|
11 | ||
12 | function __construct( $declaration ) { |
|
13 | $this->declaration = $declaration; |
|
14 | } |
|
15 | ||
16 | function to_csv_array() { |
|
17 | return array( |
|
18 | $this->type(), |
|
19 | $this->declaration->path, |
|
20 | $this->declaration->line, |
|
21 | $this->declaration->display_name(), |
|
22 | ); |
|
23 | } |
|
24 | ||
25 | public function type() { |
|
26 | return 'property_missing'; |
|
27 | } |
|
28 | ||
29 | public function find_invocation_warnings( $invocation, $warnings ) { |
|
30 | if ( $invocation instanceof Static_Property ) { |
|
31 | // check if it's using this missing property |
|
32 | if ( $invocation->class_name === $this->declaration->class_name |
|
33 | && $invocation->prop_name === $this->declaration->prop_name |
|
34 | && $this->declaration->static ) { |
|
35 | $warnings->add( new Warning( $this->type(), $invocation->path, $invocation->line, 'Class static property ' . $this->declaration->display_name() . ' is missing', $this->declaration ) ); |
|
36 | } |
|
37 | } |
|
38 | } |
|
39 | } |
|
40 |
@@ 9-37 (lines=29) @@ | ||
6 | use Automattic\Jetpack\Analyzer\Invocations\Static_Const; |
|
7 | use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? |
|
8 | ||
9 | class Class_Const_Missing extends PersistentListItem implements Invocation_Warner { |
|
10 | public $declaration; |
|
11 | ||
12 | function __construct( $declaration ) { |
|
13 | $this->declaration = $declaration; |
|
14 | } |
|
15 | ||
16 | function to_csv_array() { |
|
17 | return array( |
|
18 | $this->type(), |
|
19 | $this->declaration->path, |
|
20 | $this->declaration->line, |
|
21 | $this->declaration->display_name(), |
|
22 | ); |
|
23 | } |
|
24 | ||
25 | public function type() { |
|
26 | return 'class_const_missing'; |
|
27 | } |
|
28 | ||
29 | public function find_invocation_warnings( $invocation, $warnings ) { |
|
30 | if ( $invocation instanceof Static_Const ) { |
|
31 | if ( $invocation->class_name === $this->declaration->class_name |
|
32 | && $invocation->const_name === $this->declaration->const_name) { |
|
33 | $warnings->add( new Warning( $this->type(), $invocation->path, $invocation->line, 'Class constant ' . $this->declaration->display_name() . ' is missing', $this->declaration ) ); |
|
34 | } |
|
35 | } |
|
36 | } |
|
37 | } |
|
38 |