| Conditions | 9 | 
| Paths | 46 | 
| Total Lines | 52 | 
| Lines | 16 | 
| Ratio | 30.77 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName  | 
            ||
| 23 | 	public static function callback( Event $event ) { | 
            ||
| 24 | $arguments = $event->getArguments();  | 
            ||
| 25 | $scan_path = isset( $arguments[0] ) ? $arguments[0] : null;  | 
            ||
| 26 | $io = $event->getIO();  | 
            ||
| 27 | |||
| 28 | 		if ( is_null( $scan_path ) ) { | 
            ||
| 29 | $io->writeError( 'WordPress Core path is required for this script to work. Pass it as the argument.' );  | 
            ||
| 30 | return;  | 
            ||
| 31 | }  | 
            ||
| 32 | |||
| 33 | $io->write( "Find invocations\n" );  | 
            ||
| 34 | |||
| 35 | 		try { | 
            ||
| 36 | $declarations = self::get_declarations( $scan_path );  | 
            ||
| 37 | 			foreach ( $declarations->get() as $declaration ) { | 
            ||
| 38 | |||
| 39 | 				if ( $declaration instanceof Declarations\Function_ ) { | 
            ||
| 40 | |||
| 41 | $io->write(  | 
            ||
| 42 | $declaration->func_name . ', ' .  | 
            ||
| 43 | $declaration->path . ', ' .  | 
            ||
| 44 | $declaration->line  | 
            ||
| 45 | );  | 
            ||
| 46 | View Code Duplication | 				} elseif ( $declaration instanceof Declarations\Class_Property ) { | 
            |
| 47 | |||
| 48 | $io->write(  | 
            ||
| 49 | $declaration->class_name . '::' . $declaration->prop_name . ', ' .  | 
            ||
| 50 | $declaration->path . ', ' .  | 
            ||
| 51 | $declaration->line  | 
            ||
| 52 | );  | 
            ||
| 53 | 				} elseif ( $declaration instanceof Declarations\Class_Method ) { | 
            ||
| 54 | |||
| 55 | $io->write(  | 
            ||
| 56 | $declaration->class_name . '::' . $declaration->method_name . ', ' .  | 
            ||
| 57 | $declaration->path . ', ' .  | 
            ||
| 58 | $declaration->line  | 
            ||
| 59 | );  | 
            ||
| 60 | View Code Duplication | 				} elseif ( $declaration instanceof Declarations\Class_Const ) { | 
            |
| 61 | |||
| 62 | $io->write(  | 
            ||
| 63 | $declaration->class_name . '::' . $declaration->const_name . ', ' .  | 
            ||
| 64 | $declaration->path . ', ' .  | 
            ||
| 65 | $declaration->line  | 
            ||
| 66 | );  | 
            ||
| 67 | }  | 
            ||
| 68 | }  | 
            ||
| 69 | 		} catch ( Exception $e ) { | 
            ||
| 70 | $io->writeError( 'Exception caught' );  | 
            ||
| 71 | $io->writeError( $e->getMessage() );  | 
            ||
| 72 | return;  | 
            ||
| 73 | }  | 
            ||
| 74 | }  | 
            ||
| 75 | |||
| 130 | 
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.