1 | <?php |
||
19 | class ApiUrl implements SourceAccessorInterface |
||
20 | { |
||
21 | |||
22 | use Traits\SourceMagic; |
||
23 | |||
24 | private static $sources = []; |
||
25 | private $dotName = ''; |
||
26 | private $source = ''; |
||
27 | |||
28 | public function __construct($className = null, $text = '') |
||
62 | |||
63 | /** |
||
64 | * Set root url of current project API. This can be relative or absolute url. |
||
65 | * |
||
66 | * Set url for many projects with namespaces - this allows cross-linking different projects: |
||
67 | * |
||
68 | * ``` |
||
69 | * ApiUrl::setRoot([ |
||
70 | * '/mangan/api' => 'Maslosoft\\Mangan\\' |
||
71 | * '/addendum/api' => 'Maslosoft\\Addendum\\' |
||
72 | * ]); |
||
73 | * ``` |
||
74 | * |
||
75 | * Could also be used for one project, but might result in wrong url if |
||
76 | * used on classes outside of project: |
||
77 | * |
||
78 | * ``` |
||
79 | * ApiUrl::setRoot('/mangan/api); |
||
80 | * ``` |
||
81 | * |
||
82 | * |
||
83 | * @param string $apiUrl |
||
84 | */ |
||
85 | public static function setRoot($apiUrl) |
||
105 | |||
106 | public function method($name) |
||
111 | |||
112 | public function property($name) |
||
117 | |||
118 | public static function __callStatic($name, $arguments) |
||
122 | |||
123 | public function __toString() |
||
127 | |||
128 | /** |
||
129 | * Ensure that name starts and ends with slash |
||
130 | * @param string $name |
||
131 | * @return string |
||
132 | */ |
||
133 | private static function normalize($name) |
||
137 | |||
138 | } |
||
139 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.