Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,13 @@ public function getAttributes(

if (!isset($attributes[$attributeName])) {
$attributes[$attributeName] = [
'readable' => false,
'writable' => false,
'description' => (new DocBlock($reflMethod))->getShortDescription(),
];
}

if (0 === $reflMethod->getNumberOfRequiredParameters()) {
$attributes[$attributeName]['readable'] = true;
} else {
} elseif (0 === strpos($methodName, 'set')) {
$attributes[$attributeName]['writable'] = true;
}
}
Expand All @@ -196,6 +194,11 @@ public function getAttributes(

// populate attributes
foreach ($attributes as $attributeName => $attribute) {
if (!isset($attribute['readable']) && !isset($attribute['writable'])) {
unset($attributes[$attributeName]);
continue;
}

$this->populateAttribute($attributeName, $attributes[$attributeName], $validationGroups);
}
}
Expand Down Expand Up @@ -288,8 +291,8 @@ private function populateAttribute($name, array &$attribute, array $validationGr
$attribute['readable'] = false;
}

if (!isset($attribute['writeable'])) {
$attribute['writeable'] = false;
if (!isset($attribute['writable'])) {
$attribute['writable'] = false;
}

foreach ($this->validatorClassMetadata->getPropertyMetadata($name) as $propertyMetadata) {
Expand Down
5 changes: 5 additions & 0 deletions Tests/Behat/TestBundle/Entity/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ public function getName()
{
return $this->name;
}

public function hasRole($role)
{

}
}