Skip to content

Commit

Permalink
Fix serialiazation with validation and groups
Browse files Browse the repository at this point in the history
  • Loading branch information
sghribi committed Jul 9, 2015
1 parent 787f695 commit 24fd099
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Parser/JmsMetadataParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function supports(array $input)
public function parse(array $input)
{
$className = $input['class'];
$groups = $input['groups'];
$groups = !empty($input['groups']) ? $input['groups'] : array("Default");

This comment has been minimized.

Copy link
@phansys

phansys Dec 5, 2016

You could simplify this construction as $groups = $input['groups'] ?: array('Default');. BTW, use simple quotes please.


return $this->doParse($className, array(), $groups);
}
Expand Down Expand Up @@ -133,6 +133,7 @@ protected function doParse($className, $visited = array(), array $groups = array
// apply exclusion strategies
foreach ($exclusionStrategies as $strategy) {
if (true === $strategy->shouldSkipProperty($item, SerializationContext::create())) {
$params[$name] = null;
continue 2;
}
}
Expand Down Expand Up @@ -273,6 +274,12 @@ public function postParse(array $input, array $parameters)
*/
protected function doPostParse (array $parameters, array $visited = array(), array $groups = array())
{
foreach ($parameters as $param => $data) {

This comment has been minimized.

Copy link
@phansys

phansys Dec 5, 2016

!isset() can deliver better performance here.

if (!array_key_exists('description', $data)) {
$parameters[$param] = null;
}
}

foreach ($parameters as $param => $data) {
if (isset($data['class']) && isset($data['children']) && !in_array($data['class'], $visited)) {
$visited[] = $data['class'];
Expand Down

0 comments on commit 24fd099

Please sign in to comment.