File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed
tests/PHPStan/Rules/Variables Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -3243,6 +3243,9 @@ public function filterBySpecifiedTypes(SpecifiedTypes $specifiedTypes): self
32433243
32443244 // Pass 2: Supertype match. Only runs when Pass 1 found no exact match for this expression.
32453245 foreach ($ conditionalExpressions as $ conditionalExpression ) {
3246+ if ($ conditionalExpression ->getTypeHolder ()->getCertainty ()->no ()) {
3247+ continue ;
3248+ }
32463249 foreach ($ conditionalExpression ->getConditionExpressionTypeHolders () as $ holderExprString => $ conditionalTypeHolder ) {
32473250 if (
32483251 !array_key_exists ($ holderExprString , $ specifiedExpressions )
Original file line number Diff line number Diff line change @@ -387,6 +387,11 @@ public function testBug4846(): void
387387 ]);
388388 }
389389
390+ public function testBug14458 (): void
391+ {
392+ $ this ->analyse ([__DIR__ . '/data/bug-14458.php ' ], []);
393+ }
394+
390395 public function testBug14393 (): void
391396 {
392397 $ this ->analyse ([__DIR__ . '/data/bug-14393.php ' ], [
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug14458 ;
4+
5+ use DateTime ;
6+
7+ class Foo
8+ {
9+
10+ /**
11+ * @param array<mixed> $payload
12+ * @return array<mixed>
13+ */
14+ public function doFoo (array $ payload ): array
15+ {
16+ if ($ payload ['a ' ] !== 'b ' ) {
17+ throw new \Exception ();
18+ }
19+
20+ if (isset ($ payload ['c ' ])) {
21+ $ c = array_values (array_map (static fn (array $ cd ) => $ cd [0 ], $ payload ['c ' ]));
22+ }
23+
24+ $ convertedPriceWithVat = null ;
25+ if (array_key_exists ('cpwv ' , $ payload )) {
26+ $ convertedAmount = (float ) $ payload ['cpwv ' ]['awv ' ];
27+
28+ }
29+
30+ return [
31+ $ payload ['cf ' ],
32+ $ payload ['n ' ],
33+ $ payload ['d ' ] ?? null ,
34+ $ payload ['mb ' ] ?? null ,
35+ $ payload ['cr ' ],
36+ new DateTime ($ payload ['p ' ]),
37+ $ payload ['pn ' ],
38+ $ payload ['pd ' ] ?? null ,
39+ $ payload ['piu ' ] ?? null ,
40+ $ convertedPriceWithVat ,
41+ $ payload ['vi ' ],
42+ $ payload ['pi ' ],
43+ $ payload ['user ' ]['name ' ] ?? null ,
44+ $ payload ['user ' ]['phone ' ] ?? null ,
45+ $ payload ['ac ' ] ?? null ,
46+ $ c ?? null ,
47+ ];
48+ }
49+
50+ }
You can’t perform that action at this time.
0 commit comments