From 465c02fe68d683efd32a314417940629c54374c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 11 Nov 2022 16:29:36 +0100 Subject: [PATCH] Reverse-engineer actual type from code (#10221) The code contains tests for is_array(), is object(), and an else clause. The type is wrong, and the variable name misleading. --- lib/Doctrine/ORM/Query/AST/Node.php | 20 ++++++++++---------- phpstan-baseline.neon | 10 ---------- psalm-baseline.xml | 8 -------- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/lib/Doctrine/ORM/Query/AST/Node.php b/lib/Doctrine/ORM/Query/AST/Node.php index 4bc3245d14b..507b41c915b 100644 --- a/lib/Doctrine/ORM/Query/AST/Node.php +++ b/lib/Doctrine/ORM/Query/AST/Node.php @@ -49,19 +49,19 @@ public function __toString() } /** - * @param object $obj + * @param mixed $value * * @return string */ - public function dump($obj) + public function dump($value) { static $ident = 0; $str = ''; - if ($obj instanceof Node) { - $str .= get_debug_type($obj) . '(' . PHP_EOL; - $props = get_object_vars($obj); + if ($value instanceof Node) { + $str .= get_debug_type($value) . '(' . PHP_EOL; + $props = get_object_vars($value); foreach ($props as $name => $prop) { $ident += 4; @@ -71,12 +71,12 @@ public function dump($obj) } $str .= str_repeat(' ', $ident) . ')'; - } elseif (is_array($obj)) { + } elseif (is_array($value)) { $ident += 4; $str .= 'array('; $some = false; - foreach ($obj as $k => $v) { + foreach ($value as $k => $v) { $str .= PHP_EOL . str_repeat(' ', $ident) . '"' . $k . '" => ' . $this->dump($v) . ','; $some = true; @@ -84,10 +84,10 @@ public function dump($obj) $ident -= 4; $str .= ($some ? PHP_EOL . str_repeat(' ', $ident) : '') . ')'; - } elseif (is_object($obj)) { - $str .= 'instanceof(' . get_debug_type($obj) . ')'; + } elseif (is_object($value)) { + $str .= 'instanceof(' . get_debug_type($value) . ')'; } else { - $str .= var_export($obj, true); + $str .= var_export($value, true); } return $str; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b79dd96242f..b9100af19a7 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -425,16 +425,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php - - - message: "#^Call to function is_array\\(\\) with object will always evaluate to false\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Node.php - - - - message: "#^Else branch is unreachable because previous condition is always true\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Node.php - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkWhenClauseExpression\\(\\)\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1c43c7c1f63..be265360b75 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1830,14 +1830,6 @@ $sqlWalker - - - is_array($obj) - - - is_object($obj) - - $sqlWalker