-
-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
185 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JMS\Serializer\Annotation; | ||
|
||
use JMS\Serializer\Exception\InvalidArgumentException; | ||
|
||
trait AnnotationUtilsTrait | ||
{ | ||
private function loadAnnotationParameters(array $vars): void | ||
{ | ||
if (!array_key_exists('values', $vars)) { | ||
$values = []; | ||
} elseif (!is_array($vars['values'])) { | ||
$values = ['value' => $vars['values']]; | ||
} else { | ||
$values = $vars['values']; | ||
} | ||
|
||
unset($vars['values']); | ||
|
||
if (array_key_exists('value', $values)) { | ||
$values[key($vars)] = $values['value']; | ||
unset($values['value']); | ||
} | ||
|
||
foreach ($values as $key => $value) { | ||
$vars[$key] = $value; | ||
} | ||
|
||
foreach ($vars as $key => $value) { | ||
if (!property_exists(static::class, $key)) { | ||
throw new InvalidArgumentException(sprintf('Unknown property "%s" on annotation "%s".', $key, static::class)); | ||
} | ||
|
||
$this->{$key} = $value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.