Skip to content
Permalink
Browse files

Improve assertion calculation on mixed vars

  • Loading branch information
muglug committed Nov 12, 2019
1 parent 7012bed commit 7f5af741f7665f68fa9883d2f613e3626f2e0880
@@ -108,6 +108,8 @@ public static function analyze(
function (Clause $c) use ($mixed_var_ids) {
$keys = array_keys($c->possibilities);
$mixed_var_ids = array_diff($mixed_var_ids, $keys);
foreach ($keys as $key) {
foreach ($mixed_var_ids as $mixed_var_id) {
if (preg_match('/^' . preg_quote($mixed_var_id, '/') . '(\[|-)/', $key)) {
@@ -118,6 +118,8 @@ public static function analyze(
function (Clause $c) use ($mixed_var_ids) {
$keys = array_keys($c->possibilities);
$mixed_var_ids = array_diff($mixed_var_ids, $keys);
foreach ($keys as $key) {
foreach ($mixed_var_ids as $mixed_var_id) {
if (preg_match('/^' . preg_quote($mixed_var_id, '/') . '(\[|-)/', $key)) {
@@ -992,6 +994,8 @@ protected static function analyzeElseIfBlock(
function (Clause $c) use ($mixed_var_ids) {
$keys = array_keys($c->possibilities);
$mixed_var_ids = array_diff($mixed_var_ids, $keys);
foreach ($keys as $key) {
foreach ($mixed_var_ids as $mixed_var_id) {
if (preg_match('/^' . preg_quote($mixed_var_id, '/') . '(\[|-)/', $key)) {
@@ -397,6 +397,8 @@ function ($var_id) use ($original_vars_in_scope) {
function (\Psalm\Internal\Clause $c) use ($mixed_var_ids) {
$keys = array_keys($c->possibilities);
$mixed_var_ids = array_diff($mixed_var_ids, $keys);
foreach ($keys as $key) {
foreach ($mixed_var_ids as $mixed_var_id) {
if (preg_match('/^' . preg_quote($mixed_var_id, '/') . '(\[|-)/', $key)) {
@@ -190,6 +190,8 @@ function ($var_id) use ($pre_condition_vars_in_scope) {
function (\Psalm\Internal\Clause $c) use ($mixed_var_ids) {
$keys = array_keys($c->possibilities);
$mixed_var_ids = array_diff($mixed_var_ids, $keys);
foreach ($keys as $key) {
foreach ($mixed_var_ids as $mixed_var_id) {
if (preg_match('/^' . preg_quote($mixed_var_id, '/') . '(\[|-)/', $key)) {
@@ -437,6 +437,22 @@ function testElseif(C $obj) : void {
if ($obj->b === "baz") {}
}'
],
'assertArrayWithOffset' => [
'<?php
/**
* @param mixed $decoded
* @return array{icons:mixed}
*/
function assertArrayWithOffset($decoded): array {
if (!is_array($decoded)
|| !isset($decoded["icons"])
) {
throw new RuntimeException("Bad");
}
return $decoded;
}'
],
];
}
}

0 comments on commit 7f5af74

Please sign in to comment.
You can’t perform that action at this time.