| Conditions | 8 |
| Paths | 17 |
| Total Lines | 41 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 3 |
| CRAP Score | 47.3039 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 2 | public function parse(&$variable) |
|
| 19 | { |
||
| 20 | 2 | if (!$variable instanceof \Closure) { |
|
| 21 | 2 | return false; |
|
| 22 | } |
||
| 23 | |||
| 24 | $this->name = 'Closure'; |
||
| 25 | $reflection = new \ReflectionFunction($variable); |
||
| 26 | $ret = array( |
||
| 27 | 'Parameters' => array(), |
||
| 28 | ); |
||
| 29 | |||
| 30 | $val = $reflection->getParameters(); |
||
| 31 | if ($val) { |
||
|
|
|||
| 32 | foreach ($val as $parameter) { |
||
| 33 | // todo http://php.net/manual/en/class.reflectionparameter.php |
||
| 34 | $ret['Parameters'][] = $parameter->name; |
||
| 35 | } |
||
| 36 | |||
| 37 | } |
||
| 38 | |||
| 39 | $val = $reflection->getStaticVariables(); |
||
| 40 | if ($val) { |
||
| 41 | $ret['Uses'] = $val; |
||
| 42 | } |
||
| 43 | |||
| 44 | if ( |
||
| 45 | method_exists($reflection, 'getClousureThis') |
||
| 46 | && |
||
| 47 | $val = $reflection->getClosureThis() |
||
| 48 | ) { |
||
| 49 | $ret['Uses']['$this'] = $val; |
||
| 50 | } |
||
| 51 | |||
| 52 | $val = $reflection->getFileName(); |
||
| 53 | if ($val) { |
||
| 54 | $this->value = Kint::shortenPath($val) . ':' . $reflection->getStartLine(); |
||
| 55 | } |
||
| 56 | |||
| 57 | return $ret; |
||
| 58 | } |
||
| 59 | } |
||
| 60 |
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.