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

Utilizing Expression::visit method instead of switch-case #230

Open
wants to merge 2 commits into
base: 2.0.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Doctrine\Common\Collections\Expr;

use RuntimeException;
use function get_class;

/**
* An Expression visitor walks a graph of expressions and turns them into a
Expand Down Expand Up @@ -43,15 +42,6 @@ abstract public function walkCompositeExpression(CompositeExpression $expr);
*/
public function dispatch(Expression $expr)
{
switch (true) {
case $expr instanceof Comparison:
return $this->walkComparison($expr);
case $expr instanceof Value:
return $this->walkValue($expr);
case $expr instanceof CompositeExpression:
return $this->walkCompositeExpression($expr);
default:
throw new RuntimeException('Unknown Expression ' . get_class($expr));
}
return $expr->visit($this);
}
}