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

[PropertyAccess][DX] Enhance exception that say that some methods are missing if they don't #18732

Closed
wants to merge 5 commits into from

Conversation

Projects
None yet
7 participants
@nykopol
Copy link
Contributor

commented May 9, 2016

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

When you try do define a manyToMany association but you don't give an array or \Traversable, the raised exception say that some methods are missing while they don't. This PR check if the adder and setter methods exists and if so, give a exception that pointing on the real problem.

@xabbuh

This comment has been minimized.

Copy link
Member

commented May 9, 2016

@nykopol Can you please also add a test to prevent future regressions?

nykopol added some commits May 10, 2016

@nykopol

This comment has been minimized.

Copy link
Contributor Author

commented May 10, 2016

@xabbuh I added the test.

'"%s" given.',
$property,
$reflClass->name,
implode(' and ', array_map(function($method){

This comment has been minimized.

Copy link
@phansys

phansys May 15, 2016

Contributor

It is offending PSR-2 - 6.Closures.

@@ -714,6 +714,19 @@ private function getWriteAccessInfo($class, $property, $value)
// we call the getter and hope the __call do the job
$access[self::ACCESS_TYPE] = self::ACCESS_TYPE_MAGIC;
$access[self::ACCESS_NAME] = $setter;
} elseif (null !== $this->findAdderAndRemover($reflClass, $singulars)) {

This comment has been minimized.

Copy link
@nicolas-grekas

nicolas-grekas May 19, 2016

Member

null !== $methods = ...

'"%s" given.',
$property,
$reflClass->name,
implode(' and ', array_map(function ($method) {

This comment has been minimized.

Copy link
@nicolas-grekas

nicolas-grekas May 19, 2016

Member

no need for array_map here. "and" is also going to be repeated many times, let's replace it with a comma:
implode('()", "', $methods) and use methods "%s()" but in the message above.

@fabpot

This comment has been minimized.

Copy link
Member

commented Jun 15, 2016

Thank you @nykopol.

fabpot added a commit that referenced this pull request Jun 15, 2016

bug #18732 [PropertyAccess][DX] Enhance exception that say that some …
…methods are missing if they don't (nykopol)

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

Discussion
----------

[PropertyAccess][DX] Enhance exception that say that some methods are missing if they don't

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

When you try do define a manyToMany association but you don't give an array or \Traversable, the raised exception say that some methods are missing while they don't. This PR check if the adder and setter methods exists and if so, give a exception that pointing on the real problem.

Commits
-------

c46519b [PropertyAccess][DX] Enhance exception that say that some methods are missing if they don't

@fabpot fabpot closed this Jun 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.