| @@ 9-45 (lines=37) @@ | ||
| 6 | use Automattic\Jetpack\Analyzer\Invocations\Static_Call; |
|
| 7 | use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? |
|
| 8 | ||
| 9 | class Class_Method_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 'method_moved'; |
|
| 29 | } |
|
| 30 | ||
| 31 | public function display_name() { |
|
| 32 | return $this->old_declaration->display_name(); |
|
| 33 | } |
|
| 34 | ||
| 35 | public function find_invocation_warnings( $invocation, $warnings ) { |
|
| 36 | if ( $invocation instanceof Static_Call ) { |
|
| 37 | // check if it's instantiating this missing class |
|
| 38 | if ( $invocation->class_name === $this->old_declaration->class_name |
|
| 39 | && $invocation->method_name === $this->old_declaration->method_name |
|
| 40 | && $this->old_declaration->static ) { |
|
| 41 | $warnings->add( new Warning( $this->type(), $invocation->path, $invocation->line, 'Class static method ' . $this->old_declaration->display_name() . ' was moved from ' . $this->old_declaration->path . ' to ' . $this->new_declaration->path, $this->old_declaration ) ); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| @@ 9-41 (lines=33) @@ | ||
| 6 | use Automattic\Jetpack\Analyzer\Invocations\Static_Property; |
|
| 7 | use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? |
|
| 8 | ||
| 9 | class Class_Property_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 'property_moved'; |
|
| 29 | } |
|
| 30 | ||
| 31 | public function find_invocation_warnings( $invocation, $warnings ) { |
|
| 32 | if ( $invocation instanceof Static_Property ) { |
|
| 33 | // check if it's using this missing property |
|
| 34 | if ( $invocation->class_name === $this->old_declaration->class_name |
|
| 35 | && $invocation->prop_name === $this->old_declaration->prop_name |
|
| 36 | && $this->old_declaration->static ) { |
|
| 37 | $warnings->add( new Warning( $this->type(), $invocation->path, $invocation->line, 'Class static property ' . $this->old_declaration->display_name() . ' was moved from ' . $this->old_declaration->path . ' to ' . $this->new_declaration->path, $this->old_declaration ) ); |
|
| 38 | } |
|
| 39 | } |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||