From 553b094fef35e876ec91e82d926ab2c47184c225 Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Wed, 16 Sep 2015 14:38:34 +0900 Subject: [PATCH] Use InvalidArgumentException, because it's better then RuntimeExpcetion --- src/Visitor/Expression/AbstractExpressionCompiler.php | 4 ++-- tests/PHPSA/Expression/ExpressionCompilerTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Visitor/Expression/AbstractExpressionCompiler.php b/src/Visitor/Expression/AbstractExpressionCompiler.php index 6ce31ba8..958e68a4 100644 --- a/src/Visitor/Expression/AbstractExpressionCompiler.php +++ b/src/Visitor/Expression/AbstractExpressionCompiler.php @@ -5,10 +5,10 @@ namespace PHPSA\Visitor\Expression; +use Doctrine\Instantiator\Exception\InvalidArgumentException; use PHPSA\CompiledExpression; use PHPSA\Context; use PHPSA\Visitor\ExpressionCompilerInterface; -use RuntimeException; abstract class AbstractExpressionCompiler implements ExpressionCompilerInterface { @@ -21,7 +21,7 @@ abstract class AbstractExpressionCompiler implements ExpressionCompilerInterface protected function assertExpression($expression) { if (!$expression instanceof $this->name) { - throw new RuntimeException('Passed $expression must be instance of ' . $this->name); + throw new InvalidArgumentException('Passed $expression must be instance of ' . $this->name); } } diff --git a/tests/PHPSA/Expression/ExpressionCompilerTest.php b/tests/PHPSA/Expression/ExpressionCompilerTest.php index fd9d6ebd..af1fbf09 100644 --- a/tests/PHPSA/Expression/ExpressionCompilerTest.php +++ b/tests/PHPSA/Expression/ExpressionCompilerTest.php @@ -19,7 +19,7 @@ public function testPassUnexpectedExpression() $this->assertSame('PhpParser\Node\Expr\UnaryMinus', $expr->getName()); $this->setExpectedException( - 'RuntimeException', + 'InvalidArgumentException', 'Passed $expression must be instance of PhpParser\Node\Expr\UnaryMinus' ); $expr->pass($this->newFakeScalarExpr(), $this->getContext());