| @@ 9-40 (lines=32) @@ | ||
| 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 instanceof New_ ) { | |
| 33 | // check if it's instantiating this missing class | |
| 34 | // echo "Checking " . $invocation->class_name . " matches " . $this->old_declaration->class_name . "\n"; | |
| 35 | 			if ( $invocation->class_name === $this->old_declaration->class_name ) { | |
| 36 | $warnings->add( 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 ) ); | |
| 37 | } | |
| 38 | } | |
| 39 | } | |
| 40 | } | |
| 41 | ||
| @@ 9-43 (lines=35) @@ | ||
| 6 | use Automattic\Jetpack\Analyzer\Invocations\Function_Call; | |
| 7 | use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses? | |
| 8 | ||
| 9 | class Function_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 'function_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 Function_Call ) { | |
| 37 | // check if it's instantiating this missing class | |
| 38 | 			if ( $invocation->func_name === $this->old_declaration->func_name ) { | |
| 39 | $warnings->add( new Warning( $this->type(), $invocation->path, $invocation->line, 'Function ' . $this->old_declaration->display_name() . ' was moved from ' . $this->old_declaration->path . ' to ' . $this->new_declaration->path, $this->old_declaration ) ); | |
| 40 | } | |
| 41 | } | |
| 42 | } | |
| 43 | } | |
| 44 | ||