carno-php /
rpc
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Named kit |
||
| 4 | * User: moyo |
||
| 5 | * Date: 30/10/2017 |
||
| 6 | * Time: 10:51 AM |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace Carno\RPC\Chips; |
||
| 10 | |||
| 11 | use Carno\RPC\Service\Scanner; |
||
| 12 | |||
| 13 | trait NamedKit |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @param string $class |
||
| 17 | * @return string |
||
| 18 | */ |
||
| 19 | private function namedServer(string $class) : string |
||
| 20 | { |
||
| 21 | $segments = array_map(static function ($p) { |
||
| 22 | return lcfirst($p); |
||
| 23 | }, explode('\\', $class)); |
||
| 24 | |||
| 25 | while ($segments) { |
||
|
0 ignored issues
–
show
|
|||
| 26 | if (Scanner::CLIENTS_NAME === $pop = array_pop($segments)) { |
||
|
0 ignored issues
–
show
|
|||
| 27 | break; |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | return implode('.', $segments); |
||
| 32 | } |
||
| 33 | } |
||
| 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.