Skip to content

Commit 465c02f

Browse files
authored
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.
1 parent 7e45ad9 commit 465c02f

File tree

3 files changed

+10
-28
lines changed

3 files changed

+10
-28
lines changed

lib/Doctrine/ORM/Query/AST/Node.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ public function __toString()
4949
}
5050

5151
/**
52-
* @param object $obj
52+
* @param mixed $value
5353
*
5454
* @return string
5555
*/
56-
public function dump($obj)
56+
public function dump($value)
5757
{
5858
static $ident = 0;
5959

6060
$str = '';
6161

62-
if ($obj instanceof Node) {
63-
$str .= get_debug_type($obj) . '(' . PHP_EOL;
64-
$props = get_object_vars($obj);
62+
if ($value instanceof Node) {
63+
$str .= get_debug_type($value) . '(' . PHP_EOL;
64+
$props = get_object_vars($value);
6565

6666
foreach ($props as $name => $prop) {
6767
$ident += 4;
@@ -71,23 +71,23 @@ public function dump($obj)
7171
}
7272

7373
$str .= str_repeat(' ', $ident) . ')';
74-
} elseif (is_array($obj)) {
74+
} elseif (is_array($value)) {
7575
$ident += 4;
7676
$str .= 'array(';
7777
$some = false;
7878

79-
foreach ($obj as $k => $v) {
79+
foreach ($value as $k => $v) {
8080
$str .= PHP_EOL . str_repeat(' ', $ident) . '"'
8181
. $k . '" => ' . $this->dump($v) . ',';
8282
$some = true;
8383
}
8484

8585
$ident -= 4;
8686
$str .= ($some ? PHP_EOL . str_repeat(' ', $ident) : '') . ')';
87-
} elseif (is_object($obj)) {
88-
$str .= 'instanceof(' . get_debug_type($obj) . ')';
87+
} elseif (is_object($value)) {
88+
$str .= 'instanceof(' . get_debug_type($value) . ')';
8989
} else {
90-
$str .= var_export($obj, true);
90+
$str .= var_export($value, true);
9191
}
9292

9393
return $str;

phpstan-baseline.neon

-10
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,6 @@ parameters:
425425
count: 1
426426
path: lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php
427427

428-
-
429-
message: "#^Call to function is_array\\(\\) with object will always evaluate to false\\.$#"
430-
count: 1
431-
path: lib/Doctrine/ORM/Query/AST/Node.php
432-
433-
-
434-
message: "#^Else branch is unreachable because previous condition is always true\\.$#"
435-
count: 1
436-
path: lib/Doctrine/ORM/Query/AST/Node.php
437-
438428
-
439429
message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkWhenClauseExpression\\(\\)\\.$#"
440430
count: 1

psalm-baseline.xml

-8
Original file line numberDiff line numberDiff line change
@@ -1830,14 +1830,6 @@
18301830
<code>$sqlWalker</code>
18311831
</ParamNameMismatch>
18321832
</file>
1833-
<file src="lib/Doctrine/ORM/Query/AST/Node.php">
1834-
<DocblockTypeContradiction occurrences="1">
1835-
<code>is_array($obj)</code>
1836-
</DocblockTypeContradiction>
1837-
<RedundantConditionGivenDocblockType occurrences="1">
1838-
<code>is_object($obj)</code>
1839-
</RedundantConditionGivenDocblockType>
1840-
</file>
18411833
<file src="lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php">
18421834
<ParamNameMismatch occurrences="1">
18431835
<code>$sqlWalker</code>

0 commit comments

Comments
 (0)