From 387497c774b68f5598a54da32da0c0a4a850617d Mon Sep 17 00:00:00 2001 From: Edward Surov Date: Thu, 25 May 2023 17:14:22 +0300 Subject: [PATCH] labels are exposed in reverse order (fixes #34, via #57) --- composer.json | 6 +- phpunit.xml.dist | 3 +- src/Attribute/AttributeParser.php | 3 +- src/Model/ModelProviderChain.php | 11 +- test/AllureLifecycleTest.php | 58 +++++-- test/Attribute/AttributeParserTest.php | 211 +++++++++++++++++++++++++ test/Model/ModelProviderChainTest.php | 4 +- test/Model/TemporaryTest.php | 3 + 8 files changed, 276 insertions(+), 23 deletions(-) create mode 100644 test/Attribute/AttributeParserTest.php diff --git a/composer.json b/composer.json index c9c9e6e..5f45476 100644 --- a/composer.json +++ b/composer.json @@ -35,10 +35,10 @@ }, "require-dev": { "jetbrains/phpstorm-attributes": "^1", - "phpunit/phpunit": "^9.5.10", + "phpunit/phpunit": "^9.6.8", "psalm/plugin-phpunit": "^0.18.4", - "squizlabs/php_codesniffer": "^3.7.1", - "vimeo/psalm": "^5.4" + "squizlabs/php_codesniffer": "^3.7.2", + "vimeo/psalm": "^5.12" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c91d200..e094557 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,8 +1,9 @@ diff --git a/src/Attribute/AttributeParser.php b/src/Attribute/AttributeParser.php index ae590cb..215ce6d 100644 --- a/src/Attribute/AttributeParser.php +++ b/src/Attribute/AttributeParser.php @@ -18,6 +18,7 @@ use ReflectionProperty; use function array_merge; +use function array_reverse; use function is_string; final class AttributeParser implements ModelProviderInterface @@ -161,7 +162,7 @@ private function createLabel(LabelInterface $label): Model\Label */ public function getLabels(): array { - return $this->labels; + return array_reverse($this->labels); } private function createParameter(ParameterInterface $parameter): Model\Parameter diff --git a/src/Model/ModelProviderChain.php b/src/Model/ModelProviderChain.php index cee154c..9599813 100644 --- a/src/Model/ModelProviderChain.php +++ b/src/Model/ModelProviderChain.php @@ -6,6 +6,7 @@ use function array_map; use function array_merge; +use function array_reverse; use function array_values; final class ModelProviderChain implements ModelProviderInterface @@ -40,10 +41,12 @@ public function getLinks(): array public function getLabels(): array { return array_merge( - ...array_map( - /** @psalm-return list