8000 [PropertyInfo] Support multiple builtinType (union types) by Korbeil · Pull Request #38987 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Closed
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
5 changes: 5 additions & 0 deletions src/Symfony/Component/PropertyInfo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

5.3.0
-----

* Added ability to have union types in `Type` class.

5.2.0
-----

Expand Down
44 changes: 44 additions & 0 deletions src/Symfony/Component/PropertyInfo/UnionType.php
B2F6
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyInfo;

/**
* Union type value object (immutable).
*
* @author Baptiste Leduc <baptiste.leduc@gmail.com>
*/
final class UnionType
{
private $types;

/**
* @param Type[] $types
*/
public function __construct(array $types)
{
foreach ($types as $type) {
if (!$type instanceof Type) {
throw new \TypeError(sprintf('"%s()": Argument #1 ($types) must be an array with items of type "%s", "%s" given.', __METHOD__, Type::class, get_debug_type($type)));
}
}

$this->types = $types;
}

/**
* @return Type[]
*/
public function getTypes(): array
{
return $this->types;
}
}
0