diff --git a/src/Symfony/Component/PropertyInfo/CHANGELOG.md b/src/Symfony/Component/PropertyInfo/CHANGELOG.md index 75621067ad0cf..bfa4d127adbcf 100644 --- a/src/Symfony/Component/PropertyInfo/CHANGELOG.md +++ b/src/Symfony/Component/PropertyInfo/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.3.0 +----- + +* Added ability to have union types in `Type` class. + 5.2.0 ----- diff --git a/src/Symfony/Component/PropertyInfo/UnionType.php b/src/Symfony/Component/PropertyInfo/UnionType.php new file mode 100644 index 0000000000000..e22d266cd6044 --- /dev/null +++ b/src/Symfony/Component/PropertyInfo/UnionType.php @@ -0,0 +1,44 @@ + + * + * 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 + */ +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; + } +}