| @@ 9-38 (lines=30) @@ | ||
| 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 | ||
| 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_missing'; |
|
| 27 | } |
|
| 28 | ||
| 29 | public function find_invocation_warnings( $invocation, $warnings ) { |
|
| 30 | if ( $invocation instanceof New_ ) { |
|
| 31 | // check if it's instantiating this missing class |
|
| 32 | // echo "Checking " . $invocation->class_name . " matches " . $this->declaration->class_name . "\n"; |
|
| 33 | if ( $invocation->class_name === $this->declaration->class_name ) { |
|
| 34 | $warnings->add( new Warning( $invocation->path, $invocation->line, "Class " . $this->declaration->display_name() . " is missing") ); |
|
| 35 | } |
|
| 36 | } |
|
| 37 | } |
|
| 38 | } |
|
| @@ 9-40 (lines=32) @@ | ||
| 6 | use Automattic\Jetpack\Analyzer\Invocations\New_; |
|
| 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 'method_missing'; |
|
| 27 | } |
|
| 28 | ||
| 29 | public function find_invocation_warnings( $invocation, $warnings ) { |
|
| 30 | if ( $invocation instanceof New_ ) { |
|
| 31 | // check if it's instantiating this missing class |
|
| 32 | // echo "Checking " . $invocation->class_name . " matches " . $this->declaration->class_name . "\n"; |
|
| 33 | // echo "... and " . $invocation->method_name . " matches " . $this->declaration->name . ", and invocation is static\n"; |
|
| 34 | if ( $invocation->class_name === $this->declaration->class_name |
|
| 35 | && $this->declaration->static ) { |
|
| 36 | $warnings->add( new Warning( $invocation->path, $invocation->line, "Class static property" . $this->declaration->display_name() . " is missing") ); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | } |
|
| 40 | } |
|