Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[PropertyInfo] Exclude static methods form properties guessing#21331

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:2.8fromdunglas:propertyinfo/exclude_static
Jan 18, 2017

Conversation

@dunglas
Copy link
Member

QA
Branch?2.8
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

@stof
Copy link
Member

👍

@fabpot
Copy link
Member

Thank you@dunglas.

@fabpotfabpot merged commit190c736 intosymfony:2.8Jan 18, 2017
fabpot added a commit that referenced this pull requestJan 18, 2017
…sing (dunglas)This PR was merged into the 2.8 branch.Discussion----------[PropertyInfo] Exclude static methods form properties guessing| Q             | A| ------------- | ---| Branch?       | 2.8| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aCommits-------190c736 [PropertyInfo] Exclude static methods form properties guessing
@dunglasdunglas deleted the propertyinfo/exclude_static branchJanuary 18, 2017 15:19
fabpot added a commit that referenced this pull requestJan 18, 2017
…c method (dunglas)This PR was merged into the 2.8 branch.Discussion----------[PropertyInfo] Don't try to access a property thru a static method| Q             | A| ------------- | ---| Branch?       | 2.8| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aSee also#21331.Commits-------3b4858f [PropertyInfo] Don't try to access a property thru a static method
@teohhanhui
Copy link
Contributor

Again like inapi-platform/core#914, I'm curious about the rationale behind this... Since there's no explanation given.

@dunglas
Copy link
MemberAuthor

dunglas commentedJan 23, 2017
edited
Loading

@teohhanhui if you have an entity like the following:

<?php// src/AppBundle/Entity/Book.phpuseApiPlatform\Core\Annotation\ApiResource;useSymfony\Component\Validator\ConstraintsasAssert;/** * @ApiResource(attributes={"validation_groups"={Book::class, "getValidationGroups"}}) */class Book{/**     * Return dynamic validation groups.     *     * @param self $book Contains the instance of Book to validate.     *     * @return string[]     */publicstaticfunctiongetValidationGroups(self$book)    {return ['a'];    }/**     * @Assert\NotBlank(groups={"a"})     */private$name;/**     * @Assert\NotNull(groups={"b"})     */private$author;// ...}

The extractor will include "validationGroups" in the list of properties of the entityBook. It's definitely a bug, static methods should be excluded.

@teohhanhui
Copy link
Contributor

teohhanhui commentedJan 23, 2017 via email

Static properties / methods could be used for a variety of reasons (Ibelieve there are valid use cases where properties are represented assuch). I don't see why PropertyInfo should make the decision for the userto exclude them.
On Mon, 23 Jan 2017, 17:50 Kévin Dunglas, ***@***.***> wrote:@teohhanhui <https://github.com/teohhanhui> if you have an entity like the following: <?php// src/AppBundle/Entity/Book.phpuse ApiPlatform\Core\Annotation\ApiResource;use Symfony\Component\Validator\Constraints as Assert;/** * @ApiResource(attributes={"validation_groups"={Book::class, "validationGroups"}}) */class Book{ /** * Return dynamic validation groups. * *@param self $book Contains the instance of Book to validate. * *@return string[] */ public static function getValidationGroups(self $book) { return ['a']; } /** *@Assert\NotBlank(groups={"a"}) */ private $name; /** *@Assert\NotNull(groups={"b"}) */ private $author; // ...} The extractor will include "validationGroups" in the list of properties of the entity Book. It's definitely a bug, static methods should be excluded. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#21331 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAhf6yMCQsM49ouZKVmBQSYbbwuVi3bRks5rVHfegaJpZM4Lmzua> .

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@dunglas@stof@fabpot@teohhanhui@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp