From cba9112537543f82ee920926a28bd7689871529f Mon Sep 17 00:00:00 2001 From: patrykbaszak Date: Wed, 24 Jul 2024 11:46:01 +0200 Subject: [PATCH 1/3] fix: Corrected Attributes --- .../Application/Model/ClassBuildContext.php | 9 +++++++++ .../Application/Model/PropertyBuildContext.php | 2 +- src/Mapper/Application/Attribute/Accessor.php | 2 +- .../Attribute/ApplyToCollectionItem.php | 4 ++-- src/Mapper/Application/Attribute/Callback.php | 2 +- .../Application/Attribute/Discriminator.php | 2 +- src/Mapper/Application/Attribute/Groups.php | 2 +- src/Mapper/Application/Attribute/Ignore.php | 2 +- src/Mapper/Application/Attribute/MaxDepth.php | 2 +- .../Application/Attribute/SimpleObject.php | 2 +- .../Application/Attribute/TargetPropertyName.php | 2 +- .../Application/Attribute/TargetPropertyPath.php | 2 +- ...er_tests_assets_dummysimplewithattribute.yaml | 16 ++++++++-------- 13 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 src/Build/Application/Model/ClassBuildContext.php diff --git a/src/Build/Application/Model/ClassBuildContext.php b/src/Build/Application/Model/ClassBuildContext.php new file mode 100644 index 0000000..505f63b --- /dev/null +++ b/src/Build/Application/Model/ClassBuildContext.php @@ -0,0 +1,9 @@ + */ + /** @var array where the key is from AccessOption */ public array $accessOptions = []; } diff --git a/src/Mapper/Application/Attribute/Accessor.php b/src/Mapper/Application/Attribute/Accessor.php index 796a147..aabfbf3 100644 --- a/src/Mapper/Application/Attribute/Accessor.php +++ b/src/Mapper/Application/Attribute/Accessor.php @@ -25,7 +25,7 @@ public function __construct( ) { } - public function validate(\ReflectionProperty|\ReflectionParameter|\ReflectionClass $reflection): void + public function validate(\Reflector $reflector): void { // todo implement } diff --git a/src/Mapper/Application/Attribute/ApplyToCollectionItem.php b/src/Mapper/Application/Attribute/ApplyToCollectionItem.php index d83e28f..92f1313 100644 --- a/src/Mapper/Application/Attribute/ApplyToCollectionItem.php +++ b/src/Mapper/Application/Attribute/ApplyToCollectionItem.php @@ -20,8 +20,8 @@ public function __construct( ) { } - /** @param \ReflectionProperty $reflection */ - public function validate(\ReflectionProperty|\ReflectionParameter|\ReflectionClass $reflection): void + /** @param \ReflectionProperty $reflector */ + public function validate(\Reflector $reflector): void { // $class = $reflection->getDeclaringClass(); diff --git a/src/Mapper/Application/Attribute/Callback.php b/src/Mapper/Application/Attribute/Callback.php index c9ef7ed..539ebfb 100644 --- a/src/Mapper/Application/Attribute/Callback.php +++ b/src/Mapper/Application/Attribute/Callback.php @@ -107,7 +107,7 @@ public function __construct( ) { } - public function validate(\ReflectionProperty|\ReflectionParameter|\ReflectionClass $reflection): void + public function validate(\Reflector $reflector): void { // todo: update the list of available placeholders // if (str_replace([ diff --git a/src/Mapper/Application/Attribute/Discriminator.php b/src/Mapper/Application/Attribute/Discriminator.php index 9dec163..0238570 100644 --- a/src/Mapper/Application/Attribute/Discriminator.php +++ b/src/Mapper/Application/Attribute/Discriminator.php @@ -33,7 +33,7 @@ public function __construct( ) { } - public function validate(\ReflectionProperty|\ReflectionParameter|\ReflectionClass $reflection): void + public function validate(\Reflector $reflector): void { // todo implement } diff --git a/src/Mapper/Application/Attribute/Groups.php b/src/Mapper/Application/Attribute/Groups.php index 467d681..1e1bd51 100644 --- a/src/Mapper/Application/Attribute/Groups.php +++ b/src/Mapper/Application/Attribute/Groups.php @@ -27,7 +27,7 @@ public function __construct( $this->groups = is_array($groups) ? $groups : [$groups]; } - public function validate(\ReflectionProperty|\ReflectionParameter|\ReflectionClass $reflection): void + public function validate(\Reflector $reflector): void { // todo implement } diff --git a/src/Mapper/Application/Attribute/Ignore.php b/src/Mapper/Application/Attribute/Ignore.php index cbaf0d2..1899f7b 100644 --- a/src/Mapper/Application/Attribute/Ignore.php +++ b/src/Mapper/Application/Attribute/Ignore.php @@ -22,7 +22,7 @@ public function __construct( ) { } - public function validate(\ReflectionProperty|\ReflectionParameter|\ReflectionClass $reflection): void + public function validate(\Reflector $reflector): void { // todo implement } diff --git a/src/Mapper/Application/Attribute/MaxDepth.php b/src/Mapper/Application/Attribute/MaxDepth.php index 6597dea..626067d 100644 --- a/src/Mapper/Application/Attribute/MaxDepth.php +++ b/src/Mapper/Application/Attribute/MaxDepth.php @@ -25,7 +25,7 @@ public function __construct( ) { } - public function validate(\ReflectionProperty|\ReflectionParameter|\ReflectionClass $reflection): void + public function validate(\Reflector $reflector): void { // todo implement } diff --git a/src/Mapper/Application/Attribute/SimpleObject.php b/src/Mapper/Application/Attribute/SimpleObject.php index a56d19c..c322e6e 100644 --- a/src/Mapper/Application/Attribute/SimpleObject.php +++ b/src/Mapper/Application/Attribute/SimpleObject.php @@ -30,7 +30,7 @@ public function __construct( ) { } - public function validate(\ReflectionProperty|\ReflectionParameter|\ReflectionClass $reflection): void + public function validate(\Reflector $reflector): void { // todo implement } diff --git a/src/Mapper/Application/Attribute/TargetPropertyName.php b/src/Mapper/Application/Attribute/TargetPropertyName.php index 1a0b632..3cc91f5 100644 --- a/src/Mapper/Application/Attribute/TargetPropertyName.php +++ b/src/Mapper/Application/Attribute/TargetPropertyName.php @@ -23,7 +23,7 @@ public function __construct( ) { } - public function validate(\ReflectionProperty|\ReflectionParameter|\ReflectionClass $reflection): void + public function validate(\Reflector $reflector): void { // there cannot be two target properties with the same processType // todo implement diff --git a/src/Mapper/Application/Attribute/TargetPropertyPath.php b/src/Mapper/Application/Attribute/TargetPropertyPath.php index ed13a20..da8d36a 100644 --- a/src/Mapper/Application/Attribute/TargetPropertyPath.php +++ b/src/Mapper/Application/Attribute/TargetPropertyPath.php @@ -23,7 +23,7 @@ public function __construct( ) { } - public function validate(\ReflectionProperty|\ReflectionParameter|\ReflectionClass $reflection): void + public function validate(\Reflector $reflector): void { // there cannot be two target properties with the same processType // todo implement diff --git a/tests/Assets/pbaszak_ultramapper_tests_assets_dummysimplewithattribute.yaml b/tests/Assets/pbaszak_ultramapper_tests_assets_dummysimplewithattribute.yaml index 042a1fb..570cade 100644 --- a/tests/Assets/pbaszak_ultramapper_tests_assets_dummysimplewithattribute.yaml +++ b/tests/Assets/pbaszak_ultramapper_tests_assets_dummysimplewithattribute.yaml @@ -114,15 +114,15 @@ blueprints: defaultValue: null filesHashes: /app/tests/Assets/DummySimpleWithAttribute.php: 5de157db33ad5536dfb49fe841a058a3 - /app/src/Mapper/Application/Attribute/Callback.php: 7ba81d4a5d36143504c6bcc2909e6a1c - /app/src/Mapper/Application/Attribute/Ignore.php: 3ff46e0eb1d09e4a9d5b7c97302034de + /app/src/Mapper/Application/Attribute/Callback.php: a8b352f51ce806632b4d7754b7bf5e91 + /app/src/Mapper/Application/Attribute/Ignore.php: d8e23944de7bbbf374804f401dbf8b9f events: - 'Blueprint created. Root class: PBaszak\UltraMapper\Tests\Assets\DummySimpleWithAttribute.' - 'Class Blueprint PBaszak\UltraMapper\Tests\Assets\DummySimpleWithAttribute added. Blueprint name: pbaszak_ultramapper_tests_assets_dummysimplewithattribute.' - 'File hash added. File: /app/tests/Assets/DummySimpleWithAttribute.php, hash: 5de157db33ad5536dfb49fe841a058a3.' - - 'File hash added. File: /app/src/Mapper/Application/Attribute/Callback.php, hash: 7ba81d4a5d36143504c6bcc2909e6a1c.' - - 'File hash already exists. File: /app/src/Mapper/Application/Attribute/Callback.php, hash: 7ba81d4a5d36143504c6bcc2909e6a1c.' - - 'File hash added. File: /app/src/Mapper/Application/Attribute/Ignore.php, hash: 3ff46e0eb1d09e4a9d5b7c97302034de.' - - 'File hash already exists. File: /app/src/Mapper/Application/Attribute/Callback.php, hash: 7ba81d4a5d36143504c6bcc2909e6a1c.' - - 'File hash already exists. File: /app/src/Mapper/Application/Attribute/Callback.php, hash: 7ba81d4a5d36143504c6bcc2909e6a1c.' - - 'File hash already exists. File: /app/src/Mapper/Application/Attribute/Ignore.php, hash: 3ff46e0eb1d09e4a9d5b7c97302034de.' + - 'File hash added. File: /app/src/Mapper/Application/Attribute/Callback.php, hash: a8b352f51ce806632b4d7754b7bf5e91.' + - 'File hash already exists. File: /app/src/Mapper/Application/Attribute/Callback.php, hash: a8b352f51ce806632b4d7754b7bf5e91.' + - 'File hash added. File: /app/src/Mapper/Application/Attribute/Ignore.php, hash: d8e23944de7bbbf374804f401dbf8b9f.' + - 'File hash already exists. File: /app/src/Mapper/Application/Attribute/Callback.php, hash: a8b352f51ce806632b4d7754b7bf5e91.' + - 'File hash already exists. File: /app/src/Mapper/Application/Attribute/Callback.php, hash: a8b352f51ce806632b4d7754b7bf5e91.' + - 'File hash already exists. File: /app/src/Mapper/Application/Attribute/Ignore.php, hash: d8e23944de7bbbf374804f401dbf8b9f.' From 4f57afb95fafdd46f0d00986d6c5482c999b1349 Mon Sep 17 00:00:00 2001 From: patrykbaszak Date: Wed, 24 Jul 2024 17:30:13 +0200 Subject: [PATCH 2/3] fix: Added build context options key --- src/Blueprint/Application/Model/Assets/ClassBlueprint.php | 2 ++ src/Blueprint/Application/Model/Assets/PropertyBlueprint.php | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Blueprint/Application/Model/Assets/ClassBlueprint.php b/src/Blueprint/Application/Model/Assets/ClassBlueprint.php index 44e0fea..31c80c3 100644 --- a/src/Blueprint/Application/Model/Assets/ClassBlueprint.php +++ b/src/Blueprint/Application/Model/Assets/ClassBlueprint.php @@ -15,6 +15,8 @@ class ClassBlueprint implements Normalizable { use GetAttributes; + public const OPTIONS_BUILD_CONTEXT = 'buildContext'; + /** @var array */ public array $options = []; diff --git a/src/Blueprint/Application/Model/Assets/PropertyBlueprint.php b/src/Blueprint/Application/Model/Assets/PropertyBlueprint.php index 574c7f5..6cdfbc1 100644 --- a/src/Blueprint/Application/Model/Assets/PropertyBlueprint.php +++ b/src/Blueprint/Application/Model/Assets/PropertyBlueprint.php @@ -15,6 +15,7 @@ class PropertyBlueprint implements Normalizable public const OPTIONS_NAME = 'name'; public const OPTIONS_PATH = 'path'; + public const OPTIONS_BUILD_CONTEXT = 'buildContext'; /** @var array */ public array $options = []; From 039374d9226c99b417303840af275bb8c6ead60e Mon Sep 17 00:00:00 2001 From: patrykbaszak Date: Thu, 25 Jul 2024 15:59:59 +0200 Subject: [PATCH 3/3] fix: removed unnecessary import --- src/Build/Application/Model/PropertyBuildContext.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Build/Application/Model/PropertyBuildContext.php b/src/Build/Application/Model/PropertyBuildContext.php index e3e8135..cd80343 100644 --- a/src/Build/Application/Model/PropertyBuildContext.php +++ b/src/Build/Application/Model/PropertyBuildContext.php @@ -4,7 +4,6 @@ namespace PBaszak\UltraMapper\Build\Application\Model; -use PBaszak\UltraMapper\Build\Application\Model\Enum\AccessOption; use PBaszak\UltraMapper\Build\Application\Model\Enum\AccessType; class PropertyBuildContext