diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e0e2bb..cc8f997 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 0.3.1 + +- Deprecated calling `types::alias()`, `types::template()` and `types::object()` with named arguments. diff --git a/types.php b/types.php index 843a93e..4a2b432 100644 --- a/types.php +++ b/types.php @@ -47,7 +47,13 @@ enum types implements Type */ public static function alias(string $class, string $name, Type ...$arguments): Type { - return new Internal\AliasType($class, $name, array_values($arguments)); + if (!array_is_list($arguments)) { + trigger_deprecation('typhoon/type', '0.3.1', 'Calling %s() with named arguments is deprecated.', __METHOD__); + /** @var list */ + $arguments = array_values($arguments); + } + + return new Internal\AliasType($class, $name, $arguments); } /** @@ -344,7 +350,13 @@ public static function object(string $class, Type ...$arguments): Type return self::closure; } - return new Internal\NamedObjectType($class, array_values($arguments)); + if (!array_is_list($arguments)) { + trigger_deprecation('typhoon/type', '0.3.1', 'Calling %s() with named arguments is deprecated.', __METHOD__); + /** @var list */ + $arguments = array_values($arguments); + } + + return new Internal\NamedObjectType($class, $arguments); } /** @@ -389,7 +401,13 @@ public static function prop(Type $type, bool $optional = false): Property */ public static function template(string $name, AtMethod|AtClass|AtFunction $declaredAt, Type ...$arguments): Type { - return new Internal\TemplateType($name, $declaredAt, array_values($arguments)); + if (!array_is_list($arguments)) { + trigger_deprecation('typhoon/type', '0.3.1', 'Calling %s() with named arguments is deprecated.', __METHOD__); + /** @var list */ + $arguments = array_values($arguments); + } + + return new Internal\TemplateType($name, $declaredAt, $arguments); } /**