[PropertyAccess] Handle interfaces in the invalid argument exception #21360

Closed
wants to merge 2 commits into
from

Projects

None yet

5 participants

@fancyweb
Contributor
Q A
Branch? 2.7
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? no
Fixed tickets -
License MIT
Doc PR -

Before :
Expected argument of type "dule\MenuBundle\Entity\AbstractMenu::setMenuElements() must implement interface Doctrine\Common\Collections\Collection", "array" given

After :
Expected argument of type "Doctrine\Common\Collections\Collection", "array" given

@fancyweb fancyweb [PropertyAccess] Handle interfaces in the invalid argument exception
299109c
@xabbuh
Member
xabbuh commented Jan 20, 2017

Can you add a test for this?

@fancyweb fancyweb added test
5706b45
@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Jan 24, 2017
+
+ /**
+ * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
+ * @expectedExceptionMessage Expected argument of type "Countable", "string" given
@xabbuh
xabbuh Jan 25, 2017 Member

I would have expected a test checking for the new "must implement interface" string in the exception message.

@fancyweb
fancyweb Jan 25, 2017 Contributor

I don't get it : the "must implement interface" comes from the PHP exception that is handled and then the InvalidArgumentException is thrown.

@xabbuh
xabbuh Jan 25, 2017 Member

Sorry, you are right. I misread the changes you made.

@xabbuh
xabbuh approved these changes Jan 25, 2017 View changes

👍 LGTM

@fabpot
Member
fabpot commented Jan 25, 2017

Thank you @fancyweb.

@fabpot fabpot added a commit that referenced this pull request Jan 25, 2017
@fabpot fabpot bug #21360 [PropertyAccess] Handle interfaces in the invalid argument…
… exception (fancyweb)

This PR was squashed before being merged into the 2.7 branch (closes #21360).

Discussion
----------

[PropertyAccess] Handle interfaces in the invalid argument exception

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Before :
`Expected argument of type "dule\MenuBundle\Entity\AbstractMenu::setMenuElements() must implement interface Doctrine\Common\Collections\Collection", "array" given`

After :
`Expected argument of type "Doctrine\Common\Collections\Collection", "array" given`

Commits
-------

be52b39 [PropertyAccess] Handle interfaces in the invalid argument exception
a6d2420
@fabpot fabpot closed this Jan 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment