Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use concrete Class Methods to check validations #7069

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

Closed
wants to merge 1 commit into from
Closed

Use concrete Class Methods to check validations #7069

wants to merge 1 commit into from

Conversation

Gladhon
Copy link

@Gladhon Gladhon commented Feb 14, 2013

Please use the concrete Class Methods to check validations. Its realy unexpected that Validator don't use the normal Object way and invoke the conrete object with another class.

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

Please use the concrete Class Methods to check validations. Its realy unexpected that Validator don't use the normal Object way and can call anything...
@fabpot
Copy link
Member

fabpot commented Feb 14, 2013

Can you add a test case?

@vicb
Copy link
Contributor

vicb commented Feb 16, 2013

What bug does this fix ? I don't get the difference with the current code.

@stof
Copy link
Member

stof commented Feb 17, 2013

@vicb If you overwrite the method in the child class and have the validation mapping defined on the method of the parent class, the current code calls the parent method, not the method of your object

Btw, there is already a ticket reporting the issue a long time ago: #2841

@vicb
Copy link
Contributor

vicb commented Feb 17, 2013

Thanks for clarification @stof.

Is the fix appropriate or should newReflectionMember be changed instead ?

Christophe Coevoet [email protected] wrote:

@vicb If you overwrite the method in the child class and have the
validation mapping defined on the method of the parent class, the
current code calls the parent method, not the method of your object

Btw, there is already a ticket reporting the issue a long time ago:
#2841


Reply to this email directly or view it on GitHub:
#7069 (comment)

@fabpot
Copy link
Member

fabpot commented Feb 27, 2013

@Gladhon Can you add some tests please? Thanks.

@vicb
Copy link
Contributor

vicb commented Mar 5, 2013

see #7271

@vicb vicb closed this Mar 5, 2013
fabpot added a commit that referenced this pull request Mar 18, 2013
This PR was merged into the master branch.

Commits
-------

b6a5457 [Validator] Fixed member (getter/property) metadata readers. [Validator] added overridden getter metadata test [Validator] class member reflection build requires object instance [Validator] fixed error [Validation] fixed member metadata reflection cache [Validation] added property metedata test [Validation] fixed class/member metadata mapping [Validation] removed var_dump
9b6cd80 Update src/Symfony/Component/Validator/Mapping/GetterMetadata.php

Discussion
----------

[Validator] Use concrete Class Methods to check validations

This PR just adds a test to #7069.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #7069

---------------------------------------------------------------------------

by vicb at 2013-03-05T18:21:02Z

@jfsimon Do you have a response about my comment in the original PR ?

At least we now have a BC break (ie new is no more called).

---------------------------------------------------------------------------

by jfsimon at 2013-03-05T18:30:43Z

@vicb I didn't saw it. I update the description.

---------------------------------------------------------------------------

by vicb at 2013-03-05T18:34:01Z

np, do you have a reply ?

_BCB = yes should trigger a note in the changelog_

---------------------------------------------------------------------------

by jfsimon at 2013-03-05T18:51:15Z

@vicb a response about the `newReflectionMember` method update?

---------------------------------------------------------------------------

by vicb at 2013-03-05T19:08:54Z

Yep

"Jean-François Simon" <[email protected]> wrote:

>@vicb a response about the `newReflectionMember` method update?
>
>---
>Reply to this email directly or view it on GitHub:
>#7271 (comment)

---------------------------------------------------------------------------

by Gladhon at 2013-03-06T08:04:38Z

@vicb
newReflectionMember is a Method that comes from the parent and has no argument "object". So it can only get the reflection Member of the configured class, while we need once (in this special case) need the method of the concrete class.

---------------------------------------------------------------------------

by jfsimon at 2013-03-06T08:29:11Z

@vicb @Gladhon correct me if I'm wrong.

This method is only used to check the member scope. In the case of a getter, this scope is always public (`method_exists` returns true only if method is visible, then is this case public, isn'it?), so the `isPublic`, `isProtected` and `isPrivate` methods can be safely overriden. Am I right?

---------------------------------------------------------------------------

by Gladhon at 2013-03-06T08:43:54Z

Yes i am in agreement with that.

But I just think about to change the getPropertyValue also in PropertyMetadata. Can that make sense in any case ?

---------------------------------------------------------------------------

by vicb at 2013-03-06T08:56:21Z

@jfsimon `method_exists` returns `true` when the method exists, whatever its visibility.

My question is whether it would make sense to change the signature of `newReflectionMember` to accept an objet ?
That would be a BC break but the implementation proposed here is also a BC break (`newReflectionMember` which was called from `getReflectionMember` is no more called with this PR - it could have been overriden by a dev)

Finally `PropertyMetadata` should probably be updated in the same way.

---------------------------------------------------------------------------

by vicb at 2013-03-06T08:57:33Z

_and fyi you can both work on the same PR, ie @Gladhon you can send some changes (a PR) to the repo of @jfsimon_

---------------------------------------------------------------------------

by Gladhon at 2013-03-06T10:22:07Z

Well, i like it how it is now. Cause if we change that, you also need to have a object if calling "isPublic". For me it makes more sence to have only the object parameter if its realy needed.
Where do you see a real benefit if we change the `newReflectionMember` instead ?

---------------------------------------------------------------------------

by jfsimon at 2013-03-07T13:43:43Z

@vicb I think passing object instance to `getReflectionMember` is **required** for consistency.
I just pushed it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants