| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public static function createAttribute(string ...$args): string |
||
| 15 | { |
||
| 16 | $arglist = ''; |
||
| 17 | |||
| 18 | if ($args) { |
||
|
|
|||
| 19 | $arglist = sprintf( |
||
| 20 | '("%s")', |
||
| 21 | implode( |
||
| 22 | '", "', |
||
| 23 | array_map( |
||
| 24 | fn(string $arg) => addslashes(trim($arg)), |
||
| 25 | array_filter($args) |
||
| 26 | ) |
||
| 27 | ) |
||
| 28 | ); |
||
| 29 | } |
||
| 30 | |||
| 31 | return '#[\\' . get_called_class() . $arglist . ']'; |
||
| 32 | } |
||
| 34 |
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.