| Conditions | 12 |
| Paths | 23 |
| Total Lines | 41 |
| Code Lines | 28 |
| Lines | 11 |
| Ratio | 26.83 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 21 | public function getEntries(Project $project, Context $context) |
||
| 22 | { |
||
| 23 | /** @var FQCN $fqcn */ |
||
| 24 | list($fqcn, $isThis) = $context->getData(); |
||
| 25 | $this->logger->debug('creating static entries'); |
||
| 26 | if (!$fqcn instanceof FQCN) { |
||
| 27 | return []; |
||
| 28 | } |
||
| 29 | $index = $project->getIndex(); |
||
| 30 | $this->logger->debug('Creating completion for ' . $fqcn->toString()); |
||
| 31 | $class = $index->findClassByFQCN($fqcn); |
||
| 32 | if (empty($class)) { |
||
| 33 | $class = $index->findInterfaceByFQCN($fqcn); |
||
| 34 | } |
||
| 35 | if (empty($class)) { |
||
| 36 | return []; |
||
| 37 | } |
||
| 38 | $entries = []; |
||
| 39 | $spec = new Specification($isThis ? 'private' : 'public', 1); |
||
|
|
|||
| 40 | View Code Duplication | if ($class->methods !== null) { |
|
| 41 | foreach ($class->methods->all($spec) as $method) { |
||
| 42 | $entry = $this->createEntryForMethod($method); |
||
| 43 | $entries[$method->name] = $entry; |
||
| 44 | } |
||
| 45 | } |
||
| 46 | if ($class instanceof InterfaceData) { |
||
| 47 | return $entries; |
||
| 48 | } |
||
| 49 | View Code Duplication | if ($class->properties !== null) { |
|
| 50 | foreach ($class->properties->all($spec) as $property) { |
||
| 51 | $entries[$property->name] = $this->createEntryForProperty($property); |
||
| 52 | } |
||
| 53 | } |
||
| 54 | if ($class->constants !== null) { |
||
| 55 | foreach ($class->constants->all() as $const) { |
||
| 56 | $entries[$const] = $this->createEntryForConst($const); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | ksort($entries); |
||
| 60 | return $entries; |
||
| 61 | } |
||
| 62 | |||
| 100 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: