Conditions | 6 |
Paths | 7 |
Total Lines | 30 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 7.0986 |
Changes | 0 |
1 | <?php |
||
23 | 4 | public function resolve(Reference $reference, Scope $scope) : string |
|
24 | { |
||
25 | 4 | $identifier = $reference->getIdentifier(); |
|
26 | 4 | $imports = $scope->getImports(); |
|
27 | |||
28 | 4 | if ($reference->isFullyQualified()) { |
|
29 | return $identifier; |
||
30 | } |
||
31 | |||
32 | 4 | $identifierLower = strtolower($identifier); |
|
33 | |||
34 | 4 | if (isset($imports[$identifierLower])) { |
|
35 | 1 | return $imports[$identifierLower]; |
|
36 | } |
||
37 | |||
38 | 3 | if (strpos($identifierLower, '\\') !== false) { |
|
39 | $namespacePart = explode('\\', $identifierLower, 2)[0]; |
||
40 | |||
41 | if (isset($imports[$namespacePart])) { |
||
42 | return $imports[$namespacePart] . '\\' . explode('\\', $identifier, 2)[1]; |
||
43 | } |
||
44 | } |
||
45 | |||
46 | 3 | $namespace = $this->getSubjectNamespaceName($scope->getSubject()); |
|
47 | |||
48 | 3 | if ($namespace === '') { |
|
49 | 3 | return $identifier; |
|
50 | } |
||
51 | |||
52 | return $namespace . '\\' . $identifier; |
||
53 | } |
||
68 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: