From f3e8075839e9655d68c7f42ecfdcebc6b41ef6eb Mon Sep 17 00:00:00 2001 From: vognev Date: Thu, 2 Mar 2023 10:44:37 +0600 Subject: [PATCH] change type of $handleTypes arg to iterable and add Symfony Configuring info to readme --- README.md | 15 +++++++++++++++ src/ObjectHandler.php | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bb13bd8..68d9015 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,21 @@ Install the latest version with $ composer require omasn/object-handler ``` +### Symfony Configuring + +``` +services: + _instanceof: + Omasn\ObjectHandler\HandleTypeInterface: + tags: [ 'omasn.objectHandlerType' ] + + Omasn\ObjectHandler\ObjectHandlerInterface: + class: Omasn\ObjectHandler\ObjectHandler + autowire: true + bind: + $handleTypes: !tagged_iterator omasn.objectHandlerType +``` + ## Basic Usage ```php diff --git a/src/ObjectHandler.php b/src/ObjectHandler.php index cde1cf6..4bb7553 100644 --- a/src/ObjectHandler.php +++ b/src/ObjectHandler.php @@ -30,7 +30,7 @@ final class ObjectHandler extends AbstractHandler /** * @var HandleTypeInterface[] */ - protected array $handleTypes = []; + protected iterable $handleTypes = []; private PropertyInfoExtractorInterface $propertyInfoExtractor; private PropertyAccessorInterface $propertyAccessor; @@ -40,7 +40,7 @@ final class ObjectHandler extends AbstractHandler * @param HandleTypeInterface[]|callable[] $handleTypes */ public function __construct( - array $handleTypes, + iterable $handleTypes, PropertyInfoExtractorInterface $propertyInfoExtractor, PropertyAccessorInterface $propertyAccessor = null, ViolationFactoryInterface $violationFactory = null