| Conditions | 10 | 
| Paths | 7 | 
| Total Lines | 67 | 
| Lines | 0 | 
| Ratio | 0 % | 
| 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  | 
            ||
| 51 | public function __construct($twigOrName, ?object $poolOrTemplating, object $searchHandlerOrPool, ?SearchHandler $searchHandler = null)  | 
            ||
| 52 |     { | 
            ||
| 53 |         if ($poolOrTemplating instanceof Pool) { | 
            ||
| 54 |             if (!$twigOrName instanceof Environment) { | 
            ||
| 55 | throw new \TypeError(sprintf(  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 56 | 'Argument 1 passed to %s() must be an instance of %s, %s given.',  | 
            ||
| 57 | __METHOD__,  | 
            ||
| 58 | Environment::class,  | 
            ||
| 59 | \is_object($twigOrName) ? 'instance of '.\get_class($twigOrName) : \gettype($twigOrName)  | 
            ||
| 60 | ));  | 
            ||
| 61 | }  | 
            ||
| 62 | |||
| 63 |             if (!$searchHandlerOrPool instanceof SearchHandler) { | 
            ||
| 64 | throw new \TypeError(sprintf(  | 
            ||
| 65 | 'Argument 3 passed to %s() must be an instance of %s, instance of %s given.',  | 
            ||
| 66 | __METHOD__,  | 
            ||
| 67 | SearchHandler::class,  | 
            ||
| 68 | \get_class($twigOrName)  | 
            ||
| 69 | ));  | 
            ||
| 70 | }  | 
            ||
| 71 | |||
| 72 | parent::__construct($twigOrName);  | 
            ||
| 73 | |||
| 74 | $this->pool = $poolOrTemplating;  | 
            ||
| 75 | $this->searchHandler = $searchHandlerOrPool;  | 
            ||
| 76 |         } elseif (null === $poolOrTemplating || $poolOrTemplating instanceof EngineInterface) { | 
            ||
| 77 | @trigger_error(sprintf(  | 
            ||
| 78 | 'Passing %s as argument 2 to %s() is deprecated since sonata-project/admin-bundle 3.x'  | 
            ||
| 79 | .' and will throw a \TypeError in version 4.0. You must pass an instance of %s instead.',  | 
            ||
| 80 | null === $poolOrTemplating ? 'null' : EngineInterface::class,  | 
            ||
| 81 | __METHOD__,  | 
            ||
| 82 | Pool::class  | 
            ||
| 83 | ), E_USER_DEPRECATED);  | 
            ||
| 84 | |||
| 85 |             if (!$searchHandlerOrPool instanceof Pool) { | 
            ||
| 86 | throw new \TypeError(sprintf(  | 
            ||
| 87 | 'Argument 2 passed to %s() must be an instance of %s, instance of %s given.',  | 
            ||
| 88 | __METHOD__,  | 
            ||
| 89 | Pool::class,  | 
            ||
| 90 | \get_class($twigOrName)  | 
            ||
| 91 | ));  | 
            ||
| 92 | }  | 
            ||
| 93 | |||
| 94 |             if (null === $searchHandler) { | 
            ||
| 95 | throw new \TypeError(sprintf(  | 
            ||
| 96 | 'Passing null as argument 3 to %s() is not allowed when %s is passed as argument 2.'  | 
            ||
| 97 | .' You must pass an instance of %s instead.',  | 
            ||
| 98 | __METHOD__,  | 
            ||
| 99 | EngineInterface::class,  | 
            ||
| 100 | SearchHandler::class  | 
            ||
| 101 | ));  | 
            ||
| 102 | }  | 
            ||
| 103 | |||
| 104 | parent::__construct($twigOrName, $poolOrTemplating);  | 
            ||
| 105 | |||
| 106 | $this->pool = $searchHandlerOrPool;  | 
            ||
| 107 | $this->searchHandler = $searchHandler;  | 
            ||
| 108 |         } else { | 
            ||
| 109 | throw new \TypeError(sprintf(  | 
            ||
| 110 | 'Argument 2 passed to %s() must be either null or an instance of %s or preferably %s, instance of %s given.',  | 
            ||
| 111 | __METHOD__,  | 
            ||
| 112 | EngineInterface::class,  | 
            ||
| 113 | Pool::class,  | 
            ||
| 114 | \get_class($poolOrTemplating)  | 
            ||
| 115 | ));  | 
            ||
| 116 | }  | 
            ||
| 117 | }  | 
            ||
| 118 | |||
| 174 | 
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.