Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse-engineer actual type from code #10221

Merged
merged 1 commit into from Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/Doctrine/ORM/Query/AST/Node.php
Expand Up @@ -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;
Expand All @@ -71,23 +71,23 @@ 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;
}

$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;
Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions psalm-baseline.xml
Expand Up @@ -1830,14 +1830,6 @@
<code>$sqlWalker</code>
</ParamNameMismatch>
</file>
<file src="lib/Doctrine/ORM/Query/AST/Node.php">
<DocblockTypeContradiction occurrences="1">
<code>is_array($obj)</code>
</DocblockTypeContradiction>
<RedundantConditionGivenDocblockType occurrences="1">
<code>is_object($obj)</code>
</RedundantConditionGivenDocblockType>
</file>
<file src="lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php">
<ParamNameMismatch occurrences="1">
<code>$sqlWalker</code>
Expand Down