-
-
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.
Merge branch 'union-types-discriminated' of github.com:idbentley/seri…
…alizer into idbentley-union-types-discriminated
- Loading branch information
Showing
12 changed files
with
372 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JMS\Serializer\Annotation; | ||
|
||
/** | ||
* @Annotation | ||
* @Target({"PROPERTY"}) | ||
*/ | ||
#[\Attribute(\Attribute::TARGET_PROPERTY)] | ||
final class UnionDiscriminator implements SerializerAttribute | ||
{ | ||
use AnnotationUtilsTrait; | ||
|
||
/** @var array<string> */ | ||
public $map = []; | ||
|
||
/** @var string */ | ||
public $field = 'type'; | ||
|
||
public function __construct(array $values = [], string $field = 'type', array $map = []) | ||
{ | ||
$this->loadAnnotationParameters(get_defined_vars()); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JMS\Serializer\Tests\Fixtures; | ||
|
||
use JMS\Serializer\Annotation\SerializedName; | ||
use JMS\Serializer\Annotation\Type; | ||
|
||
class DiscriminatedAuthor | ||
{ | ||
/** | ||
* @Type("string") | ||
* @SerializedName("full_name") | ||
*/ | ||
#[Type(name: 'string')] | ||
#[SerializedName(name: 'full_name')] | ||
private $name; | ||
|
||
/** | ||
* @Type("string") | ||
* @SerializedName("objectType") | ||
*/ | ||
#[Type(name: 'string')] | ||
#[SerializedName(name: 'objectType')] | ||
private $objectType = 'author'; | ||
|
||
public function __construct($name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function getObjectType() | ||
{ | ||
return $this->objectType; | ||
} | ||
} |
Oops, something went wrong.