Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3.1707 |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
11 | 13 | protected function generateParamDocblock() { |
|
12 | 13 | $docblock = $this->getDocblock(); |
|
|
|||
13 | 13 | $tags = $docblock->getTags('param'); |
|
14 | 13 | foreach ($this->parameters as $param) { |
|
15 | 6 | $ptag = $param->getDocblockTag(); |
|
16 | |||
17 | 6 | $tag = $tags->find($ptag, function(ParamTag $tag, ParamTag $ptag) { |
|
18 | return $tag->getVariable() == $ptag->getVariable(); |
||
19 | 6 | }); |
|
20 | |||
21 | // try to update existing docblock first |
||
22 | 6 | if ($tag !== null) { |
|
23 | $tag->setDescription($ptag->getDescription()); |
||
24 | $tag->setType($ptag->getType()); |
||
25 | } |
||
26 | |||
27 | // ... append if it doesn't exist |
||
28 | else { |
||
29 | 6 | $docblock->appendTag($ptag); |
|
30 | } |
||
31 | 13 | } |
|
32 | } |
||
33 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.