| Conditions | 4 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | 15 | public function pass(Expr\Array_ $expr, Context $context) |
|
| 22 | { |
||
| 23 | 15 | $result = false; |
|
| 24 | 15 | $keys = []; |
|
| 25 | |||
| 26 | /** @var Expr\ArrayItem $item */ |
||
| 27 | 15 | foreach ($expr->items as $item) { |
|
| 28 | 7 | if (!$item->key instanceof Scalar) { |
|
| 29 | 5 | continue; |
|
| 30 | } |
||
| 31 | |||
| 32 | 2 | $key = $item->key->value; |
|
|
|
|||
| 33 | |||
| 34 | 2 | if (isset($keys[$key])) { |
|
| 35 | 1 | $context->notice( |
|
| 36 | 1 | 'array.duplicate_keys', |
|
| 37 | 1 | sprintf('Duplicate array key "%s" in array definition (previously declared in line %d).', $key, $keys[$key]->getLine()), |
|
| 38 | $item |
||
| 39 | 1 | ); |
|
| 40 | |||
| 41 | 1 | $result = true; |
|
| 42 | 1 | } |
|
| 43 | |||
| 44 | 2 | $keys[$key] = $item; |
|
| 45 | 15 | } |
|
| 46 | |||
| 47 | 15 | return $result; |
|
| 48 | } |
||
| 49 | |||
| 73 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.