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

Exclude annotation not preventing attempt to find public methods when using AccessType #367

Closed
andrewboerema opened this issue Nov 24, 2014 · 6 comments

Comments

@andrewboerema
Copy link

I have discovered an issue where, if you set AccessType("public_method") on a class, Exclude annotations on that class's properties are ignored. Ex:

<?php
namespace Application\Fruits;

use JMS\Serializer\Annotation as JMS;

/**
 * Class Bananas
 *
 * @package Application\Fruits
 * @JMS\AccessType("public_method")
 */
class Bananas {
    /**
     * @var array
     * @JMS\Exclude
     */
    private static $acceptedStatuses = array(
        'Approved',
        'Pending',
    );
    ...
}

In this case, I get the error "There is neither a public getAcceptedStatuses method, nor a public isAcceptedStatuses method, nor a public hasAcceptedStatuses method in class Application\Model\RedOakPage. Please specify which public method should be used for retrieving the value of the property acceptedStatuses."

It would be my understanding that the more specific Exclude annotation on the property would override the class-level annotation of AccessType. If that isn't true, this isn't a defect, but it should be made clear on the docs for AccessType.

@nitso
Copy link

nitso commented Dec 14, 2014

+1

1 similar comment
@Strate
Copy link
Contributor

Strate commented Feb 11, 2015

+1

Strate added a commit to Strate/serializer that referenced this issue Feb 11, 2015
…ic methods when using AccessType

Attempt to find getters and setters only if property included to serialization
@Nemo64
Copy link

Nemo64 commented Feb 28, 2015

still no fix?

sword pushed a commit to lovecrafts/serializer that referenced this issue May 1, 2015
…ic methods when using AccessType

Attempt to find getters and setters only if property included to serialization
@mattjanssen
Copy link

PR #397

@detook
Copy link

detook commented Aug 1, 2016

+1

goetas added a commit that referenced this issue Aug 3, 2016
#367 Exclude annotation not preventing attempt to find public methods when using AccessType
@goetas
Copy link
Collaborator

goetas commented Aug 3, 2016

PR has been merged

@goetas goetas closed this as completed Aug 3, 2016
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

No branches or pull requests

7 participants