From 53954031b507c30e82cf0bd3e87460c0b437c344 Mon Sep 17 00:00:00 2001 From: Thomas Picquet Date: Fri, 28 Jan 2022 07:30:39 -0800 Subject: [PATCH 1/6] Fixed Areas attribute to work like the documentation specifies --- Annotation/Areas.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Annotation/Areas.php b/Annotation/Areas.php index c4bf48f..384b9fe 100644 --- a/Annotation/Areas.php +++ b/Annotation/Areas.php @@ -22,12 +22,12 @@ final class Areas public function __construct(array $properties) { - if (!array_key_exists('value', $properties) || !is_array($properties['value'])) { + if ($properties === []) { throw new \InvalidArgumentException('An array of areas was expected'); } $areas = []; - foreach ($properties['value'] as $area) { + foreach ($properties as $area) { if (!is_string($area)) { throw new \InvalidArgumentException('An area must be given as a string'); } From ebde54f25107a04b32c5db4a5f29351b7e7fedde Mon Sep 17 00:00:00 2001 From: Thomas Picquet Date: Fri, 28 Jan 2022 07:34:08 -0800 Subject: [PATCH 2/6] style fix --- Annotation/Areas.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Annotation/Areas.php b/Annotation/Areas.php index 384b9fe..805275d 100644 --- a/Annotation/Areas.php +++ b/Annotation/Areas.php @@ -22,7 +22,7 @@ final class Areas public function __construct(array $properties) { - if ($properties === []) { + if ([] === $properties) { throw new \InvalidArgumentException('An array of areas was expected'); } From 11f61af93b9a26e64a734d4eb371a3adf6090f99 Mon Sep 17 00:00:00 2001 From: Thomas Picquet Date: Fri, 28 Jan 2022 07:37:28 -0800 Subject: [PATCH 3/6] keep it BC --- Annotation/Areas.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Annotation/Areas.php b/Annotation/Areas.php index 805275d..bd173cb 100644 --- a/Annotation/Areas.php +++ b/Annotation/Areas.php @@ -22,12 +22,17 @@ final class Areas public function __construct(array $properties) { + + if (!array_key_exists('value', $properties) || !is_array($properties['value'])) { + $properties = array_values($properties); + } + if ([] === $properties) { throw new \InvalidArgumentException('An array of areas was expected'); } $areas = []; - foreach ($properties as $area) { + foreach ($properties['value'] as $area) { if (!is_string($area)) { throw new \InvalidArgumentException('An area must be given as a string'); } From 5b5121476527f99585e18574a8a43739f1490dae Mon Sep 17 00:00:00 2001 From: Thomas Picquet Date: Fri, 28 Jan 2022 07:38:19 -0800 Subject: [PATCH 4/6] styleci fix --- Annotation/Areas.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Annotation/Areas.php b/Annotation/Areas.php index bd173cb..b81272f 100644 --- a/Annotation/Areas.php +++ b/Annotation/Areas.php @@ -22,7 +22,6 @@ final class Areas public function __construct(array $properties) { - if (!array_key_exists('value', $properties) || !is_array($properties['value'])) { $properties = array_values($properties); } From f363eeef664904b621f876e4ae8598181bbe65f3 Mon Sep 17 00:00:00 2001 From: Thomas Picquet Date: Fri, 28 Jan 2022 07:40:09 -0800 Subject: [PATCH 5/6] set value key --- Annotation/Areas.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Annotation/Areas.php b/Annotation/Areas.php index b81272f..8e8d588 100644 --- a/Annotation/Areas.php +++ b/Annotation/Areas.php @@ -23,7 +23,7 @@ final class Areas public function __construct(array $properties) { if (!array_key_exists('value', $properties) || !is_array($properties['value'])) { - $properties = array_values($properties); + $properties['value'] = array_values($properties); } if ([] === $properties) { From 405a5247e132191696b834bd7aabde969de65b40 Mon Sep 17 00:00:00 2001 From: Thomas Picquet Date: Wed, 2 Feb 2022 08:47:26 -0800 Subject: [PATCH 6/6] check `$properties['value']` is not empty --- Annotation/Areas.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Annotation/Areas.php b/Annotation/Areas.php index 8e8d588..4d8c805 100644 --- a/Annotation/Areas.php +++ b/Annotation/Areas.php @@ -26,7 +26,7 @@ final class Areas $properties['value'] = array_values($properties); } - if ([] === $properties) { + if ([] === $properties['value']) { throw new \InvalidArgumentException('An array of areas was expected'); }