These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminBundle\Helper; |
||
4 | |||
5 | use Symfony\Component\DependencyInjection\ContainerInterface; |
||
6 | use Symfony\Component\HttpFoundation\RequestStack; |
||
7 | |||
8 | /** |
||
9 | * Class DomainConfiguration |
||
10 | * |
||
11 | * Default (single domain) configuration handling |
||
12 | */ |
||
13 | class DomainConfiguration implements DomainConfigurationInterface |
||
14 | { |
||
15 | /** @var ContainerInterface */ |
||
16 | protected $container; |
||
17 | |||
18 | /** @var RequestStack */ |
||
19 | private $requestStack; |
||
20 | |||
21 | /** @var bool */ |
||
22 | protected $multiLanguage; |
||
23 | |||
24 | /** @var array */ |
||
25 | protected $requiredLocales; |
||
26 | |||
27 | /** @var string */ |
||
28 | protected $defaultLocale; |
||
29 | |||
30 | /** |
||
31 | * @param ContainerInterface|string $multilanguage |
||
0 ignored issues
–
show
|
|||
32 | */ |
||
33 | View Code Duplication | public function __construct(/*ContainerInterface|RequestStack*/ $requestStack, $multilanguage = null, $defaultLocale = null, $requiredLocales = null) |
|
34 | { |
||
35 | if ($requestStack instanceof ContainerInterface) { |
||
36 | @trigger_error('Container injection and the usage of the container is deprecated in KunstmaanNodeBundle 5.1 and will be removed in KunstmaanNodeBundle 6.0.', E_USER_DEPRECATED); |
||
37 | |||
38 | $this->container = $requestStack; |
||
39 | $this->multiLanguage = $this->container->getParameter( |
||
40 | 'multilanguage' |
||
41 | ); |
||
42 | $this->defaultLocale = $this->container->getParameter( |
||
43 | 'defaultlocale' |
||
44 | ); |
||
45 | $this->requiredLocales = explode( |
||
46 | '|', |
||
47 | $this->container->getParameter('requiredlocales') |
||
48 | ); |
||
49 | $this->requestStack = $this->container->get('request_stack'); |
||
50 | |||
51 | return; |
||
52 | } |
||
53 | |||
54 | $this->requestStack = $requestStack; |
||
55 | $this->multiLanguage = $multilanguage; |
||
0 ignored issues
–
show
It seems like
$multilanguage can also be of type object<Symfony\Component...ion\ContainerInterface> or string . However, the property $multiLanguage is declared as type boolean . Maybe add an additional type check?
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 Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
Loading history...
|
|||
56 | $this->defaultLocale = $defaultLocale; |
||
57 | |||
58 | $this->requiredLocales = explode('|', $requiredLocales); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getHost() |
||
65 | { |
||
66 | $request = $this->getMasterRequest(); |
||
67 | $host = is_null($request) ? '' : $request->getHost(); |
||
68 | |||
69 | return $host; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return array |
||
74 | */ |
||
75 | public function getHosts() |
||
76 | { |
||
77 | return array($this->getHost()); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return string |
||
82 | */ |
||
83 | public function getDefaultLocale() |
||
84 | { |
||
85 | return $this->defaultLocale; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param string|null $host |
||
90 | * |
||
91 | * @return bool |
||
92 | */ |
||
93 | public function isMultiLanguage($host = null) |
||
94 | { |
||
95 | return $this->multiLanguage; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @param string|null $host |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | public function getFrontendLocales($host = null) |
||
104 | { |
||
105 | return $this->requiredLocales; |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * @param string|null $host |
||
110 | * |
||
111 | * @return array |
||
112 | */ |
||
113 | public function getBackendLocales($host = null) |
||
114 | { |
||
115 | return $this->requiredLocales; |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * @return bool |
||
120 | */ |
||
121 | public function isMultiDomainHost() |
||
122 | { |
||
123 | return false; |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * @param string|null $host |
||
128 | */ |
||
129 | public function getRootNode($host = null) |
||
130 | { |
||
131 | return null; |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * @return array |
||
136 | */ |
||
137 | public function getExtraData() |
||
138 | { |
||
139 | return array(); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * @return array |
||
144 | */ |
||
145 | public function getLocalesExtraData() |
||
146 | { |
||
147 | return array(); |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * @return null|\Symfony\Component\HttpFoundation\Request |
||
152 | */ |
||
153 | protected function getMasterRequest() |
||
154 | { |
||
155 | return $this->requestStack->getMasterRequest(); |
||
156 | } |
||
157 | |||
158 | /** |
||
159 | * @return array |
||
160 | */ |
||
161 | public function getFullHostConfig() |
||
162 | { |
||
163 | return array(); |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * @param string|null $host |
||
168 | */ |
||
169 | public function getFullHost($host = null) |
||
170 | { |
||
171 | return null; |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * @param int $id |
||
176 | */ |
||
177 | public function getFullHostById($id) |
||
178 | { |
||
179 | return null; |
||
180 | } |
||
181 | |||
182 | public function getHostSwitched() |
||
183 | { |
||
184 | return null; |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * @param string|null $host |
||
189 | */ |
||
190 | public function getHostBaseUrl($host = null) |
||
191 | { |
||
192 | return null; |
||
193 | } |
||
194 | } |
||
195 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.