| Conditions | 5 |
| Paths | 7 |
| Total Lines | 27 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5.246 |
| Changes | 0 | ||
| 1 | <?php declare (strict_types = 1); |
||
| 17 | 2 | public function fix(NodeSearch $nodeSearch): bool |
|
| 18 | { |
||
| 19 | 2 | $found = false; |
|
| 20 | |||
| 21 | 2 | foreach ($nodeSearch->eachType(Declare_::class) as $declareNode) { |
|
| 22 | 2 | $newDeclares = []; |
|
| 23 | |||
| 24 | /** @var DeclareDeclare $declareStatement */ |
||
| 25 | 2 | foreach ($declareNode->declares as $declareStatement) { |
|
| 26 | 2 | if ($declareStatement->key === 'strict_types') { |
|
| 27 | 2 | $found = true; |
|
| 28 | 2 | continue; |
|
| 29 | } |
||
| 30 | |||
| 31 | $newDeclares[] = $declareNode; |
||
| 32 | } |
||
| 33 | |||
| 34 | 2 | if ($newDeclares) { |
|
|
1 ignored issue
–
show
|
|||
| 35 | $declareNode->declares = $newDeclares; |
||
| 36 | continue; |
||
| 37 | } |
||
| 38 | |||
| 39 | 2 | $nodeSearch->removeNode($declareNode); |
|
| 40 | } |
||
| 41 | |||
| 42 | 2 | return $found; |
|
| 43 | } |
||
| 44 | } |
||
| 45 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.