Issues (21)

src/Chips/NamedKit.php (2 issues)

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
Bug Best Practice introduced by
The expression $segments of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

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.

Loading history...
26
            if (Scanner::CLIENTS_NAME === $pop = array_pop($segments)) {
0 ignored issues
show
The assignment to $pop is dead and can be removed.
Loading history...
27
                break;
28
            }
29
        }
30
31
        return implode('.', $segments);
32
    }
33
}
34