Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
Add more informative exception messages for unknown type operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Elliot Levin committed Sep 20, 2014
1 parent f95fd0d commit d81b795
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Source/Analysis/Types/MixedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public function isParentTypeOf(IType $type)
return true;
}

protected function unsupported(O\Expression $expression, $message)
protected function unsupported(O\Expression $expression, $message, array $formatValues = [])
{
return new TypeException(
'Type does not support expression \'%s\': %s',
$expression->compileDebug(),
$message);
vsprintf($message, $formatValues));
}

public function getConstructor(O\NewExpression $expression)
Expand All @@ -39,22 +39,22 @@ public function getConstructor(O\NewExpression $expression)

public function getMethod(O\MethodCallExpression $expression)
{
throw $this->unsupported($expression, 'method is not supported');
throw $this->unsupported($expression, 'method %s is not supported', [$expression->getName()->compileDebug()]);
}

public function getStaticMethod(O\StaticMethodCallExpression $expression)
{
throw $this->unsupported($expression, 'static method is not supported');
throw $this->unsupported($expression, 'static method %s is not supported', [$expression->getName()->compileDebug()]);
}

public function getField(O\FieldExpression $expression)
{
throw $this->unsupported($expression, 'field is not supported');
throw $this->unsupported($expression, 'field %s is not supported', [$expression->getName()->compileDebug()]);
}

public function getStaticField(O\StaticFieldExpression $expression)
{
throw $this->unsupported($expression, 'static field is not supported');
throw $this->unsupported($expression, 'static field %s is not supported', [$expression->getName()->compileDebug()]);
}

public function getInvocation(O\InvocationExpression $expression)
Expand All @@ -69,11 +69,11 @@ public function getIndex(O\IndexExpression $expression)

public function getCast(O\CastExpression $expression)
{
throw $this->unsupported($expression, 'cast is not supported');
throw $this->unsupported($expression, 'cast \'%s\' is not supported', [$expression->getCastType()]);
}

public function getUnaryOperation(O\UnaryOperationExpression $expression)
{
throw $this->unsupported($expression, 'unary operator is not supported');
throw $this->unsupported($expression, 'unary operator \'%s\' is not supported', [$expression->getOperator()]);
}
}

0 comments on commit d81b795

Please sign in to comment.