Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
schmittjoh#367 Exclude annotation not preventing attempt to find publ…
Browse files Browse the repository at this point in the history
…ic methods when using AccessType

Attempt to find getters and setters only if property included to serialization
  • Loading branch information
Strate authored and Rob Sworder committed May 1, 2015
1 parent 363186a commit 67d9f83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/JMS/Serializer/Metadata/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ public function loadMetadataForClass(\ReflectionClass $class)
}
}

$propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]);

if ((ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude)
|| (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose)) {
$propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]);
$classMetadata->addPropertyMetadata($propertyMetadata);
}
}
Expand Down
7 changes: 7 additions & 0 deletions tests/JMS/Serializer/Tests/Fixtures/GetSetObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace JMS\Serializer\Tests\Fixtures;

use JMS\Serializer\Annotation\AccessType;
use JMS\Serializer\Annotation\Exclude;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\ReadOnly;

Expand All @@ -36,6 +37,12 @@ class GetSetObject
*/
private $readOnlyProperty = 42;

/**
* This property should be exlcluded
* @Exclude()
*/
private $excludedProperty;

public function getId()
{
throw new \RuntimeException('This should not be called.');
Expand Down

0 comments on commit 67d9f83

Please sign in to comment.