DamienHarper /
adf-tools
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace DH\Adf\Node\Inline; |
||
| 6 | |||
| 7 | use DH\Adf\Node\InlineNode; |
||
| 8 | |||
| 9 | class Extension extends InlineNode |
||
| 10 | { |
||
| 11 | protected string $type = 'extension'; |
||
| 12 | private string $layout; |
||
| 13 | private string $extensionType; |
||
| 14 | private string $extensionKey; |
||
| 15 | private array $parameters; |
||
| 16 | private string $localId; |
||
| 17 | |||
| 18 | public function __construct( |
||
| 19 | string $layout, |
||
| 20 | string $extensionType, |
||
| 21 | string $extensionKey, |
||
| 22 | array $parameters, |
||
| 23 | string $localId |
||
| 24 | ) { |
||
| 25 | $this->layout = $layout; |
||
| 26 | $this->extensionType = $extensionType; |
||
| 27 | $this->extensionKey = $extensionKey; |
||
| 28 | $this->parameters = $parameters; |
||
| 29 | $this->localId = $localId; |
||
| 30 | } |
||
| 31 | |||
| 32 | protected function attrs(): array |
||
| 33 | { |
||
| 34 | $attrs = parent::attrs(); |
||
| 35 | $attrs['layout'] = $this->layout; |
||
| 36 | $attrs['extensionType'] = $this->extensionType; |
||
| 37 | $attrs['extensionKey'] = $this->extensionKey; |
||
| 38 | if ($this->parameters) { |
||
|
0 ignored issues
–
show
|
|||
| 39 | $attrs['parameters'] = $this->parameters; |
||
| 40 | } |
||
| 41 | $attrs['localId'] = $this->localId; |
||
| 42 | |||
| 43 | return $attrs; |
||
| 44 | } |
||
| 45 | } |
||
| 46 |
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.