1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Fi\CoreBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\HttpFoundation\Request; |
6
|
|
|
use Symfony\Component\HttpFoundation\Response; |
7
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
8
|
|
|
use Fi\CoreBundle\Entity\Tabelle; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Tabelle controller. |
12
|
|
|
*/ |
13
|
|
|
class TabelleController extends FiCoreController |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
public function aggiornaAction(Request $request) |
17
|
|
|
{ |
18
|
|
|
if ($request->get('oper') == 'edit') { |
19
|
|
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
20
|
|
|
$operatore = $gestionepermessi->utentecorrente(); |
21
|
|
|
|
22
|
|
|
$id = $request->get('id'); |
23
|
|
|
|
24
|
|
|
$em = $this->getDoctrine()->getManager(); |
25
|
|
|
$tabelle = $em->getRepository('FiCoreBundle:Tabelle')->find($id); |
26
|
|
|
$tabelle->setOperatoriId($operatore['id']); |
27
|
|
|
$nometabella = $this->getRequestValue($request, 'nometabella'); |
28
|
|
|
if ($nometabella) { |
29
|
|
|
$tabelle->setNometabella($nometabella); |
30
|
|
|
} |
31
|
|
|
$nomecampo = $this->getRequestValue($request, 'nomecampo'); |
32
|
|
|
if ($nomecampo) { |
33
|
|
|
$tabelle->setNomecampo($nomecampo); |
34
|
|
|
} |
35
|
|
|
$mostraindex = $this->getRequestValue($request, 'mostraindex'); |
36
|
|
|
$tabelle->setMostraindex($mostraindex); |
37
|
|
|
$ordineindex = $this->getRequestValue($request, 'ordineindex'); |
38
|
|
|
$tabelle->setOrdineindex($ordineindex); |
39
|
|
|
$etichettaindex = $this->getRequestValue($request, 'etichettaindex'); |
40
|
|
|
$tabelle->setEtichettaindex($etichettaindex); |
41
|
|
|
|
42
|
|
|
$larghezzaindex = $this->getRequestValue($request, 'larghezzaindex'); |
43
|
|
|
$tabelle->setLarghezzaindex($larghezzaindex); |
44
|
|
|
|
45
|
|
|
$mostrastampa = $this->getRequestValue($request, 'mostrastampa'); |
46
|
|
|
$tabelle->setMostrastampa($mostrastampa); |
47
|
|
|
|
48
|
|
|
$ordinestampa = $this->getRequestValue($request, 'ordinestampa'); |
49
|
|
|
$tabelle->setOrdinestampa($ordinestampa); |
50
|
|
|
|
51
|
|
|
$etichettastampa = $this->getRequestValue($request, 'etichettastampa'); |
52
|
|
|
$tabelle->setEtichettastampa($etichettastampa); |
53
|
|
|
|
54
|
|
|
$larghezzastampa = $this->getRequestValue($request, 'larghezzastampa'); |
55
|
|
|
$tabelle->setLarghezzastampa($larghezzastampa); |
56
|
|
|
$em->persist($tabelle); |
|
|
|
|
57
|
|
|
$em->flush(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return new Response('OK'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
private function getRequestValue($request, $attribute) |
64
|
|
|
{ |
65
|
|
|
if (($request->get($attribute) !== null) && ($request->get($attribute) !== '')) { |
66
|
|
|
return $request->get($attribute); |
67
|
|
|
} else { |
68
|
|
|
return null; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
1 |
|
public function configuraAction(Request $request, $nometabella) |
73
|
|
|
{ |
74
|
1 |
|
$this->setup($request); |
75
|
1 |
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
76
|
1 |
|
$operatore = $gestionepermessi->utentecorrente(); |
77
|
1 |
|
$this->generaDB(array('tabella' => $nometabella), $request); |
78
|
1 |
|
$this->generaDB(array('tabella' => $nometabella, 'operatore' => $operatore['id']), $request); |
79
|
|
|
|
80
|
1 |
|
$namespace = $this->getNamespace(); |
81
|
1 |
|
$bundle = $this->getBundle(); |
82
|
1 |
|
$controller = $this->getController(); |
83
|
1 |
|
$container = $this->container; |
84
|
|
|
|
85
|
1 |
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
86
|
|
|
|
87
|
1 |
|
$em = $this->getDoctrine()->getManager(); |
88
|
1 |
|
$entities = $em->getRepository($nomebundle . ':' . $controller)->findAll(); |
89
|
|
|
|
90
|
|
|
$dettaglij = array( |
91
|
1 |
|
'nomecampo' => array( |
92
|
|
|
array('nomecampo' => 'nomecampo', 'lunghezza' => '150', 'descrizione' => 'Campo', 'tipo' => 'text', 'editable' => false),), |
93
|
|
|
'mostraindex' => array( |
94
|
|
|
array('nomecampo' => 'mostraindex', 'lunghezza' => '100', 'descrizione' => 'Vedi in griglia', 'tipo' => 'boolean'), |
95
|
|
|
), |
96
|
|
|
'ordineindex' => array( |
97
|
|
|
array('nomecampo' => 'ordineindex', 'lunghezza' => '100', 'descrizione' => 'Ordine in griglia', 'tipo' => 'text'), |
98
|
|
|
), |
99
|
|
|
'etichettaindex' => array( |
100
|
|
|
array('nomecampo' => 'etichettaindex', 'lunghezza' => '150', 'descrizione' => 'Label in griglia', 'tipo' => 'text'), |
101
|
|
|
), |
102
|
|
|
'larghezzaindex' => array( |
103
|
|
|
array('nomecampo' => 'larghezzaindex', 'lunghezza' => '100', 'descrizione' => 'Largh. in griglia', 'tipo' => 'text'), |
104
|
|
|
), |
105
|
|
|
'mostrastampa' => array( |
106
|
|
|
array('nomecampo' => 'mostrastampa', 'lunghezza' => '100', 'descrizione' => 'Vedi in stampa', 'tipo' => 'boolean'), |
107
|
|
|
), |
108
|
|
|
'ordinestampa' => array( |
109
|
|
|
array('nomecampo' => 'ordinestampa', 'lunghezza' => '100', 'descrizione' => 'Ordine in stampa', 'tipo' => 'text'), |
110
|
|
|
), |
111
|
|
|
'etichettastampa' => array( |
112
|
|
|
array('nomecampo' => 'etichettastampa', 'lunghezza' => '150', 'descrizione' => 'Label in stampa', 'tipo' => 'text'), |
113
|
|
|
), |
114
|
|
|
'larghezzastampa' => array( |
115
|
|
|
array('nomecampo' => 'larghezzastampa', 'lunghezza' => '100', 'descrizione' => 'Largh. in stampa', 'tipo' => 'text'), |
116
|
|
|
), |
117
|
|
|
); |
118
|
|
|
|
119
|
|
|
$paricevuti = array( |
120
|
1 |
|
'doctrine' => $em, |
121
|
1 |
|
'nomebundle' => $nomebundle, |
122
|
1 |
|
'nometabella' => $controller, |
123
|
1 |
|
'dettaglij' => $dettaglij, |
124
|
1 |
|
'container' => $container, |
125
|
|
|
); |
126
|
|
|
|
127
|
1 |
|
$paricevuti['escludere'] = array('nometabella', 'operatori_id'); |
128
|
|
|
|
129
|
1 |
|
$testata = Griglia::testataPerGriglia($paricevuti); |
130
|
|
|
|
131
|
1 |
|
$testata['titolo'] = "Configurazione colonne per tabella $nometabella"; |
132
|
1 |
|
$testata['multisearch'] = 0; |
133
|
1 |
|
$testata['showdel'] = 0; |
134
|
1 |
|
$testata['showadd'] = 0; |
135
|
1 |
|
$testata['showedit'] = 0; |
136
|
1 |
|
$testata['showprint'] = 0; |
137
|
1 |
|
$testata['editinline'] = 1; |
138
|
1 |
|
$testata['nomelist'] = '#listconfigura'; |
139
|
1 |
|
$testata['nomepager'] = '#pagerconfigura'; |
140
|
1 |
|
$testata['tastochiudi'] = 1; |
141
|
1 |
|
$testata['div'] = '#dettaglioconf'; |
142
|
1 |
|
$testata['chiamante'] = $nometabella; |
143
|
1 |
|
$testata['percorsogriglia'] = $nometabella . '/grigliapopup'; |
144
|
1 |
|
$testata['altezzagriglia'] = '300'; |
145
|
1 |
|
$testata['larghezzagriglia'] = '900'; |
146
|
|
|
|
147
|
1 |
|
$testata['permessiedit'] = 1; |
148
|
1 |
|
$testata['permessidelete'] = 1; |
149
|
1 |
|
$testata['permessicreate'] = 1; |
150
|
1 |
|
$testata['permessiread'] = 1; |
151
|
|
|
$twigparm = array( |
152
|
1 |
|
'entities' => $entities, |
153
|
1 |
|
'nomecontroller' => $controller, |
154
|
1 |
|
'testata' => json_encode($testata), |
155
|
1 |
|
'chiamante' => $nometabella, |
156
|
|
|
); |
157
|
|
|
|
158
|
1 |
|
return $this->render($nomebundle . ':' . $controller . ':configura.html.twig', $twigparm); |
159
|
|
|
} |
160
|
|
|
|
161
|
1 |
|
public function generaDB($parametri, Request $request) |
162
|
|
|
{ |
163
|
1 |
|
$this->setup($request); |
164
|
1 |
|
if (!isset($parametri['tabella'])) { |
165
|
|
|
return false; |
166
|
|
|
} |
167
|
|
|
|
168
|
1 |
|
$namespace = $this->getNamespace(); |
169
|
1 |
|
$bundle = $this->getBundle(); |
170
|
|
|
|
171
|
1 |
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
172
|
|
|
|
173
|
1 |
|
$nometabella = $parametri['tabella']; |
174
|
1 |
|
$em = $this->getDoctrine()->getManager(); |
175
|
|
|
|
176
|
1 |
|
$bundles = $this->get('kernel')->getBundles(); |
177
|
1 |
|
$tableClassName = ""; |
178
|
1 |
|
foreach ($bundles as $bundle) { |
179
|
1 |
|
$className = get_class($bundle); |
180
|
1 |
|
$entityClass = substr($className, 0, strrpos($className, '\\')); |
181
|
1 |
|
$tableClassName = '\\' . $entityClass . '\\Entity\\' . $nometabella; |
182
|
1 |
|
if (!class_exists($tableClassName)) { |
183
|
1 |
|
$tableClassName = ''; |
184
|
1 |
|
continue; |
185
|
|
|
} else { |
186
|
1 |
|
break; |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
|
190
|
1 |
|
if (!$tableClassName) { |
191
|
|
|
throw new \Exception('Entity per la tabella ' . $nometabella . ' non trovata', '-1'); |
192
|
|
|
} |
193
|
|
|
|
194
|
1 |
|
$bundleClass = str_replace('\\', '', $entityClass); |
|
|
|
|
195
|
|
|
|
196
|
1 |
|
$c = $em->getClassMetadata($bundleClass . ':' . $nometabella); |
197
|
|
|
|
198
|
1 |
|
$colonne = $c->getColumnNames(); |
199
|
1 |
|
$this->scriviDB($colonne, $nometabella, $nomebundle, $parametri); |
200
|
1 |
|
} |
201
|
|
|
|
202
|
1 |
|
private function scriviDB($colonne, $nometabella, $nomebundle, $parametri) |
203
|
|
|
{ |
204
|
1 |
|
foreach ($colonne as $colonna) { |
205
|
|
|
$vettorericerca = array( |
206
|
1 |
|
'nometabella' => $nometabella, |
207
|
1 |
|
'nomecampo' => $colonna, |
208
|
|
|
); |
209
|
|
|
|
210
|
1 |
|
if (isset($parametri['operatore'])) { |
211
|
1 |
|
$vettorericerca['operatori_id'] = $parametri['operatore']; |
212
|
|
|
} |
213
|
|
|
|
214
|
1 |
|
$trovato = $this->getDoctrine()->getRepository($nomebundle . ':Tabelle')->findBy($vettorericerca, array()); |
215
|
|
|
|
216
|
1 |
|
if (empty($trovato)) { |
217
|
1 |
|
$crea = new Tabelle(); |
218
|
1 |
|
$crea->setNometabella($nometabella); |
219
|
1 |
|
$crea->setNomecampo($colonna); |
220
|
|
|
|
221
|
1 |
|
if (isset($parametri['operatore'])) { |
222
|
1 |
|
$arraycreaoperatore = array('id' => $parametri['operatore']); |
223
|
1 |
|
$creaoperatore = $this->getDoctrine()->getRepository($nomebundle . ':Operatori')->findOneBy($arraycreaoperatore); |
224
|
1 |
|
$crea->setOperatori($creaoperatore); |
|
|
|
|
225
|
|
|
|
226
|
1 |
|
unset($vettorericerca['operatori_id']); |
227
|
1 |
|
$vettorericerca['operatori_id'] = null; |
228
|
1 |
|
$ritrovato = $this->getDoctrine()->getRepository($nomebundle . ':Tabelle')->findOneBy($vettorericerca); |
229
|
|
|
|
230
|
1 |
|
if (!empty($ritrovato)) { |
231
|
1 |
|
$crea->setMostrastampa($ritrovato->hasMostrastampa() ? true : false); |
232
|
1 |
|
$crea->setMostraindex($ritrovato->hasMostraindex() ? true : false); |
233
|
|
|
} |
234
|
|
|
} else { |
235
|
1 |
|
$crea->setMostrastampa(true); |
236
|
1 |
|
$crea->setMostraindex(true); |
237
|
|
|
} |
238
|
|
|
|
239
|
1 |
|
$ma = $this->getDoctrine()->getManager(); |
240
|
1 |
|
$ma->persist($crea); |
241
|
1 |
|
$ma->flush(); |
242
|
|
|
} |
243
|
|
|
} |
244
|
1 |
|
} |
245
|
|
|
|
246
|
|
|
public function grigliapopupAction(Request $request, $chiamante) |
247
|
|
|
{ |
248
|
|
|
$this->setup($request); |
249
|
|
|
$namespace = $this->getNamespace(); |
250
|
|
|
$bundle = $this->getBundle(); |
251
|
|
|
$controller = $this->getController(); |
252
|
|
|
|
253
|
|
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
254
|
|
|
$em = $this->getDoctrine()->getManager(); |
255
|
|
|
|
256
|
|
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
257
|
|
|
$operatore = $gestionepermessi->utentecorrente(); |
258
|
|
|
$tabellej = array(); |
259
|
|
|
$tabellej['operatori_id'] = array('tabella' => 'operatori', 'campi' => array('username', 'operatore')); |
260
|
|
|
|
261
|
|
|
$paricevuti = array( |
262
|
|
|
'request' => $request, |
263
|
|
|
'doctrine' => $em, |
264
|
|
|
'container' => $this->container, |
265
|
|
|
'nomebundle' => $nomebundle, |
266
|
|
|
'nometabella' => $controller, |
267
|
|
|
'tabellej' => $tabellej,); |
268
|
|
|
|
269
|
|
|
$paricevuti['escludere'] = array('nometabella', 'operatori_id'); |
270
|
|
|
$paricevuti['precondizioni'] = array('Tabelle.nometabella' => $chiamante, 'Tabelle.operatori_id' => $operatore['id']); |
271
|
|
|
|
272
|
|
|
return new Response(Griglia::datiPerGriglia($paricevuti)); |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
public function grigliaAction(Request $request) |
276
|
|
|
{ |
277
|
|
|
$this->setParametriGriglia(array('request' => $request)); |
278
|
|
|
$paricevuti = self::$parametrigriglia; |
279
|
|
|
|
280
|
|
|
return new Response(Griglia::datiPerGriglia($paricevuti)); |
281
|
|
|
} |
282
|
|
|
|
283
|
1 |
|
protected function setParametriGriglia($prepar = array()) |
284
|
|
|
{ |
285
|
1 |
|
$this->setup($prepar['request']); |
286
|
1 |
|
$namespace = $this->getNamespace(); |
287
|
1 |
|
$bundle = $this->getBundle(); |
288
|
1 |
|
$controller = $this->getController(); |
289
|
|
|
|
290
|
1 |
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
291
|
1 |
|
$canRead = ($gestionepermessi->leggere(array('modulo' => $controller)) ? 1 : 0); |
292
|
1 |
|
if (!$canRead) { |
293
|
|
|
throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto"); |
294
|
|
|
} |
295
|
|
|
|
296
|
1 |
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
297
|
1 |
|
$tabellej = array(); |
298
|
1 |
|
$tabellej['operatori_id'] = array('tabella' => 'operatori', 'campi' => array('username')); |
299
|
1 |
|
$escludi = array("operatori"); //'operatori_id' |
300
|
|
|
|
301
|
|
|
$paricevuti = array( |
302
|
1 |
|
'container' => $this->container, |
303
|
1 |
|
'nomebundle' => $nomebundle, |
304
|
1 |
|
'nometabella' => $controller, |
305
|
1 |
|
'tabellej' => $tabellej, |
306
|
1 |
|
'escludere' => $escludi |
307
|
|
|
); |
308
|
|
|
|
309
|
1 |
|
if (! empty($prepar)) { |
310
|
1 |
|
$paricevuti = array_merge($paricevuti, $prepar); |
311
|
|
|
} |
312
|
|
|
|
313
|
1 |
|
self::$parametrigriglia = $paricevuti; |
314
|
1 |
|
} |
315
|
|
|
|
316
|
|
|
public function listacampitabellaAction(Request $request) |
317
|
|
|
{ |
318
|
|
|
$this->setup($request); |
319
|
|
|
$namespace = $this->getNamespace(); |
320
|
|
|
$bundle = $this->getBundle(); |
321
|
|
|
$controller = $this->getController(); |
322
|
|
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
323
|
|
|
|
324
|
|
|
$nometabella = trim($request->get('tabella')); |
325
|
|
|
if (!isset($nometabella)) { |
326
|
|
|
return false; |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
$escludiid = $request->get('escludiid'); |
330
|
|
|
if (!isset($escludiid)) { |
331
|
|
|
$escludiid = 0; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
$em = $this->getDoctrine()->getManager(); |
335
|
|
|
|
336
|
|
|
$bundles = $this->get('kernel')->getBundles(); |
337
|
|
|
foreach ($bundles as $bundle) { |
338
|
|
|
$className = get_class($bundle); |
339
|
|
|
$entityClass = substr($className, 0, strrpos($className, '\\')); |
340
|
|
|
$tableClassName = '\\' . $entityClass . '\\Entity\\' . $nometabella; |
341
|
|
|
if (!class_exists($tableClassName)) { |
342
|
|
|
$tableClassName = ''; |
343
|
|
|
continue; |
344
|
|
|
} else { |
345
|
|
|
break; |
346
|
|
|
} |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
if (!$tableClassName) { |
|
|
|
|
350
|
|
|
throw new \Exception('Entity per la tabella ' . $nometabella . ' non trovata', '-1'); |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
$bundleClass = str_replace('\\', '', $entityClass); |
|
|
|
|
354
|
|
|
$c = $em->getClassMetadata($bundleClass . ':' . $nometabella); |
355
|
|
|
$colonne = $c->getColumnNames(); |
356
|
|
|
|
357
|
|
|
$risposta = $this->listacampitabelladettagli($escludiid, $colonne, $nomebundle, $controller); |
358
|
|
|
//natcasesort($risposta); |
359
|
|
|
asort($risposta, SORT_NATURAL | SORT_FLAG_CASE); |
360
|
|
|
|
361
|
|
|
return new JsonResponse($risposta); |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
private function listacampitabelladettagli($escludiid, $colonne, $nomebundle, $controller) |
365
|
|
|
{ |
366
|
|
|
$risposta = array(); |
367
|
|
|
if ($escludiid == 1) { |
368
|
|
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
369
|
|
|
$operatore = $gestionepermessi->utentecorrente(); |
370
|
|
|
foreach ($colonne as $colonna) { |
371
|
|
|
$nomecampo = trim(strtolower($colonna)); |
372
|
|
|
if (($nomecampo !== 'id') && (strpos($colonna, '_id') == false)) { |
|
|
|
|
373
|
|
|
$qb = $this->getDoctrine()->getRepository("$nomebundle:$controller") |
374
|
|
|
->createQueryBuilder('t') |
375
|
|
|
->where('LOWER(t.nometabella) = :nometabella') |
376
|
|
|
->andWhere('LOWER(t.nomecampo) = :nomecampo') |
377
|
|
|
->andWhere('t.operatori_id = :operatori_id') |
378
|
|
|
->setParameter('nometabella', $nometabella) |
|
|
|
|
379
|
|
|
->setParameter('nomecampo', $nomecampo) |
380
|
|
|
->setParameter('operatori_id', $operatore['id']) |
381
|
|
|
->getQuery(); |
382
|
|
|
$labeltrovata = $qb->getResult(); |
383
|
|
|
if (!$labeltrovata) { |
384
|
|
|
$qb = $this->getDoctrine()->getRepository("$nomebundle:$controller") |
385
|
|
|
->createQueryBuilder('t') |
386
|
|
|
->where('LOWER(t.nometabella) = :nometabella') |
387
|
|
|
->andWhere('LOWER(t.nomecampo) = :nomecampo') |
388
|
|
|
->andWhere('t.operatori_id IS NULL') |
389
|
|
|
->setParameter('nometabella', $nometabella) |
390
|
|
|
->setParameter('nomecampo', $nomecampo) |
391
|
|
|
->getQuery(); |
392
|
|
|
$labeltrovata = $qb->getResult(); |
393
|
|
|
if (!$labeltrovata) { |
394
|
|
|
$risposta[$colonna] = $colonna; |
395
|
|
|
} else { |
396
|
|
|
if (($labeltrovata[0]->getEtichettaindex()) && ($labeltrovata[0]->getEtichettaindex() != '')) { |
397
|
|
|
$risposta[$colonna] = trim($labeltrovata[0]->getEtichettaindex()); |
398
|
|
|
} else { |
399
|
|
|
$risposta[$colonna] = $colonna; |
400
|
|
|
} |
401
|
|
|
} |
402
|
|
|
} else { |
403
|
|
|
if (($labeltrovata[0]->getEtichettaindex()) && ($labeltrovata[0]->getEtichettaindex() != '')) { |
404
|
|
|
$risposta[$colonna] = trim($labeltrovata[0]->getEtichettaindex()); |
405
|
|
|
} else { |
406
|
|
|
$risposta[$colonna] = $colonna; |
407
|
|
|
} |
408
|
|
|
} |
409
|
|
|
} |
410
|
|
|
} |
411
|
|
|
} else { |
412
|
|
|
foreach ($colonne as $colonna) { |
413
|
|
|
$risposta[$colonna] = $colonna; |
414
|
|
|
} |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
return $risposta; |
418
|
|
|
} |
419
|
|
|
} |
420
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.