diff --git a/composer.json b/composer.json index b3d92d8dd..76e8e3763 100644 --- a/composer.json +++ b/composer.json @@ -50,8 +50,7 @@ "ramsey/uuid": "^4.5", "symfony/cache": "^6.2", "symfony/dotenv": "^6.2", - "symfony/uid": "^6.3", - "symfony/validator": "^5.4 || ^6.2" + "symfony/uid": "^6.3" }, "autoload": { "files": [ diff --git a/composer.lock b/composer.lock index 996681d84..dce923ea6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a8e8a5c56e8b9e8c00121aa4bd1c81e2", + "content-hash": "5ca5e11341c4d4282a130713419881b5", "packages": [ { "name": "amphp/amp", @@ -6729,86 +6729,6 @@ ], "time": "2023-01-26T09:26:14+00:00" }, - { - "name": "symfony/polyfill-php83", - "version": "v1.28.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php83.git", - "reference": "b0f46ebbeeeda3e9d2faebdfbf4b4eae9b59fa11" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/b0f46ebbeeeda3e9d2faebdfbf4b4eae9b59fa11", - "reference": "b0f46ebbeeeda3e9d2faebdfbf4b4eae9b59fa11", - "shasum": "" - }, - "require": { - "php": ">=7.1", - "symfony/polyfill-php80": "^1.14" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php83\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php83/tree/v1.28.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-08-16T06:22:46+00:00" - }, { "name": "symfony/polyfill-uuid", "version": "v1.28.0", @@ -6891,84 +6811,6 @@ ], "time": "2023-01-26T09:26:14+00:00" }, - { - "name": "symfony/translation-contracts", - "version": "v3.3.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/translation-contracts.git", - "reference": "02c24deb352fb0d79db5486c0c79905a85e37e86" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/02c24deb352fb0d79db5486c0c79905a85e37e86", - "reference": "02c24deb352fb0d79db5486c0c79905a85e37e86", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.4-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Translation\\": "" - }, - "exclude-from-classmap": [ - "/Test/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to translation", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v3.3.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-05-30T17:17:10+00:00" - }, { "name": "symfony/uid", "version": "v6.3.0", @@ -7043,102 +6885,6 @@ ], "time": "2023-04-08T07:25:02+00:00" }, - { - "name": "symfony/validator", - "version": "v6.3.5", - "source": { - "type": "git", - "url": "https://github.com/symfony/validator.git", - "reference": "48e815ba3b5eb72e632588dbf7ea2dc4e608ee47" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/validator/zipball/48e815ba3b5eb72e632588dbf7ea2dc4e608ee47", - "reference": "48e815ba3b5eb72e632588dbf7ea2dc4e608ee47", - "shasum": "" - }, - "require": { - "php": ">=8.1", - "symfony/deprecation-contracts": "^2.5|^3", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php83": "^1.27", - "symfony/translation-contracts": "^2.5|^3" - }, - "conflict": { - "doctrine/annotations": "<1.13", - "doctrine/lexer": "<1.1", - "symfony/dependency-injection": "<5.4", - "symfony/expression-language": "<5.4", - "symfony/http-kernel": "<5.4", - "symfony/intl": "<5.4", - "symfony/property-info": "<5.4", - "symfony/translation": "<5.4", - "symfony/yaml": "<5.4" - }, - "require-dev": { - "doctrine/annotations": "^1.13|^2", - "egulias/email-validator": "^2.1.10|^3|^4", - "symfony/cache": "^5.4|^6.0", - "symfony/config": "^5.4|^6.0", - "symfony/console": "^5.4|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/expression-language": "^5.4|^6.0", - "symfony/finder": "^5.4|^6.0", - "symfony/http-client": "^5.4|^6.0", - "symfony/http-foundation": "^5.4|^6.0", - "symfony/http-kernel": "^5.4|^6.0", - "symfony/intl": "^5.4|^6.0", - "symfony/mime": "^5.4|^6.0", - "symfony/property-access": "^5.4|^6.0", - "symfony/property-info": "^5.4|^6.0", - "symfony/translation": "^5.4|^6.0", - "symfony/yaml": "^5.4|^6.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Validator\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides tools to validate values", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/validator/tree/v6.3.5" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-09-29T07:41:15+00:00" - }, { "name": "symfony/var-exporter", "version": "v6.3.4", diff --git a/src/core/etl/docs/complex_transformers.md b/src/core/etl/docs/complex_transformers.md index 48c8d46a0..c0481a6eb 100644 --- a/src/core/etl/docs/complex_transformers.md +++ b/src/core/etl/docs/complex_transformers.md @@ -22,7 +22,6 @@ Available Filters - [entry number](../src/Flow/ETL/Transformer/Filter/Filter/EntryNumber.php) - [entry exists](../src/Flow/ETL/Transformer/Filter/Filter/EntryExists.php) - [opposite](../src/Flow/ETL/Transformer/Filter/Filter/Opposite.php) -- [valid value](../src/Flow/ETL/Transformer/Filter/Filter/ValidValue.php) - optionally integrates with [symfony validator](https://github.com/symfony/validator) #### Transformer - Conditional @@ -48,7 +47,6 @@ Available Conditions - [entry value less than](../src/Flow/ETL/Transformer/Condition/EntryValueLessThan.php) - [none](../src/Flow/ETL/Transformer/Condition/None.php) - [opposite](../src/Flow/ETL/Transformer/Condition/Opposite.php) -- [valid value](../src/Flow/ETL/Transformer/Condition/ValidValue) - optionally integrates with [Symfony Validator](https://github.com/symfony/validator) #### Transformer - Cast @@ -85,4 +83,4 @@ Available styles: * `dot` -[<< back](../README.md) \ No newline at end of file +[<< back](../README.md) diff --git a/src/core/etl/src/Flow/ETL/DSL/Condition.php b/src/core/etl/src/Flow/ETL/DSL/Condition.php index 0ecb2c26c..0e23bdb27 100644 --- a/src/core/etl/src/Flow/ETL/DSL/Condition.php +++ b/src/core/etl/src/Flow/ETL/DSL/Condition.php @@ -4,11 +4,9 @@ namespace Flow\ETL\DSL; -use Flow\ETL\Exception\RuntimeException; use Flow\ETL\Row\Entry; use Flow\ETL\Transformer\Condition as TransformerCondition; use Flow\ETL\Transformer\Condition\RowCondition; -use Symfony\Component\Validator\Constraint; /** * @infection-ignore-all @@ -120,15 +118,6 @@ final public static function is_string(string $entry) : RowCondition return new TransformerCondition\EntryInstanceOf($entry, Entry\StringEntry::class); } - final public static function is_valid(string $entry, Constraint ...$constraints) : RowCondition - { - if (!\class_exists('\Symfony\Component\Validator\Validation')) { - throw new RuntimeException("Symfony\Component\Validator\Validation class not found, please add symfony/validator dependency to the project first."); - } - - return new TransformerCondition\ValidValue($entry, new TransformerCondition\ValidValue\SymfonyValidator($constraints)); - } - final public static function less_or_equals_value(string $entry, mixed $value) : RowCondition { return new TransformerCondition\EntryValueLessOrEqualThan($entry, $value); diff --git a/src/core/etl/src/Flow/ETL/DSL/Transform.php b/src/core/etl/src/Flow/ETL/DSL/Transform.php index c67fd914d..68ae23ea9 100644 --- a/src/core/etl/src/Flow/ETL/DSL/Transform.php +++ b/src/core/etl/src/Flow/ETL/DSL/Transform.php @@ -30,14 +30,12 @@ use Flow\ETL\Transformer\Filter\Filter\EntryNotNull; use Flow\ETL\Transformer\Filter\Filter\EntryNumber; use Flow\ETL\Transformer\Filter\Filter\Opposite; -use Flow\ETL\Transformer\Filter\Filter\ValidValue; use Flow\ETL\Transformer\FilterRowsTransformer; use Flow\ETL\Transformer\KeepEntriesTransformer; use Flow\ETL\Transformer\Rename\EntryRename; use Flow\ETL\Transformer\RenameEntriesTransformer; use Flow\ETL\Transformer\StyleConverter\StringStyles; use Laminas\Hydrator\ReflectionHydrator; -use Symfony\Component\Validator\Constraint; /** * @infection-ignore-all @@ -166,11 +164,6 @@ final public static function filter_exists(string $entry) : Transformer return new FilterRowsTransformer(new EntryExists($entry)); } - final public static function filter_invalid(string $entry, Constraint ...$constraints) : Transformer - { - return new FilterRowsTransformer(new ValidValue($entry, new ValidValue\SymfonyValidator($constraints))); - } - final public static function filter_not_equals(string $entry, mixed $value) : Transformer { return new FilterRowsTransformer(new Opposite(new EntryEqualsTo($entry, $value))); @@ -201,11 +194,6 @@ final public static function filter_number(string $entry) : Transformer return new FilterRowsTransformer(new EntryNumber($entry)); } - final public static function filter_valid(string $entry, Constraint ...$constraints) : Transformer - { - return new FilterRowsTransformer(new Opposite(new ValidValue($entry, new ValidValue\SymfonyValidator($constraints)))); - } - final public static function group_to_array(string $group_by_entry, string $new_entry_name) : Transformer { return new Transformer\GroupToArrayTransformer($group_by_entry, $new_entry_name); diff --git a/src/core/etl/src/Flow/ETL/Transformer/Condition/ValidValue.php b/src/core/etl/src/Flow/ETL/Transformer/Condition/ValidValue.php deleted file mode 100644 index 01a45e586..000000000 --- a/src/core/etl/src/Flow/ETL/Transformer/Condition/ValidValue.php +++ /dev/null @@ -1,26 +0,0 @@ -entries()->has($this->entryName)) { - return false; - } - - return $this->validator->isValid($row->valueOf($this->entryName)); - } -} diff --git a/src/core/etl/src/Flow/ETL/Transformer/Condition/ValidValue/SymfonyValidator.php b/src/core/etl/src/Flow/ETL/Transformer/Condition/ValidValue/SymfonyValidator.php deleted file mode 100644 index ac0f9824d..000000000 --- a/src/core/etl/src/Flow/ETL/Transformer/Condition/ValidValue/SymfonyValidator.php +++ /dev/null @@ -1,33 +0,0 @@ - $constraints - * @param null|ValidatorInterface $validator - */ - public function __construct(private readonly array $constraints = [], ValidatorInterface $validator = null) - { - $this->validator = $validator ?: Validation::createValidator(); - } - - public function isValid(mixed $value) : bool - { - return $this->validator->validate($value, $this->constraints)->count() === 0; - } -} diff --git a/src/core/etl/src/Flow/ETL/Transformer/Condition/ValidValue/Validator.php b/src/core/etl/src/Flow/ETL/Transformer/Condition/ValidValue/Validator.php deleted file mode 100644 index 97c03ad03..000000000 --- a/src/core/etl/src/Flow/ETL/Transformer/Condition/ValidValue/Validator.php +++ /dev/null @@ -1,11 +0,0 @@ - - */ -final class ValidValue implements Filter -{ - public function __construct(private string $entryName, private Validator $validator) - { - } - - public function __serialize() : array - { - return [ - 'entry_name' => $this->entryName, - 'validator' => $this->validator, - ]; - } - - public function __unserialize(array $data) : void - { - $this->entryName = $data['entry_name']; - $this->validator = $data['validator']; - } - - public function keep(Row $row) : bool - { - return $this->validator->isValid($row->valueOf($this->entryName)); - } -} diff --git a/src/core/etl/src/Flow/ETL/Transformer/Filter/Filter/ValidValue/SymfonyValidator.php b/src/core/etl/src/Flow/ETL/Transformer/Filter/Filter/ValidValue/SymfonyValidator.php deleted file mode 100644 index 7fc95403f..000000000 --- a/src/core/etl/src/Flow/ETL/Transformer/Filter/Filter/ValidValue/SymfonyValidator.php +++ /dev/null @@ -1,50 +0,0 @@ -}> - */ -final class SymfonyValidator implements Validator -{ - private ValidatorInterface $validator; - - /** - * @param array $constraints - * @param null|ValidatorInterface $validator - */ - public function __construct(private array $constraints = [], ValidatorInterface $validator = null) - { - $this->validator = $validator ?: Validation::createValidator(); - } - - public function __serialize() : array - { - return [ - 'constraints' => $this->constraints, - 'validator' => $this->validator, - ]; - } - - public function __unserialize(array $data) : void - { - $this->validator = $data['validator']; - $this->constraints = $data['constraints']; - } - - public function isValid($value) : bool - { - return $this->validator->validate($value, $this->constraints)->count() === 0; - } -} diff --git a/src/core/etl/src/Flow/ETL/Transformer/Filter/Filter/ValidValue/Validator.php b/src/core/etl/src/Flow/ETL/Transformer/Filter/Filter/ValidValue/Validator.php deleted file mode 100644 index bffd21dd2..000000000 --- a/src/core/etl/src/Flow/ETL/Transformer/Filter/Filter/ValidValue/Validator.php +++ /dev/null @@ -1,18 +0,0 @@ - - */ -interface Validator extends Serializable -{ - /** - * @param mixed $value - */ - public function isValid($value) : bool; -} diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/Transformer/FilterRowsTransformerTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/Transformer/FilterRowsTransformerTest.php deleted file mode 100644 index 1b5de5072..000000000 --- a/src/core/etl/tests/Flow/ETL/Tests/Integration/Transformer/FilterRowsTransformerTest.php +++ /dev/null @@ -1,46 +0,0 @@ -assertSame( - [ - [ - 'email' => 'email@email.com', - ], - ], - $transformer->transform($rows, new FlowContext(Config::default()))->toArray() - ); - } -}