-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Bug3872; | ||
|
||
class Demo | ||
{ | ||
public function analyze($json): void | ||
{ | ||
foreach (json_decode($json, true) as $item) { | ||
$item += ['value' => '', 'operator' => '']; | ||
if ($item['value']) { | ||
$item['value'] = strtotime($item['value']); | ||
if ($item['operator'] === 'eq') { | ||
echo 'test'; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Bug6783; | ||
|
||
/** | ||
* @return array<string, mixed> | ||
*/ | ||
function foo(): array | ||
{ | ||
// something from elsewhere (not in the scope of PHPStan) | ||
return [ | ||
// removing or keeping those lines does/should not change the reporting | ||
'foo' => [ | ||
'bar' => true, | ||
] | ||
]; | ||
} | ||
|
||
function bar() { | ||
$data = foo(); | ||
$data = $data['foo'] ?? []; // <<< removing this line suppress the error | ||
$data += [ | ||
'default' => true, | ||
]; | ||
foreach (['formatted'] as $field) { | ||
$data[$field] = empty($data[$field]) ? false : true; | ||
} | ||
|
||
$bar = $data['bar']; | ||
} | ||
|