Skip to content

Commit

Permalink
Use the correct type for the exception message
Browse files Browse the repository at this point in the history
Since the UoW checks each item of a *-to-many association to ensure
it has the correct type, we should never say that we expect an instance
of `Doctrine\Common\Collections\Collection` or an `array`.
  • Loading branch information
foaly-nr1 authored and lcobucci committed Nov 26, 2017
1 parent 152be9d commit ef83f5b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/Doctrine/ORM/ORMInvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,7 @@ public static function invalidIdentifierBindingEntity()
*/
public static function invalidAssociation(ClassMetadata $targetClass, $assoc, $actualValue)
{
$expectedType = 'Doctrine\Common\Collections\Collection|array';

if (($assoc['type'] & ClassMetadata::TO_ONE) > 0) {
$expectedType = $targetClass->getName();
}
$expectedType = $targetClass->getName();

return new self(sprintf(
'Expected value of type "%s" for association field "%s#$%s", got "%s" instead.',
Expand Down

0 comments on commit ef83f5b

Please sign in to comment.