diff --git a/.docker/compose.yaml b/.docker/compose.yaml
new file mode 100644
index 00000000..bc72ae34
--- /dev/null
+++ b/.docker/compose.yaml
@@ -0,0 +1,14 @@
+x-build-args: &build-args
+ UID: "${UID:-1000}"
+ GID: "${GID:-1000}"
+
+name: cleverage-process-bundle
+
+services:
+ php:
+ build:
+ context: php
+ args:
+ <<: *build-args
+ volumes:
+ - ../:/var/www
diff --git a/.docker/php/Dockerfile b/.docker/php/Dockerfile
new file mode 100644
index 00000000..82be215c
--- /dev/null
+++ b/.docker/php/Dockerfile
@@ -0,0 +1,28 @@
+FROM php:8.5-fpm-alpine
+
+ARG UID
+ARG GID
+
+RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
+COPY /conf.d/ "$PHP_INI_DIR/conf.d/"
+
+RUN apk update && apk add \
+ tzdata \
+ shadow \
+ nano \
+ bash \
+ icu-dev \
+ && docker-php-ext-configure intl \
+ && docker-php-ext-install intl
+
+RUN ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime \
+ && sed -i "s/^;date.timezone =.*/date.timezone = Europe\/Paris/" $PHP_INI_DIR/php.ini
+
+COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
+
+RUN usermod -u $UID www-data \
+ && groupmod -g $GID www-data
+
+USER www-data:www-data
+
+WORKDIR /var/www
diff --git a/.docker/php/conf.d/dev.ini b/.docker/php/conf.d/dev.ini
new file mode 100644
index 00000000..2a141bea
--- /dev/null
+++ b/.docker/php/conf.d/dev.ini
@@ -0,0 +1,5 @@
+display_errors = 1
+error_reporting = E_ALL
+
+opcache.validate_timestamps = 1
+opcache.revalidate_freq = 0
diff --git a/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
similarity index 100%
rename from ISSUE_TEMPLATE.md
rename to .github/ISSUE_TEMPLATE.md
diff --git a/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
similarity index 100%
rename from PULL_REQUEST_TEMPLATE.md
rename to .github/PULL_REQUEST_TEMPLATE.md
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..89c38bf5
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,8 @@
+# This keeps updated the GitHub actions used in .github/workflows/*.yaml
+# See https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
+version: 2
+updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
diff --git a/.github/workflows/notifications.yml b/.github/workflows/notifications.yml
index 00aa3926..dc3d0581 100644
--- a/.github/workflows/notifications.yml
+++ b/.github/workflows/notifications.yml
@@ -13,10 +13,10 @@ jobs:
steps:
- name: Get the tag short reference
id: get_tag
- run: echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}
+ run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: Rocket.Chat Notification
- uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@1.1.1
+ uses: madalozzo/Rocket.Chat.GitHub.Action.Notification@master
with:
type: success
job_name: "[cleverage/process-bundle](https://github.com/cleverage/process-bundle) : ${{ steps.get_tag.outputs.TAG }} has been released"
diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml
new file mode 100644
index 00000000..1521e2c9
--- /dev/null
+++ b/.github/workflows/quality.yml
@@ -0,0 +1,62 @@
+name: Quality
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+
+permissions:
+ contents: read
+
+jobs:
+ phpstan:
+ name: PHPStan
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v7
+ - name: Install PHP with extensions
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.5'
+ coverage: none
+ tools: composer:v2
+ - name: Install Composer dependencies (locked)
+ uses: ramsey/composer-install@v4
+ - name: PHPStan
+ run: vendor/bin/phpstan --no-progress --memory-limit=1G analyse --error-format=github
+
+ php-cs-fixer:
+ name: PHP-CS-Fixer
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v7
+ - name: Install PHP with extensions
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.5'
+ coverage: none
+ tools: composer:v2
+ - name: Install Composer dependencies (locked)
+ uses: ramsey/composer-install@v4
+ - name: PHP-CS-Fixer
+ run: vendor/bin/php-cs-fixer fix --diff --dry-run --show-progress=none
+
+ rector:
+ name: Rector
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v7
+ - name: Install PHP with extensions
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.5'
+ coverage: none
+ tools: composer:v2
+ - name: Install Composer dependencies (locked)
+ uses: ramsey/composer-install@v4
+ - name: Rector
+ run: vendor/bin/rector --no-progress-bar --dry-run
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 00000000..b49e0ce1
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,105 @@
+name: Test
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+
+permissions:
+ contents: read
+
+jobs:
+ test:
+ name: PHP ${{ matrix.php-version }} + ${{ matrix.dependencies }} + ${{ matrix.variant }}
+ runs-on: ubuntu-latest
+ continue-on-error: ${{ matrix.allowed-to-fail }}
+ env:
+ SYMFONY_REQUIRE: ${{matrix.symfony-require}}
+
+ strategy:
+ matrix:
+ php-version:
+ - '8.2'
+ - '8.3'
+ - '8.4'
+ - '8.5'
+ dependencies: [highest]
+ allowed-to-fail: [false]
+ symfony-require: ['']
+ variant: [normal]
+ include:
+ - php-version: '8.2'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 6.4.*
+ variant: symfony/symfony:"6.4.*"
+ - php-version: '8.2'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 7.4.*
+ variant: symfony/symfony:"7.4.*"
+ - php-version: '8.3'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 6.4.*
+ variant: symfony/symfony:"6.4.*"
+ - php-version: '8.3'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 7.4.*
+ variant: symfony/symfony:"7.4.*"
+ - php-version: '8.4'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 6.4.*
+ variant: symfony/symfony:"6.4.*"
+ - php-version: '8.4'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 7.4.*
+ variant: symfony/symfony:"7.4.*"
+ - php-version: '8.4'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 8.*
+ variant: symfony/symfony:"8.*"
+ - php-version: '8.5'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 6.4.*
+ variant: symfony/symfony:"6.4.*"
+ - php-version: '8.5'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 7.4.*
+ variant: symfony/symfony:"7.4.*"
+ - php-version: '8.5'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 8.*
+ variant: symfony/symfony:"8.*"
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v7
+ - name: Install PHP with extensions
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php-version }}
+ coverage: pcov
+ tools: composer:v2, flex
+ - name: Add PHPUnit matcher
+ run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
+ - name: Install variant
+ if: matrix.variant != 'normal' && !startsWith(matrix.variant, 'symfony/symfony')
+ run: composer require ${{ matrix.variant }} --no-update
+ - name: Install Composer dependencies (${{ matrix.dependencies }})
+ uses: ramsey/composer-install@v4
+ with:
+ dependency-versions: ${{ matrix.dependencies }}
+ - name: Run Tests with coverage
+ run: vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml
+ #- name: Send coverage to Codecov
+ # uses: codecov/codecov-action@v4
+ # with:
+ # files: build/logs/clover.xml
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 4f96866e..4c32dcd3 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -1,9 +1,11 @@
setRules([
- '@PHP71Migration' => true,
- '@PHPUnit75Migration:risky' => true,
+ '@PHP8x2Migration' => true,
+ '@PHPUnit7x5Migration:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'protected_to_private' => false,
@@ -33,11 +35,13 @@
'header_comment' => ['header' => $fileHeaderComment],
'modernize_strpos' => true,
'get_class_to_class_keyword' => true,
+ 'declare_strict_types' => true,
])
->setRiskyAllowed(true)
->setFinder(
(new PhpCsFixer\Finder())
->in(__DIR__.'/src')
+ ->in(__DIR__.'/tests')
->append([__FILE__])
)
->setCacheFile('.php-cs-fixer.cache')
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4129a633..286795e4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,126 @@
+v5.0
+-----
+
+## Changes
+* [#179](https://github.com/cleverage/process-bundle/issues/179) Add support for PHP 8.5 and Symfony 8.* Update phpunit/phpunit to version >10.0
+
+## BC breaks
+* [#179](https://github.com/cleverage/process-bundle/issues/179) Remove support for PHP 8.1 and Symfony 7.3
+
+v4.5
+-----
+
+## Changes
+* [#176](https://github.com/cleverage/process-bundle/issues/176) Upgrade to Symfony 7.3 & PHP 8.4
+
+v4.4
+-----
+
+### Add
+* [#168](https://github.com/cleverage/process-bundle/issues/168) Add JsonStreamWriterTask with related doc
+* [#172](https://github.com/cleverage/process-bundle/issues/172) Add spl_file_object_flags and json_flags options on JsonStream*Tasks. Update docs.
+* [#174](https://github.com/cleverage/process-bundle/issues/174) Add FileSplitterTask using Filesystem/SplFile. Add doc.
+
+### Fixes
+* [#169](https://github.com/cleverage/process-bundle/issues/169) Fix JsonStreamFile empty line at the end issue, even if SKIP_EMPTY is set. Add JsonStreamReaderTask doc.
+
+v4.3
+-----
+
+### Add
+* [#166](https://github.com/cleverage/process-bundle/issues/166) Add PregMatchTransformer
+
+v4.2
+-----
+
+### Add
+* [#cleverage/archive-process-bundle#1](https://github.com/cleverage/archive-process-bundle/issues/1) Add new bridge ArchiveProcessBundle
+* [#162](https://github.com/cleverage/process-bundle/issues/162) Add timestamp placeholder on file_path parameter of CsvWriterTask. Improve documentation.
+* [#164](https://github.com/cleverage/process-bundle/issues/164) Add cleverage/cache-process-bundle dependency
+
+v4.1.1
+-----
+
+### Fixes
+
+* [#158](https://github.com/cleverage/process-bundle/issues/158) Add dependency to symfony/service-contract
+
+v4.1
+-----
+
+### Add
+* [#155](https://github.com/cleverage/process-bundle/issues/155) Add InputFileReaderTask (Reads the whole input file and outputs its content), InputLineReaderTask (Reads an input file line by line and outputs each line.) and LineReaderTask (Reads a file line by line and outputs each line.)
+
+v4.0
+------
+
+## BC breaks
+
+* [#142](https://github.com/cleverage/process-bundle/issues/142) Remove FileFetchTask, use `cleverage/flysystem-process-bundle` instead.
+* [#142](https://github.com/cleverage/process-bundle/issues/142) YamlReaderTask & YamlWriterTask namespaces changed to `CleverAge\ProcessBundle\Task\File\Yaml`
+* [#142](https://github.com/cleverage/process-bundle/issues/142) Array***Transformers namespaces changed to `CleverAge\ProcessBundle\Transformer\Array`
+* [#142](https://github.com/cleverage/process-bundle/issues/142) NormalizeTransformer & DenormalizeTransformer namespaces changed to `CleverAge\ProcessBundle\Transformer\Serialization`
+* [#142](https://github.com/cleverage/process-bundle/issues/142) DateFormatTransformer & DateParserTransformer namespaces changed to `CleverAge\ProcessBundle\Transformer\Date`
+* [#142](https://github.com/cleverage/process-bundle/issues/142) ExplodeTransformer, HashTransformer, ImplodeTransformer, SlugifyTransformer, SprintfTransformer & TrimTransformer namespaces changed to `CleverAge\ProcessBundle\Transformer\String`
+* [#142](https://github.com/cleverage/process-bundle/issues/142) InstantiateTransformer, PropertyAccessorTransformer RecursivePropertySetterTransformer namespaces changed to `CleverAge\ProcessBundle\Transformer\Object`
+* [#147](https://github.com/cleverage/process-bundle/issues/147) Replace `Symfony\Component\Form\Exception\InvalidConfigurationException` by `Symfony\Component\Config\Definition\Exception\InvalidConfigurationException`
+* [#148](https://github.com/cleverage/process-bundle/issues/148) Update services (step 1) according to Symfony best practices. Services should not use autowiring or autoconfiguration. Instead, all services should be defined explicitly.
+Services must be prefixed with the bundle alias instead of using fully qualified class names => `cleverage_process`
+* [#150](https://github.com/cleverage/process-bundle/issues/150) The class `\CleverAge\ProcessBundle\Task\Debug\MemInfoDumpTask` has been deleted without suggested replacement
+* [#115](https://github.com/cleverage/process-bundle/issues/115) New mandatory configuration `default_error_strategy` on `clever_age_process` level. See [Quick Start/Global configuration](docs/01-quick_start.md#global-configuration)
+### Changes
+
+* [#139](https://github.com/cleverage/process-bundle/issues/139) Update Makefile & .docker for local standalone usage
+* [#139](https://github.com/cleverage/process-bundle/issues/139) Update rector, phpstan & php-cs-fixer configurations & apply it
+* [#141](https://github.com/cleverage/process-bundle/issues/141) `league/flysystem-bundle` is not required anymore
+* [#130](https://github.com/cleverage/process-bundle/issues/130) EventDispatcherInterface service declaration breaks dependency injection
+* [#147](https://github.com/cleverage/process-bundle/issues/147) Add missing dependencies on `symfony/dotenv` and `symfony/runtime`
+* [#147](https://github.com/cleverage/process-bundle/issues/147) Remove dependencies on `symfony/form`, `symfony/messenger` & `symfony/scheduler`
+* [#146](https://github.com/cleverage/process-bundle/issues/146) eav-process-bundle, enqueue-process-bundle, cache-process-bundle and process-soap-bundle were deprecated / archived.
+* [#141](https://github.com/cleverage/process-bundle/issues/141) Add a default value to the node "default_error_strategy"
+
+### Fixes
+
+* [#129](https://github.com/cleverage/process-bundle/issues/129) Remove wrong replace configuration on composer.json. Add missing suggest
+* Miscellaneous fixes, show full diff : https://github.com/cleverage/process-bundle/compare/v4.0.0-rc2...v4.0.0
+
+v4.0-RC2
+------
+
+## BC breaks
+
+* Bump php version to >=8.2
+* Bump symfony version to ^6.4|^7.1
+
+### Fixes
+
+* Miscellaneous fixes, show full diff : https://github.com/cleverage/process-bundle/compare/v4.0.0-rc1...v4.0.0-rc2
+
+v4.0-RC1
+------
+
+## BC breaks
+
+* Bump php version to >=8.1
+* Bump symfony version to ^6.3
+
+## Changes
+* Add some phpunit tests
+* Apply Rector & Phpstan
+* Add StopwatchTask
+* Change directory structure. Move Symfony code to /src, documentation to /doc, and tests to /tests
+
+### Fixes
+
+* Miscellaneous fixes, show full diff : https://github.com/cleverage/process-bundle/compare/v3.2.9...v4.0.0-rc1
+
+v3.2.9
+------
+
+### Fixes
+
+https://github.com/cleverage/process-bundle/compare/v3.2.8...v3.2.9
+
v3.2.8
------
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 06b24c8f..d5f790d9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,10 +1,44 @@
Contributing
============
-Every contributions are welcomed. This bundle aims to provide a standalone set of generic component.
-If a contribution is too specific or requires dependencies, it might be put in a separated sub-bundle.
+First of all, **thank you** for contributing, **you are awesome**!
-Ideally every PR should contain documentation and unit test updates.
+Here are a few rules to follow in order to ease code reviews, and discussions before
+maintainers accept and merge your work.
+
+You MUST run the quality & test suites.
+
+You SHOULD write (or update) unit tests.
+
+You SHOULD write documentation.
+
+Please, write [commit messages that make sense](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
+and [rebase your branch](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) before submitting your Pull Request.
+
+One may ask you to [squash your commits](https://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)
+too. This is used to "clean" your Pull Request before merging it (we don't want
+commits such as `fix tests`, `fix 2`, `fix 3`, etc.).
+
+Thank you!
+
+## Running the quality & test suites
+
+Tests suite uses Docker environments in order to be idempotent to OS's. More than this
+PHP version is written inside the Dockerfile; this assures to test the bundle with
+the same resources. No need to have PHP installed.
+
+You only need Docker set it up.
+
+To allow testing environments more smooth we implemented **Makefile**.
+You have two commands available:
+
+```bash
+make quality
+```
+
+```bash
+make tests
+```
## Deprecations notices
@@ -14,5 +48,5 @@ When a feature should be deprecated, or when you have a breaking change for a fu
* Trigger a deprecation error: `@trigger_error('This feature will be deprecated in v4.0', E_USER_DEPRECATED);`
You can check which deprecation notice is triggered in tests
-* `make shell`
+* `make bash`
* `SYMFONY_DEPRECATIONS_HELPER=0 ./vendor/bin/phpunit`
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 5ed590e7..00000000
--- a/Dockerfile
+++ /dev/null
@@ -1,29 +0,0 @@
-ARG PHP_VERSION=8.1
-FROM php:${PHP_VERSION}-cli
-
-# Basic tools
-RUN apt-get update
-RUN apt-get install -y wget git zip unzip
-
-# Composer install
-COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
-
-# PHP setup
-RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
-COPY Resources/tests/environment/php/conf.ini "$PHP_INI_DIR/conf.d/"
-
-# Basic sample symfony app install
-ARG SF_ENV=sf5
-ENV APP_ENV test
-RUN mkdir /app
-WORKDIR /app
-ENV HOME /app
-COPY Resources/tests/environment/${SF_ENV}/composer.json /app
-RUN composer install
-
-# Additionnal config files for a test env
-COPY phpstan.neon /app/
-COPY Resources/tests/environment/${SF_ENV} /app/
-
-# Drop the process-bundle sources into this folder
-RUN mkdir /src-cleverage_process
diff --git a/Makefile b/Makefile
index e9e753c2..0a58e32f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,54 @@
.ONESHELL:
SHELL := /bin/bash
-test:
- php -dxdebug.mode=coverage vendor/bin/phpunit --coverage-html coverage-report
+DOCKER_RUN_PHP = docker compose -f .docker/compose.yaml run --rm php "bash" "-c"
+DOCKER_COMPOSE = docker compose -f .docker/compose.yaml
-linter: #[Linter]
- vendor/bin/php-cs-fixer fix
+start: upd #[Global] Start application
-phpstan: #[Phpstan]
- vendor/bin/phpstan
+src/vendor: #[Composer] install dependencies
+ $(DOCKER_RUN_PHP) "composer install --no-interaction"
+
+upd: #[Docker] Start containers detached
+ touch .docker/.env
+ make src/vendor
+ $(DOCKER_COMPOSE) up --remove-orphans --detach
+
+up: #[Docker] Start containers
+ touch .docker/.env
+ make src/vendor
+ $(DOCKER_COMPOSE) up --remove-orphans
+
+stop: #[Docker] Down containers
+ $(DOCKER_COMPOSE) stop
+
+down: #[Docker] Down containers
+ $(DOCKER_COMPOSE) down
+
+build: #[Docker] Build containers
+ $(DOCKER_COMPOSE) build
+
+ps: # [Docker] Show running containers
+ $(DOCKER_COMPOSE) ps
+
+bash: #[Docker] Connect to php container with current host user
+ $(DOCKER_COMPOSE) exec php bash
+
+logs: #[Docker] Show logs
+ $(DOCKER_COMPOSE) logs -f
+
+quality: phpstan php-cs-fixer rector #[Quality] Run all quality checks
+
+phpstan: #[Quality] Run PHPStan
+ $(DOCKER_RUN_PHP) "vendor/bin/phpstan --no-progress --memory-limit=1G analyse"
+
+php-cs-fixer: #[Quality] Run PHP-CS-Fixer
+ $(DOCKER_RUN_PHP) "vendor/bin/php-cs-fixer fix --diff --verbose"
+
+rector: #[Quality] Run Rector
+ $(DOCKER_RUN_PHP) "vendor/bin/rector"
+
+tests: phpunit #[Tests] Run all tests
+
+phpunit: #[Tests] Run PHPUnit
+ $(DOCKER_RUN_PHP) "vendor/bin/phpunit"
diff --git a/README.md b/README.md
index da35666a..8c2b601b 100644
--- a/README.md
+++ b/README.md
@@ -1,63 +1,24 @@
CleverAge/ProcessBundle
=======================
-## Introduction
-
This bundle allows to configure series of tasks to be performed on a certain order.
Basically, it will greatly ease the configuration of import and exports but can do much more.
-Compatible with every [currently supported Symfony versions](https://symfony.com/releases).
-
-## Index
-
-- [Quick start](doc/01-quick_start.md)
-- [Task types](doc/02-task_types.md)
-- [Custom tasks and development](doc/03-custom_tasks.md)
-- [Advanced workflow](doc/04-advanced_workflow.md)
-- [Contribute](CONTRIBUTING.md)
-- Cookbooks
- - [Common Setup](doc/cookbooks/01-common_setup.md)
- - [Transformations]
- - [Flow manipulation]
- - [Dummy tasks]
- - [Debugging]
- - [Logging]
- - [Subprocess]
- - [File manipulation]
- - [Direct call (in controller)]
- - [Performances monitoring](doc/cookbooks/performances_monitoring.md)
- - [Memory usage analysis](doc/cookbooks/memory_usage_graph.md)
-- Reference
- - [Process definition](doc/reference/01-process_definition.md)
- - [Task definition](doc/reference/02-task_definition.md)
- - Basic and debug
- - [ConstantOutputTask](doc/reference/tasks/constant_output_task.md)
- - [ConstantIterableOutputTask](doc/reference/tasks/constant_iterable_output_task.md)
- - [DebugTask](doc/reference/tasks/debug_task.md)
- - [DieTask](doc/reference/tasks/die_task.md)
- - [DummyTask](doc/reference/tasks/dummy_task.md)
- - [EventDispatcherTask](doc/reference/tasks/event_dispatcher_task.md)
- - Data manipulation and transformations
- - [DenormalizerTask](doc/reference/tasks/denormalizer_task.md)
- - [NormalizerTask](doc/reference/tasks/normalizer_task.md)
- - [PropertyGetterTask](doc/reference/tasks/property_getter_task.md)
- - [PropertySetterTask](doc/reference/tasks/property_setter_task.md)
- - [TransformerTask](doc/reference/tasks/transformer_task.md)
- - File/CSV
- - [CsvReaderTask](doc/reference/tasks/csv_reader_task.md)
- - [CsvWriterTask](doc/reference/tasks/csv_writer_task.md)
- - File/XML
- - [XmlReaderTask](doc/reference/tasks/xml_reader_task.md)
- - [XmlWriterTask](doc/reference/tasks/xml_writer_task.md)
- - Flow manipulation
- - [AggregateIterableTask](doc/reference/tasks/aggregate_iterable_task.md)
- - [InputAggregatorTask](doc/reference/tasks/input_aggregator_task.md)
- - [InputIteratorTask](doc/reference/tasks/input_iterator_task.md)
- - Transformers
- - [ArrayFilterTransformer](doc/reference/transformers/array_filter_transformer.md)
- - [MappingTransformer](doc/reference/transformers/mapping_transformer.md)
- - [RulesTransformer](doc/reference/transformers/rules_transformer.md)
- - [DateFormatTransformer](doc/reference/transformers/date_format.md)
- - [DateParserTransformer](doc/reference/transformers/date_parser.md)
- - [XpathEvaluatorTransformer](doc/reference/transformers/xpath_evaluator.md)
- - [Generic transformers definition](doc/reference/03-generic_transformers_definition.md)
+Compatible with [Symfony stable version and latest Long-Term Support (LTS) release](https://symfony.com/releases).
+
+Demo project can be found on [there](https://github.com/cleverage/process-bundle-demo).
+
+## Documentation
+
+For usage documentation, see:
+[docs/index.md](docs/index.md)
+
+## Support & Contribution
+
+For general support and questions, please use [Github](https://github.com/cleverage/process-bundle/issues).
+If you think you found a bug or you have a feature idea to propose, feel free to open an issue after looking at the [contributing](CONTRIBUTING.md) guide.
+
+## License
+
+This bundle is under the MIT license.
+For the whole copyright, see the [LICENSE](LICENSE) file distributed with this source code.
diff --git a/composer.json b/composer.json
index a1d4119c..2609a9c4 100644
--- a/composer.json
+++ b/composer.json
@@ -35,6 +35,11 @@
"email": "xmarchegay@clever-age.com",
"homepage": "https://github.com/xaviermarchegay",
"role": "Lead Developer"
+ },
+ {
+ "name": "Nicolas Joubert",
+ "email": "njoubert@clever-age.com",
+ "role": "Lead Developer"
}
],
"autoload": {
@@ -47,40 +52,31 @@
"CleverAge\\ProcessBundle\\Tests\\": "tests/"
}
},
- "replace": {
- "symfony/polyfill-ctype": "*",
- "symfony/polyfill-iconv": "*",
- "symfony/polyfill-php72": "*",
- "symfony/polyfill-php73": "*",
- "symfony/polyfill-php74": "*",
- "symfony/polyfill-php80": "*",
- "symfony/polyfill-php81": "*"
- },
"require": {
- "php": ">=8.1",
- "ext-json": "*",
+ "php": ">=8.2",
"ext-dom": "*",
"ext-intl": "*",
+ "ext-json": "*",
"ext-mbstring": "*",
"psr/cache": "^1|^2|^3",
- "league/flysystem-bundle": "^3.1",
- "symfony/config": "^6.4|^7.1",
- "symfony/console": "^6.4|^7.1",
- "symfony/dependency-injection": "^6.4|^7.1",
+ "symfony/config": "^6.4|^7.4|^8",
+ "symfony/console": "^6.4|^7.4|^8",
+ "symfony/dependency-injection": "^6.4|^7.4|^8",
+ "symfony/dotenv": "^6.4|^7.4|^8",
"symfony/event-dispatcher-contracts": "^3",
- "symfony/expression-language": "^6.4|^7.1",
- "symfony/form": "^6.4|^7.1",
- "symfony/framework-bundle": "^6.4|^7.1",
- "symfony/messenger": "^6.4|^7.1",
- "symfony/monolog-bundle": "~3.3",
- "symfony/options-resolver": "^6.4|^7.1",
- "symfony/process": "^6.4|^7.1",
- "symfony/property-access": "^6.4|^7.1",
- "symfony/scheduler": "^6.4|^7.1",
- "symfony/serializer": "^6.4|^7.1",
- "symfony/stopwatch": "^6.4|^7.1",
- "symfony/validator": "^6.4|^7.1",
- "symfony/yaml": "^6.4|^7.1"
+ "symfony/expression-language": "^6.4|^7.4|^8",
+ "symfony/framework-bundle": "^6.4|^7.4|^8",
+ "symfony/monolog-bridge":"^6.4|^7.4|^8",
+ "symfony/monolog-bundle": "^3.11|^4",
+ "symfony/options-resolver": "^6.4|^7.4|^8",
+ "symfony/process": "^6.4|^7.4|^8",
+ "symfony/property-access": "^6.4|^7.4|^8",
+ "symfony/runtime": "^6.4|^7.4|^8",
+ "symfony/serializer": "^6.4|^7.4|^8",
+ "symfony/stopwatch": "^6.4|^7.4|^8",
+ "symfony/validator": "^6.4|^7.4|^8",
+ "symfony/yaml": "^6.4|^7.4|^8",
+ "symfony/service-contracts": ">=1.0.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
@@ -93,11 +89,13 @@
"symfony/test-pack": "^1.1"
},
"suggest": {
+ "cleverage/archive-process-bundle": "Dedicated bundle for Archive dependencies for the Process Bundle",
+ "cleverage/cache-process-bundle": "Dedicated bundle for Cache dependencies for the Process Bundle",
"cleverage/doctrine-process-bundle": "Dedicated bundle for Doctrine dependencies for the process bundle",
- "cleverage/flysystem-process-bundle": "Dedicated bundle for Flysystem dependencies for the process bundle",
- "cleverage/rest-process-bundle": "Dedicated bundle for Rest dependencies for the process bundle",
"cleverage/soap-process-bundle": "Dedicated bundle for Soap dependencies for the process bundle",
- "cleverage/enqueue-process-bundle": "Manage asynchronous events within the process bundle"
+ "cleverage/rest-process-bundle": "Dedicated bundle for Rest dependencies for the process bundle",
+ "cleverage/flysystem-process-bundle": "Dedicated bundle for Flysystem dependencies for the process bundle",
+ "cleverage/ui-process-bundle": "UI for the process bundle"
},
"config": {
"allow-plugins": {
diff --git a/config/services/command.yaml b/config/services/command.yaml
new file mode 100644
index 00000000..947bce64
--- /dev/null
+++ b/config/services/command.yaml
@@ -0,0 +1,27 @@
+services:
+ cleverage_process.command.execute_process:
+ class: CleverAge\ProcessBundle\Command\ExecuteProcessCommand
+ public: false
+ tags:
+ - { name: console.command }
+ arguments:
+ - '@cleverage_process.manager.process'
+ - '@event_dispatcher'
+ - '@cleverage_process.registry.process_configuration'
+
+ cleverage_process.command.list_process:
+ class: CleverAge\ProcessBundle\Command\ListProcessCommand
+ public: false
+ tags:
+ - { name: console.command }
+ arguments:
+ - '@cleverage_process.registry.process_configuration'
+
+ cleverage_process.command.process_help:
+ class: CleverAge\ProcessBundle\Command\ProcessHelpCommand
+ public: false
+ tags:
+ - { name: console.command }
+ arguments:
+ - '@cleverage_process.registry.process_configuration'
+ - '@service_container'
diff --git a/config/services/event.yaml b/config/services/event.yaml
new file mode 100644
index 00000000..8bb1ae18
--- /dev/null
+++ b/config/services/event.yaml
@@ -0,0 +1,6 @@
+services:
+ cleverage_process.event_listener.data_queue:
+ class: CleverAge\ProcessBundle\EventListener\DataQueueEventListener
+ public: false
+ tags:
+ - { name: kernel.event_listener, event: cleverage_process.data_queue, method: pushData }
diff --git a/config/services/expression_language.yaml b/config/services/expression_language.yaml
new file mode 100644
index 00000000..125d3312
--- /dev/null
+++ b/config/services/expression_language.yaml
@@ -0,0 +1,12 @@
+services:
+ cleverage_process.expression_language.php_function_provider:
+ class: CleverAge\ProcessBundle\ExpressionLanguage\PhpFunctionProvider
+ public: false
+ arguments:
+ - [ 'preg_match' ]
+
+ cleverage_process.expression_language:
+ class: Symfony\Component\ExpressionLanguage\ExpressionLanguage
+ public: false
+ calls:
+ - ['registerProvider', ['@cleverage_process.expression_language.php_function_provider']]
diff --git a/config/services/logger.yaml b/config/services/logger.yaml
new file mode 100644
index 00000000..96401ec9
--- /dev/null
+++ b/config/services/logger.yaml
@@ -0,0 +1,40 @@
+services:
+ cleverage_process.logger.process_processor:
+ class: CleverAge\ProcessBundle\Logger\ProcessProcessor
+ public: false
+ tags:
+ - { name: monolog.processor, channel: cleverage_process }
+ arguments:
+ - '@cleverage_process.manager.process'
+
+ cleverage_process.logger.task_processor:
+ class: CleverAge\ProcessBundle\Logger\TaskProcessor
+ public: false
+ tags:
+ - { name: monolog.processor, channel: cleverage_process_task }
+ arguments:
+ - '@cleverage_process.manager.process'
+
+ cleverage_process.logger.transformer_processor:
+ class: CleverAge\ProcessBundle\Logger\TransformerProcessor
+ public: false
+ tags:
+ - { name: monolog.processor, channel: cleverage_process_transformer }
+ arguments:
+ - '@cleverage_process.manager.process'
+
+ cleverage_process.logger.process_logger:
+ class: CleverAge\ProcessBundle\Logger\ProcessLogger
+ public: false
+ tags:
+ - { name: monolog.logger, channel: cleverage_process }
+ arguments:
+ - '@logger'
+
+ cleverage_process.logger.task_logger:
+ class: CleverAge\ProcessBundle\Logger\TaskLogger
+ public: false
+ tags:
+ - { name: monolog.logger, channel: cleverage_process_task }
+ arguments:
+ - '@logger'
diff --git a/config/services/manager.yaml b/config/services/manager.yaml
new file mode 100644
index 00000000..396d7d9f
--- /dev/null
+++ b/config/services/manager.yaml
@@ -0,0 +1,15 @@
+services:
+ cleverage_process.manager.process:
+ class: CleverAge\ProcessBundle\Manager\ProcessManager
+ public: false
+ arguments:
+ - '@service_container'
+ - '@cleverage_process.logger.process_logger'
+ - '@cleverage_process.logger.task_logger'
+ - '@cleverage_process.registry.process_configuration'
+ - '@cleverage_process.context.contextual_option_resolver'
+ - '@event_dispatcher'
+
+ cleverage_process.context.contextual_option_resolver:
+ class: CleverAge\ProcessBundle\Context\ContextualOptionResolver
+ public: false
diff --git a/config/services/registry.yaml b/config/services/registry.yaml
new file mode 100644
index 00000000..48d5e469
--- /dev/null
+++ b/config/services/registry.yaml
@@ -0,0 +1,11 @@
+services:
+ cleverage_process.registry.process_configuration:
+ class: CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry
+ public: false
+ arguments:
+ - ~
+ - ~
+
+ cleverage_process.registry.transformer:
+ class: CleverAge\ProcessBundle\Registry\TransformerRegistry
+ public: false
diff --git a/config/services/task.yaml b/config/services/task.yaml
new file mode 100644
index 00000000..9fb96b4e
--- /dev/null
+++ b/config/services/task.yaml
@@ -0,0 +1,14 @@
+services:
+ _defaults:
+ bind:
+ $processManager: '@cleverage_process.manager.process'
+ $processRegistry: '@cleverage_process.registry.process_configuration'
+ $transformerRegistry: '@cleverage_process.registry.transformer'
+
+ CleverAge\ProcessBundle\Task\:
+ resource: '../../src/Task/*'
+ autowire: true
+ public: true
+ shared: false
+ tags:
+ - { name: monolog.logger, channel: cleverage_process_task }
diff --git a/src/Resources/config/services/transformer.yaml b/config/services/transformer.yaml
similarity index 65%
rename from src/Resources/config/services/transformer.yaml
rename to config/services/transformer.yaml
index 63741e56..6d2c40ee 100644
--- a/src/Resources/config/services/transformer.yaml
+++ b/config/services/transformer.yaml
@@ -1,14 +1,15 @@
services:
_defaults:
- autowire: true
- autoconfigure: true
- public: true
bind:
$language: '@cleverage_process.expression_language'
+ $transformerRegistry: '@cleverage_process.registry.transformer'
CleverAge\ProcessBundle\Transformer\:
- resource: '../../../Transformer/*'
- exclude: '../../../Transformer/GenericTransformer.php'
+ resource: '../../src/Transformer/*'
+ exclude: '../../src/Transformer/GenericTransformer.php'
+ autowire: true
+ autoconfigure: true
+ public: true
tags:
- { name: cleverage.transformer }
- { name: monolog.logger, channel: cleverage_process_transformer }
diff --git a/doc/reference/tasks/constant_iterable_output_task.md b/doc/reference/tasks/constant_iterable_output_task.md
deleted file mode 100644
index b5cbb2b1..00000000
--- a/doc/reference/tasks/constant_iterable_output_task.md
+++ /dev/null
@@ -1,27 +0,0 @@
-ConstantIterableOutputTask
-==========================
-
-Same as ConstantOutputTask but only accepts an array of values and iterates over each element.
-
-Task reference
---------------
-
-* **Service**: `CleverAge\ProcessBundle\Task\ConstantIterableOutputTask`
-
-Accepted inputs
----------------
-
-Input is ignored
-
-Possible outputs
-----------------
-
-`any`: iterate on the `output` option
-
-Options
--------
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
-| `output` | `array` | **X** | | Array of values to iterate onto |
-
diff --git a/doc/reference/tasks/constant_output_task.md b/doc/reference/tasks/constant_output_task.md
deleted file mode 100644
index 3fbff205..00000000
--- a/doc/reference/tasks/constant_output_task.md
+++ /dev/null
@@ -1,44 +0,0 @@
-ConstantOutputTask
-==================
-
-Simply outputs the same configured value all the time, ignores any input
-
-Task reference
---------------
-
-* **Service**: `CleverAge\ProcessBundle\Task\ConstantOutputTask`
-
-Accepted inputs
----------------
-
-Input is ignored
-
-Possible outputs
-----------------
-
-`any`: directly output given `output` option
-
-Options
--------
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
-| `output` | `any` | **X** | | Value to output |
-
-Example
--------
-
-```yaml
-clever_age_process:
- configurations:
- project_prefix.process_name:
- tasks:
- constant_output_example:
- service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
- options:
- output:
- id: 123
- firstname: Test1
- lastname: Test2
- outputs: [XXXX]
-```
diff --git a/doc/reference/tasks/csv_reader_task.md b/doc/reference/tasks/csv_reader_task.md
deleted file mode 100644
index b5df5a40..00000000
--- a/doc/reference/tasks/csv_reader_task.md
+++ /dev/null
@@ -1,34 +0,0 @@
-CsvReaderTask
-=============
-
-Reads a CSV file and iterate on each line, returning an array of key -> values. Skips empty lines.
-
-Task reference
---------------
-
-* **Service**: `CleverAge\ProcessBundle\Task\File\Csv\CsvReaderTask`
-* **Iterable task**
-
-Accepted inputs
----------------
-
-Input is ignored
-
-Possible outputs
-----------------
-
-`array`: foreach line, it will return a php array where key comes from headers and values are strings.
-Underlying method is [fgetcsv](https://secure.php.net/manual/en/function.fgetcsv.php).
-
-Options
--------
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
-| `file_path` | `string` | **X** | | Path of the file to read from (relative to symfony root or absolute) |
-| `delimiter` | `string` | | `;` | CSV delimiter |
-| `enclosure` | `string` | | `"` | CSV enclosure character |
-| `escape` | `string` | | `\\` | CSV escape character |
-| `headers` | `array` or `null` | | `null` | Static list of CSV headers, without the option, it will be dynamically read from first input |
-| `mode` | `string` | | `rb` | File open mode (see [fopen mode parameter](https://secure.php.net/manual/en/function.fopen.php)) |
-| `log_empty_lines` | `bool` | | `false` | Log when the output is empty |
diff --git a/doc/reference/tasks/csv_writer_task.md b/doc/reference/tasks/csv_writer_task.md
deleted file mode 100644
index 96ac0f2b..00000000
--- a/doc/reference/tasks/csv_writer_task.md
+++ /dev/null
@@ -1,36 +0,0 @@
-CsvWriterTask
-=============
-
-Write given array to a CSV file, will wait until the end of the previous iteration (this is a blocking task) and outputs
-the file path.
-
-Task reference
---------------
-
-* **Service**: `CleverAge\ProcessBundle\Task\File\Csv\CsvWriterTask`
-* **Blocking task**
-
-Accepted inputs
----------------
-
-`array`: foreach line, it will need a php array where key match the headers and values are convertible to string.
-Underlying method is [fputcsv](https://secure.php.net/manual/en/function.fputcsv.php).
-
-Possible outputs
-----------------
-
-`string`: absolute path of the produced file
-
-Options
--------
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
-| `file_path` | `string` | **X** | | Path of the file to write to (relative to symfony root or absolute). It can also take two placeholders (`{date}` and `{date_time}`) to insert timestamps into the filename |
-| `delimiter` | `string` | | `;` | CSV delimiter |
-| `enclosure` | `string` | | `"` | CSV enclosure character |
-| `escape` | `string` | | `\\` | CSV escape character |
-| `headers` | `array` or `null` | | `null` | Static list of CSV headers, without the option, it will be dynamically read from first line |
-| `mode` | `string` | | `wb` | File open mode (see [fopen mode parameter](https://secure.php.net/manual/en/function.fopen.php)) |
-| `split_character` | `string` | | `\|` | Used to implode array values |
-| `write_headers` | `bool` | | `true` | Write the headers as a first line |
diff --git a/doc/reference/tasks/dummy_task.md b/doc/reference/tasks/dummy_task.md
deleted file mode 100644
index fe8a5321..00000000
--- a/doc/reference/tasks/dummy_task.md
+++ /dev/null
@@ -1,19 +0,0 @@
-DummyTask
-=========
-
-Passes the input to the output, can be used as an entry point allow multiple tasks to be run at the entry point
-
-Task reference
---------------
-
-* **Service**: `CleverAge\ProcessBundle\Task\DummyTask`
-
-Accepted inputs
----------------
-
-`any`
-
-Possible outputs
-----------------
-
-`any`: re-output given input
diff --git a/doc/reference/tasks/event_dispatcher_task.md b/doc/reference/tasks/event_dispatcher_task.md
deleted file mode 100644
index 9b6862e2..00000000
--- a/doc/reference/tasks/event_dispatcher_task.md
+++ /dev/null
@@ -1,29 +0,0 @@
-EventDispatcherTask
-===================
-
-Call the Symfony event dispatcher
-
-Task reference
---------------
-
-* **Service**: `CleverAge\ProcessBundle\Task\Event\EventDispatcherTask`
-
-Accepted inputs
----------------
-
-`any`
-
-Possible outputs
-----------------
-
-* `any` when `passive` option is set to true
-* `null` in other cases
-
-Options
--------
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
-| `event_name` | `string` | **X** | | Format for normalization ("json", "xml", ... an empty string should also work) |
-| `passive` | `bool` | | `true` | Pass input to output |
-
diff --git a/doc/reference/tasks/transformer_task.md b/doc/reference/tasks/transformer_task.md
deleted file mode 100644
index 4a8b5b21..00000000
--- a/doc/reference/tasks/transformer_task.md
+++ /dev/null
@@ -1,29 +0,0 @@
-TransformerTask
-===============
-
-Pass an input into a chain of transformers.
-
-See transformers references.
-
-Task reference
---------------
-
-* **Service**: `CleverAge\ProcessBundle\Task\TransformerTask`
-
-Accepted inputs
----------------
-
-`any`: it should match the 1st expected input of the transform chain
-
-Possible outputs
-----------------
-
-`any`: result of the transform chain
-
-Options
--------
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
-| `transformers` | `array` | **X** | | List of transformers, see [TransformerTrait](../traits/transformer_trait.md) |
-
diff --git a/doc/reference/transformers/mapping_transformer.md b/doc/reference/transformers/mapping_transformer.md
deleted file mode 100644
index 9830542d..00000000
--- a/doc/reference/transformers/mapping_transformer.md
+++ /dev/null
@@ -1,143 +0,0 @@
-MappingTransformer
-==================
-
-Transform a set of properties into a (possibly) new output.
-
-Basically, the algorithm is:
-* determine destination (from `initial_value` or `keep_input`)
-* foreach property
- - get value(s) from the source(s) (from `code`, `constant` or `set_null`)
- - use additional transformers on the value
- - merge the property and its value into the destination (with `merge_callback`, the property accessor, or as a simple array index)
-
-Task reference
---------------
-
-* **Service**: `CleverAge\ProcessBundle\Transformer\MappingTransformer`
-* **Transformer code**: `mapping`
-
-Accepted inputs
----------------
-
-`array` or `object` that can be accessed by the property accessor
-
-Possible outputs
-----------------
-
-`array` or `object` (the "destination") containing the property manipulated by the transformer
-
-Options
--------
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
-| `mapping` | `array` | **X** | | List of property => sub-mapping options. The property code can be a single string to be used as an array index, or a writable property path |
-| `ignore_missing` | `bool` | | `false` | Ignore property accessor errors for the whole mapping |
-| `keep_input` | `bool` | | `false` | Use input as the mapping destination (takes precedence on `initial_value`). Keep in mind that due to PHP behavior, arrays are cloned while objects are passed by reference |
-| `initial_value` | `any` | | `[]` | Set the mapping destination |
-| `merge_callback` | `callable` or `null` | | `null` | Allow to change how a property can be set in the destination |
-
-Foreach property there is the following options.
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
-| `code` | `string` or `array` or `null` | | `null` | A property path, or a list of property path. By default it would be the same as the destination property. Will be used as a source. The special value '.' access the whole object. |
-| `constant` | `any` | | `null` | If not `null`, will be directly used as a source (takes precedence on `code`) |
-| `set_null` | `bool` | | `false` | If `true`, `null` will be directly used as a source (takes precedence on `code`) |
-| `ignore_missing` | `bool` | | `false` | Ignore property accessor errors for this source |
-| `transformers` | `array` | | `[]` | List of sub-transformers, see [TransformerTrait](../traits/transformer_trait.md) |
-
-Examples
---------
-
-* Simple transformation, will output an array with keys "code", "label", "type", "reference", "required" and "slug"
- - required input: an array with keys "Code", "label", "Type", "Name" and "ID"
- - output: an array with keys "code", "label", "type", "reference", "required" and "slug"
-
-```yaml
-transform_data: # Task level
- service: '@CleverAge\ProcessBundle\Task\TransformerTask'
- options:
- transformers:
- mapping:
- mapping:
- code: # Simple mapping from "Code" to "code"
- code: '[Code]'
- "[label]": ~ # Value from "label" will be kept with the same name
- type: # Get value from "type" and map values (with a default)
- code: '[Type]'
- transformers:
- convert_value:
- ignore_missing: true
- map:
- TEXTE: text
- NUMERIQUE: number
- LISTE_DEROULANTE: simpleselect
- CHOIX_MULTIPLES: multiselect
- DATE: date
- default:
- value: unknown
- reference: # "null" column
- set_null: true
- required: # "true" column
- constant: true
- slug: # Get multiple sources, slugify them, and merge them
- code:
- name: '[Name]'
- id: '[ID]'
- transformers:
- array_map:
- transformers:
- slugify: ~
- implode:
- separator: '_'
- outputs: [next_task]
-```
-
-* Mapping in depth, using objects
- - required input: an object with an iterable property "productItems", containing objects with property "longName"
- - output: an array with key "items", containing a list of array with key "name"
-
-```yaml
-transform_data: # Task level
- service: '@CleverAge\ProcessBundle\Task\TransformerTask'
- options:
- transformers: # TransformerTask options
- mapping: # Transformer code
- mapping: # MappingTransformer options
- items: # property code
- code: 'productItems' # property options
- transformers: # property options
- array_map: # Transformer code
- transformers: # ArrayMapTransformer options
- mapping: # Transformer code
- mapping: # MappingTransformer options
- name: # property code
- code: 'longName' # property options
-
- outputs: [next_task]
-```
-
-* Advanced property setter
- - required input: an object with a property "address", containing an object with properties "postCode" and "customer", itself containing an object with property "hasFlag"
- - output: same object, with a modified "address.customer.hasFlag"
-
-```yaml
-transform_data: # Task level
- service: '@CleverAge\ProcessBundle\Task\TransformerTask'
- options:
- transformers:
- mapping:
- keep_input: true
- mapping:
- address.customer.hasFlag:
- code: address.postCode
- transformers:
- convert_value:
- ignore_missing: true
- map:
- 69005: true
- default:
- value: false
- outputs: [next_task]
-```
diff --git a/doc/reference/transformers/rules_transformer.md b/doc/reference/transformers/rules_transformer.md
deleted file mode 100644
index fd65827a..00000000
--- a/doc/reference/transformers/rules_transformer.md
+++ /dev/null
@@ -1,93 +0,0 @@
-RulesTransformer
-================
-
-Uses a set of rules to apply some set of transformers on a value. Basically behaves like a `if/elseif/else` block.
-
-By default a rule uses a variable named `value` containing anything you passed in input (`array`, `string`, ...). But this
-can be overridden using options `use_value_as_variables` as `true` and setting `expression_variables` to a static list of
-input variables.
-
-Note that `expression_variables` can also be set to `null` for more flexibility, but this disable initial parsing and decrease
-performances.
-
-See [The ExpressionLanguage Component Reference](https://symfony.com/doc/current/components/expression_language.html) for
-more information.
-
-Task reference
---------------
-
-* **Service**: `CleverAge\ProcessBundle\Transformer\RulesTransformer`
-* **Transformer code**: `rules`
-
-Accepted inputs
----------------
-
-`any` or an `array` of `variable code => value` injectable into an expression
-
-Possible outputs
-----------------
-
-`any` resulting from a transformation set.
-
-Without any matching rules, the value itself is returned.
-
-Options
--------
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
-| `rules_set` | `array` | **X** | | Ordered list of rules, see bellow for details |
-| `use_value_as_variables` | `bool` | | `false` | Use given value as an array of variable to inject in expression |
-| `expression_variables` | `array` or `null` | | `[value]` | Name of variables injected in the expression at initialization time |
-
-Foreach rule there is the following options.
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
-| `condition` | `string` or `null` | | `null` | An expression used to match a value |
-| `default` | `bool` | | `false` | Mark this rule as a default rule. The given rule must be the last, cannot have a condition, and there cannot have 2 default in the same time |
-| `transformers` | `array` | | `[]` | List of sub-transformers, see [TransformerTrait](../traits/transformer_trait.md) |
-| `constant` | `any` | | `null` | If not `null`, given value will be directly output (takes precedence on `transformers`) |
-| `set_null` | `bool` | | `false` | If `true`, `null` will be directly output (takes precedence on `constant`) |
-
-Examples
---------
-
-* Simple rules with default value
- - input value is an array containing an `order` object and a `customer` object
- - output will be either a value from customer, or a numeric constant, or null
-
-```yaml
-# Transformer options level
-rules:
- rules_set:
- - condition: 'value["order"].origin === "marketplace"'
- transformers:
- property_accessor:
- property_path: '[customer].id'
- - condition: 'value["order"].origin === "e-commerce"'
- constant: 1234
- - default: true
- set_null: true
-```
-
-* Use value as variables
- - same example as above
- - can be useful for more verbose expression
- - transformers still get the input as the initial array
-
-```yaml
-# Transformer options level
-rules:
- use_value_as_variables: true
- expression_variables: [order, customer]
- rules_set:
- - condition: 'order.origin === "marketplace"'
- transformers:
- property_accessor:
- property_path: '[customer].id'
- - condition: 'order.origin === "e-commerce"'
- constant: 1234
- - default: true
- set_null: true
-```
diff --git a/doc/01-quick_start.md b/docs/01-quick_start.md
similarity index 89%
rename from doc/01-quick_start.md
rename to docs/01-quick_start.md
index 0bab2f4f..efcc83c7 100644
--- a/doc/01-quick_start.md
+++ b/docs/01-quick_start.md
@@ -20,13 +20,16 @@ The most common example is the ETL. It's a kind of application whose main purpos
## Installation
-This bundle requires Symfony 6.3 minimum. You can install it using composer:
+Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
+of the Composer documentation.
+
+Open a command console, enter your project directory and install it using composer:
```bash
composer require cleverage/process-bundle
```
-Remember to add the following line to bundles.php (not required if Symfony Flex is used)
+Remember to add the following line to config/bundles.php (not required if Symfony Flex is used)
```php
CleverAge\ProcessBundle\CleverAgeProcessBundle::class => ['all' => true],
@@ -97,11 +100,11 @@ Then you can add tasks in this array. They consist of a `service`, optionally co
```
Below you can see a minimal working ETL example. It consist of 3 tasks:
-- the first *extract* some data (the [constant output task](./reference/tasks/constant_output_task.md) outputs... a constant value): it's an array with 3
+- the first *extract* some data (the [constant output task](reference/tasks/constant_output_task.md) outputs... a constant value): it's an array with 3
keys/values
-- the second *transform* the given value (the [transformer task](./reference/tasks/transformer_task.md) is one of the most important!): the output is then an
+- the second *transform* the given value (the [transformer task](reference/tasks/transformer_task.md) is one of the most important!): the output is then an
array with 2 keys/values, created using the value from previous task
-- finally, the last will just display the result (it's a cheap *load*, using the [debug task](./reference/tasks/debug_task.md), only for development
+- finally, the last will just display the result (it's a cheap *load*, using the [debug task](reference/tasks/debug_task.md), only for development
purpose!)
```yaml
@@ -193,4 +196,4 @@ Once everything is working fine, you may want to automate your processes. The st
To check if everything went fine, logs are stored in database:
- `clever_process_history`: logs process started, with `process_code`, `start_date`, `end_date` and `statut`
-- `clever_task_history`: logs custom tasks logs (see [logging]()), with `task_code`, `message`, `logged_at` date, `level`, a `reference` and `context`
+- `clever_task_history`: logs custom tasks logs (see [logging]), with `task_code`, `message`, `logged_at` date, `level`, a `reference` and `context`
diff --git a/doc/02-task_types.md b/docs/02-task_types.md
similarity index 98%
rename from doc/02-task_types.md
rename to docs/02-task_types.md
index 9ebfd21e..6639f027 100644
--- a/doc/02-task_types.md
+++ b/docs/02-task_types.md
@@ -81,7 +81,7 @@ Transformers are a special subset of this bundle. They're not tasks strictly spe
point for Transformers is the `CleverAge\ProcessBundle\Task\TransformerTask`, whose only purpose is to take some input,
pass it to a transformer and transfer the output to next task.
-The idea is to allow a great flexibility (especially using the [MappingTransformer]()), without using too much code.
+The idea is to allow a great flexibility (especially using the [MappingTransformer]), without using too much code.
They implement `CleverAge\ProcessBundle\Transformer\TransformerInterface` or
`CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface`.
diff --git a/doc/03-custom_tasks.md b/docs/03-custom_tasks.md
similarity index 95%
rename from doc/03-custom_tasks.md
rename to docs/03-custom_tasks.md
index b6bc6372..607ac3b0 100644
--- a/doc/03-custom_tasks.md
+++ b/docs/03-custom_tasks.md
@@ -25,11 +25,11 @@ method will be called and the `$state` will contain a new input (`ProcessState::
may pass a new output to the next task (`ProcessState::setOutput`).
The State also provide reporting tools:
-* `ProcessState::log`: register a new log message (see[logging]())
+* `ProcessState::log`: register a new log message (see[logging])
* `ProcessState::getConsoleOutput`: direct link to Symfony's Console Output (deprecated, prefer log)
Sometimes, when you execute a task, you need to change how the process may continue. It will be detailed in depth in
-the [next chapter about error management]() but here are the main methods
+the [next chapter about error management] but here are the main methods
* `ProcessState::setSkipped`: process won't continue to next step
* `ProcessState::setStopped`: process will fully stop
* `ProcessState::setErrorOutput`: allow to direct an output to an error branch from your workflow
@@ -50,14 +50,14 @@ Defining your tasks as Iterable or Blocking is as simple as implementing one of
* `CleverAge\ProcessBundle\Model\IterableTaskInterface`: the `next` method should behave almost the same as PHP's native
[next](https://secure.php.net/manual/en/function.next.php) function for arrays (except it only returns a boolean)
* `CleverAge\ProcessBundle\Model\BlockingTaskInterface`: every `execute` method call should only accumulate data from
-the input and once every previous task is _resolved_, the `proceed` method should provide an output (see [TODO]() for
+the input and once every previous task is _resolved_, the `proceed` method should provide an output (see [TODO] for
the exact definition of a resolved method)
It's up to you to know when you should be using one of those, but basically:
* When you loop over a collection of independent elements, you should use an Iterable task. It may help you reduce the
memory footprint.
* When you need to collect, upload, ... data as a whole, then you might need a Blocking task. Be sure to read [previous
-chapter's notice]() about performance.
+chapter's notice] about performance.
Tasks cannot be both Iterable and Blocking.
diff --git a/doc/04-advanced_workflow.md b/docs/04-advanced_workflow.md
similarity index 98%
rename from doc/04-advanced_workflow.md
rename to docs/04-advanced_workflow.md
index bef6e3f1..f31ce2a3 100644
--- a/doc/04-advanced_workflow.md
+++ b/docs/04-advanced_workflow.md
@@ -25,5 +25,4 @@ You can also use [EventDispatcherTask](reference/tasks/event_dispatcher_task.md)
_TODO_
* ProcessLauncherTask
-* EnqueueBundle
* pthread
diff --git a/doc/05-good_practices.md b/docs/05-good_practices.md
similarity index 100%
rename from doc/05-good_practices.md
rename to docs/05-good_practices.md
diff --git a/doc/06-testing.md b/docs/06-testing.md
similarity index 100%
rename from doc/06-testing.md
rename to docs/06-testing.md
diff --git a/doc/basic-etl.png b/docs/basic-etl.png
similarity index 100%
rename from doc/basic-etl.png
rename to docs/basic-etl.png
diff --git a/doc/cookbooks/01-common_setup.md b/docs/cookbooks/01-common_setup.md
similarity index 100%
rename from doc/cookbooks/01-common_setup.md
rename to docs/cookbooks/01-common_setup.md
diff --git a/doc/cookbooks/memory_usage_graph.md b/docs/cookbooks/memory_usage_graph.md
similarity index 100%
rename from doc/cookbooks/memory_usage_graph.md
rename to docs/cookbooks/memory_usage_graph.md
diff --git a/doc/cookbooks/performances_monitoring.md b/docs/cookbooks/performances_monitoring.md
similarity index 100%
rename from doc/cookbooks/performances_monitoring.md
rename to docs/cookbooks/performances_monitoring.md
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 00000000..26d38e0b
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,143 @@
+## Documentation
+
+- [Quick start](01-quick_start.md)
+- [Task types](02-task_types.md)
+- [Custom tasks and development](03-custom_tasks.md)
+- [Advanced workflow](04-advanced_workflow.md)
+- Cookbooks
+ - [Common Setup](cookbooks/01-common_setup.md)
+ - [Transformations]
+ - [Flow manipulation]
+ - [Dummy tasks]
+ - [Debugging]
+ - [Logging]
+ - [Subprocess]
+ - [File manipulation]
+ - [Direct call (in controller)]
+ - [Performances monitoring](cookbooks/performances_monitoring.md)
+ - [Memory usage analysis](cookbooks/memory_usage_graph.md)
+- Reference
+ - [Process definition](reference/01-process_definition.md)
+ - [Task definition](reference/02-task_definition.md)
+ - Basic and debug
+ - [ConstantOutputTask](reference/tasks/constant_output_task.md)
+ - [ConstantIterableOutputTask](reference/tasks/constant_iterable_output_task.md)
+ - [CounterTask](reference/tasks/counter_task.md)
+ - [DebugTask](reference/tasks/debug_task.md)
+ - [DieTask](reference/tasks/die_task.md)
+ - [DummyTask](reference/tasks/dummy_task.md)
+ - [ErrorForwarderTask](reference/tasks/error_forwarder_task.md)
+ - [EventDispatcherTask](reference/tasks/event_dispatcher_task.md)
+ - [StopwatchTask](reference/tasks/stopwatch_task.md)
+ - Data manipulation and transformations
+ - [DenormalizerTask](reference/tasks/denormalizer_task.md)
+ - [NormalizerTask](reference/tasks/normalizer_task.md)
+ - [DeserializerTask]
+ - [SerializerTask]
+ - [PropertyGetterTask](reference/tasks/property_getter_task.md)
+ - [PropertySetterTask](reference/tasks/property_setter_task.md)
+ - [ObjectUpdaterTask]
+ - [SplitJoinLineTask]
+ - [TransformerTask](reference/tasks/transformer_task.md)
+ - [ValidatorTask]
+ - File/CSV
+ - [CsvReaderTask](reference/tasks/csv_reader_task.md)
+ - [CsvWriterTask](reference/tasks/csv_writer_task.md)
+ - [CSVSplitterTask]
+ - [InputCsvReaderTask](reference/tasks/input_csv_reader_task.md)
+ - File/JsonStream
+ - [JsonStreamReaderTask](reference/tasks/json_stream_reader_task.md)
+ - [JsonStreamWriterTask](reference/tasks/json_stream_writer_task.md)
+ - File/XML
+ - [XmlReaderTask](reference/tasks/xml_reader_task.md)
+ - [XmlWriterTask](reference/tasks/xml_writer_task.md)
+ - File/Yaml
+ - [YamlReaderTask]
+ - [YamlWriterTask]
+ - File
+ - [FileMoverTask]
+ - [FileReaderTask](reference/tasks/file_reader_task.md)
+ - [FileRemoverTask]
+ - [FileSplitterTask](reference/tasks/file_splitter_task.md)
+ - [FileWriterTask]
+ - [FolderBrowserTask](reference/tasks/folder_browser_task.md)
+ - [InputFileReaderTask](reference/tasks/input_file_reader_task.md)
+ - [InputFolderBrowserTask](reference/tasks/input_folder_browser_task.md)
+ - [InputLineReaderTask](reference/tasks/input_line_reader_task.md)
+ - [LineReaderTask](reference/tasks/line_reader_task.md)
+ - Flow manipulation
+ - [AggregateIterableTask](reference/tasks/aggregate_iterable_task.md)
+ - [InputAggregatorTask](reference/tasks/input_aggregator_task.md)
+ - [InputIteratorTask](reference/tasks/input_iterator_task.md)
+ - [ArrayMergeTask]
+ - [ColumnAggregatorTask]
+ - [RowAggregatorTask]
+ - [FilterTask]
+ - [GroupByAggregateIterableTask]
+ - [SimpleBatchTask]
+ - [IterableBatchTask]
+ - [SkipEmptyTask]
+ - [StopTask]
+ - Process
+ - [CommandRunnerTask]
+ - [ProcessExecutorTask]
+ - [ProcessLauncherTask]
+ - Reporting
+ - [AdvancedStatCounterTask]
+ - [LoggerTask](reference/tasks/logger_task.md)
+ - [StatCounterTask]
+ - Transformers
+ - Basic and debug
+ - [CachedTransformer]
+ - [CallbackTransformer]
+ - [CastTransformer]
+ - [ConstantTransformer]
+ - [ConvertValueTransformer]
+ - [DebugTransformer]
+ - [DefaultTransformer]
+ - [GenericTransformer]
+ - [EvaluatorTransformer]
+ - [ExpressionLanguageMapTransformer]
+ - [MappingTransformer](reference/transformers/mapping_transformer.md)
+ - [MultiReplaceTransformer](reference/transformers/multi_replace_transformer.md)
+ - [PregFilterTransformer]
+ - [RulesTransformer](reference/transformers/rules_transformer.md)
+ - [TypeSetterTransformer]
+ - [UnsetTransformer]
+ - [WrapperTransformer]
+ - Array
+ - [ArrayElementTransformer]
+ - [ArrayFilterTransformer](reference/transformers/array_filter_transformer.md)
+ - [ArrayFirstTransformer]
+ - [ArrayLastTransformer]
+ - [ArrayMapTransformer](reference/transformers/array_map_transformer.md)
+ - [ArrayUnsetTransformer]
+ - Date
+ - [DateFormatTransformer](reference/transformers/date_format.md)
+ - [DateParserTransformer](reference/transformers/date_parser.md)
+ - Object
+ - [InstantiateTransformer]
+ - [PropertyAccessorTransformer]
+ - [RecursivePropertySetterTransformer]
+ - Serialization
+ - [DenormalizeTransformer]
+ - [NormalizeTransformer]
+ - String
+ - [ExplodeTransformer]
+ - [HashTransformer]
+ - [ImplodeTransformer](reference/transformers/implode_transformer.md)
+ - [PregMatchTransformer](reference/transformers/preg_match_transformer.md)
+ - [SlugifyTransformer](reference/transformers/slugify_transformer.md)
+ - [SprintfTransformer](reference/transformers/sprintf_transformer.md)
+ - [TrimTransformer](reference/transformers/trim_transformer.md)
+ - XML
+ - [XpathEvaluatorTransformer](reference/transformers/xpath_evaluator.md)
+ - Other bridges
+ - [Archive](https://github.com/cleverage/archive-process-bundle)
+ - [Cache](https://github.com/cleverage/cache-process-bundle)
+ - [Doctrine](https://github.com/cleverage/doctrine-process-bundle)
+ - [Flysystem](https://github.com/cleverage/flysystem-process-bundle)
+ - [Rest](https://github.com/cleverage/rest-process-bundle)
+ - [Soap](https://github.com/cleverage/soap-process-bundle)
+ - [Generic transformers definition](reference/03-generic_transformers_definition.md)
+- [UI](https://github.com/cleverage/ui-process-bundle)
diff --git a/doc/reference/01-process_definition.md b/docs/reference/01-process_definition.md
similarity index 100%
rename from doc/reference/01-process_definition.md
rename to docs/reference/01-process_definition.md
diff --git a/doc/reference/02-task_definition.md b/docs/reference/02-task_definition.md
similarity index 100%
rename from doc/reference/02-task_definition.md
rename to docs/reference/02-task_definition.md
diff --git a/doc/reference/03-generic_transformers_definition.md b/docs/reference/03-generic_transformers_definition.md
similarity index 92%
rename from doc/reference/03-generic_transformers_definition.md
rename to docs/reference/03-generic_transformers_definition.md
index 68b40ca1..9615761c 100644
--- a/doc/reference/03-generic_transformers_definition.md
+++ b/docs/reference/03-generic_transformers_definition.md
@@ -27,6 +27,6 @@ For each contextual option, you can define
| `default` | `any` | | `null` | If not `null`, define the default value |
| `default_is_null` | `bool` | | `false` | If you need `null` to be the default value, use this option |
-The transformer options are the same than any other transformer using a sub-list of transformers (see [TransformerTrait](../traits/transformer_trait.md)).
+The transformer options are the same than any other transformer using a sub-list of transformers (see [TransformerTrait](traits/transformer_trait.md)).
You can use the syntax for contextual values (`{{ contextual_option_code }}`) to put placeholders that will be filled by
those contextual options.
diff --git a/doc/reference/tasks/_template.md b/docs/reference/tasks/_template.md
similarity index 76%
rename from doc/reference/tasks/_template.md
rename to docs/reference/tasks/_template.md
index ed1d4a57..842c5f37 100644
--- a/doc/reference/tasks/_template.md
+++ b/docs/reference/tasks/_template.md
@@ -20,9 +20,8 @@ _Description of possible types_
Options
-------
-
-| Code | Type | Required | Default | Description |
-| ---- | ---- | :------: | ------- | ----------- |
+| Code | Type | Required | Default | Description |
+|--------|--------|--------------------|--------------------------------|---------------|
| `code` | `type` | **X** _or nothing_ | `default value` _if available_ | _description_ |
Examples
diff --git a/doc/reference/tasks/aggregate_iterable_task.md b/docs/reference/tasks/aggregate_iterable_task.md
similarity index 100%
rename from doc/reference/tasks/aggregate_iterable_task.md
rename to docs/reference/tasks/aggregate_iterable_task.md
diff --git a/docs/reference/tasks/constant_iterable_output_task.md b/docs/reference/tasks/constant_iterable_output_task.md
new file mode 100644
index 00000000..30b04829
--- /dev/null
+++ b/docs/reference/tasks/constant_iterable_output_task.md
@@ -0,0 +1,40 @@
+ConstantIterableOutputTask
+==========================
+
+Same as ConstantOutputTask but only accepts an array of values and iterates over each element.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\ConstantIterableOutputTask`
+
+Accepted inputs
+---------------
+
+Input is ignored
+
+Possible outputs
+----------------
+
+`any`: iterate on the `output` option
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|----------|---------|:--------:|---------|---------------------------------|
+| `output` | `array` | **X** | | Array of values to iterate onto |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask'
+ options:
+ output:
+ id: 123
+ firstname: Test1
+ lastname: Test2
+```
diff --git a/docs/reference/tasks/constant_output_task.md b/docs/reference/tasks/constant_output_task.md
new file mode 100644
index 00000000..ed2f042f
--- /dev/null
+++ b/docs/reference/tasks/constant_output_task.md
@@ -0,0 +1,40 @@
+ConstantOutputTask
+==================
+
+Simply outputs the same configured value all the time, ignores any input
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\ConstantOutputTask`
+
+Accepted inputs
+---------------
+
+Input is ignored
+
+Possible outputs
+----------------
+
+`any`: directly output given `output` option
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|----------|-------|:---------|---------|-----------------|
+| `output` | `any` | **X** | | Value to output |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
+ options:
+ output:
+ id: 123
+ firstname: Test1
+ lastname: Test2
+```
diff --git a/docs/reference/tasks/counter_task.md b/docs/reference/tasks/counter_task.md
new file mode 100644
index 00000000..455539e4
--- /dev/null
+++ b/docs/reference/tasks/counter_task.md
@@ -0,0 +1,39 @@
+CounterTask
+==================
+
+Count the number of times the task is processed and continue every N iteration (skip the rest of the time)
+
+Flush at the end with the actual count.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\CounterTask`
+
+Accepted inputs
+---------------
+
+`any`, must implement IterableTaskInterface
+
+Possible outputs
+----------------
+
+`int`: outputs the number of times the counter is called
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|---------------|-------|----------|----------|---------------------------------------------------|
+| `flush_every` | `int` | **X** | | The period at which the task will produce outputs |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\CounterTask'
+ options:
+ flush_every: 2
+```
diff --git a/docs/reference/tasks/csv_reader_task.md b/docs/reference/tasks/csv_reader_task.md
new file mode 100644
index 00000000..0e7b4c3a
--- /dev/null
+++ b/docs/reference/tasks/csv_reader_task.md
@@ -0,0 +1,48 @@
+CsvReaderTask
+=============
+
+Reads a CSV file and iterate on each line, returning an array of key -> values. Skips empty lines.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\Csv\CsvReaderTask`
+* **Iterable task**
+
+Accepted inputs
+---------------
+
+Input is ignored
+
+Possible outputs
+----------------
+
+`array`: foreach line, it will return a php array where key comes from headers and values are strings.
+Underlying method is [fgetcsv](https://secure.php.net/manual/en/function.fgetcsv.php).
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|-------------------|-------------------|:---------:|----------|--------------------------------------------------------------------------------------------------|
+| `file_path` | `string` | **X** | | Path of the file to read from (relative to symfony root or absolute) |
+| `delimiter` | `string` | | `;` | CSV delimiter |
+| `enclosure` | `string` | | `"` | CSV enclosure character |
+| `escape` | `string` | | `\\` | CSV escape character |
+| `headers` | `array` or `null` | | `null` | Static list of CSV headers, without the option, it will be dynamically read from first input |
+| `mode` | `string` | | `rb` | File open mode (see [fopen mode parameter](https://secure.php.net/manual/en/function.fopen.php)) |
+| `log_empty_lines` | `bool` | | `false` | Log when the output is empty |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\File\Csv\CsvReaderTask'
+ options:
+ file_path: 'path/to/file.csv'
+ delimiter: '{{ delimiter }}' ## delimiter is contextualized you must add -c delimiter:";" on console execute
+```
+
+
diff --git a/docs/reference/tasks/csv_writer_task.md b/docs/reference/tasks/csv_writer_task.md
new file mode 100644
index 00000000..0ff7e2ed
--- /dev/null
+++ b/docs/reference/tasks/csv_writer_task.md
@@ -0,0 +1,61 @@
+CsvWriterTask
+=============
+
+Write given array to a CSV file, will wait until the end of the previous iteration (this is a blocking task) and outputs
+the file path.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\Csv\CsvWriterTask`
+* **Blocking task**
+
+Accepted inputs
+---------------
+
+`array`: foreach line, it will need a php array where key match the headers and values are convertible to string.
+Underlying method is [fputcsv](https://secure.php.net/manual/en/function.fputcsv.php).
+
+Possible outputs
+----------------
+
+`string`: absolute path of the produced file
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|-------------------|-------------------|:--------:|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `file_path` | `string` | **X** | | Path of the file to write to (relative to symfony root or absolute).
It can also take placeholders (`{date}`, `{date_time}`, `{timestamp}` `{unique_token}`) to insert data into the filename |
+| `delimiter` | `string` | | `;` | CSV delimiter |
+| `enclosure` | `string` | | `"` | CSV enclosure character |
+| `escape` | `string` | | `\\` | CSV escape character |
+| `headers` | `array` or `null` | | `null` | Static list of CSV headers, without the option, it will be dynamically read from first line |
+| `mode` | `string` | | `wb` | File open mode (see [fopen mode parameter](https://secure.php.net/manual/en/function.fopen.php)) |
+| `split_character` | `string` | | `\|` | Used to implode array values |
+| `write_headers` | `bool` | | `true` | Write the headers as a first line |
+
+Example
+----------------
+
+```yaml
+# Task configuration level
+entry:
+ service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask'
+ outputs: [ write ]
+ options:
+ output:
+ - column1: value1-1
+ column2: value2-1
+ column3: value3-1
+ - column1: value1-2
+ column2: value2-2
+ column3: value3-2
+ - column1: ''
+ column2: null
+ column3: value3-3
+write:
+ service: '@CleverAge\ProcessBundle\Task\File\Csv\CsvWriterTask'
+ options:
+ file_path: '%kernel.project_dir%/var/data/csv_writer_{date_time}.csv'
+```
diff --git a/doc/reference/tasks/debug_task.md b/docs/reference/tasks/debug_task.md
similarity index 68%
rename from doc/reference/tasks/debug_task.md
rename to docs/reference/tasks/debug_task.md
index 1a98b263..cfaf44d7 100644
--- a/doc/reference/tasks/debug_task.md
+++ b/docs/reference/tasks/debug_task.md
@@ -20,7 +20,21 @@ Possible outputs
`any`: re-output given input
+Options
+-------
+
+None
+
Example
----------------
-https://github.com/cleverage/process-bundle-ui-demo/blob/main/config/packages/process/demo.debug.yaml
\ No newline at end of file
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
+ options:
+ output:
+ id: 123
+ firstname: Test1
+ lastname: Test2
+```
diff --git a/doc/reference/tasks/denormalizer_task.md b/docs/reference/tasks/denormalizer_task.md
similarity index 100%
rename from doc/reference/tasks/denormalizer_task.md
rename to docs/reference/tasks/denormalizer_task.md
diff --git a/doc/reference/tasks/die_task.md b/docs/reference/tasks/die_task.md
similarity index 66%
rename from doc/reference/tasks/die_task.md
rename to docs/reference/tasks/die_task.md
index cdde437e..741fdeed 100644
--- a/doc/reference/tasks/die_task.md
+++ b/docs/reference/tasks/die_task.md
@@ -19,7 +19,16 @@ Possible outputs
None
+Options
+-------
+
+None
+
Example
----------------
-https://github.com/cleverage/process-bundle-ui-demo/blob/main/config/packages/process/demo.die.yaml
\ No newline at end of file
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\Debug\DieTask'
+```
diff --git a/docs/reference/tasks/dummy_task.md b/docs/reference/tasks/dummy_task.md
new file mode 100644
index 00000000..323cafc5
--- /dev/null
+++ b/docs/reference/tasks/dummy_task.md
@@ -0,0 +1,48 @@
+DummyTask
+=========
+
+Passes the input to the output, can be used as an entry point allow multiple tasks to be run at the entry point
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\DummyTask`
+
+Accepted inputs
+---------------
+
+`any`
+
+Possible outputs
+----------------
+
+`any`: re-output given input
+
+Options
+-------
+
+None
+
+Example
+-------
+
+```yaml
+# Task configuration level
+dummy:
+ service: '@CleverAge\ProcessBundle\Task\DummyTask'
+ outputs: [output1, output2]
+output1:
+ service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
+ options:
+ output:
+ id: 123
+ firstname: Test1
+ lastname: Test2
+output2:
+ service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
+ options:
+ output:
+ id: 456
+ firstname: Test3
+ lastname: Test4
+```
diff --git a/docs/reference/tasks/error_forwarder_task.md b/docs/reference/tasks/error_forwarder_task.md
new file mode 100644
index 00000000..592c9cb2
--- /dev/null
+++ b/docs/reference/tasks/error_forwarder_task.md
@@ -0,0 +1,35 @@
+CounterTask
+==================
+
+This is a dummy task mostly intended for testing purpose.
+
+Forward any input to the error output.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\Debug\ErrorForwarderTask`
+
+Accepted inputs
+---------------
+
+`any`
+
+Possible outputs
+----------------
+
+`any`: directly error_output given `output` option
+
+Options
+-------
+
+None
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\Debug\ErrorForwarderTask'
+```
diff --git a/docs/reference/tasks/event_dispatcher_task.md b/docs/reference/tasks/event_dispatcher_task.md
new file mode 100644
index 00000000..88c87e98
--- /dev/null
+++ b/docs/reference/tasks/event_dispatcher_task.md
@@ -0,0 +1,39 @@
+EventDispatcherTask
+===================
+
+Call the Symfony event dispatcher
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\Event\EventDispatcherTask`
+
+Accepted inputs
+---------------
+
+`any`
+
+Possible outputs
+----------------
+
+* `any` when `passive` option is set to true
+* `null` in other cases
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|--------------|----------|:---------:|----------|----------------------|
+| `event_name` | `string` | **X** | | |
+| `passive` | `bool` | | `true` | Pass input to output |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\Event\EventDispatcherTask'
+ options:
+ event_name: 'myapp.myevent'
+```
diff --git a/docs/reference/tasks/file_reader_task.md b/docs/reference/tasks/file_reader_task.md
new file mode 100644
index 00000000..e0097a13
--- /dev/null
+++ b/docs/reference/tasks/file_reader_task.md
@@ -0,0 +1,40 @@
+FileReaderTask
+=============
+
+Reads a file and return raw content as a string
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\FileReaderTask`
+
+Accepted inputs
+---------------
+
+Input is ignored
+
+Possible outputs
+----------------
+
+`string`: raw content of the file.
+Underlying method is [file_get_contents](https://www.php.net/manual/en/function.file-get-contents.php).
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|------------|----------|:---------:|----------|------------------------------------------|
+| `filename` | `string` | **X** | | Path of the file to read from (absolute) |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\File\FileReaderTask'
+ options:
+ filename: 'path/to/file.txt'
+```
+
+
diff --git a/docs/reference/tasks/file_splitter_task.md b/docs/reference/tasks/file_splitter_task.md
new file mode 100644
index 00000000..a652eb4b
--- /dev/null
+++ b/docs/reference/tasks/file_splitter_task.md
@@ -0,0 +1,42 @@
+FileSplitterTask
+=============
+
+Split long file into smaller ones
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\FileSplitterTask`
+* **Iterable task**
+
+Accepted inputs
+---------------
+
+`array`: inputs are merged with task defined options.
+
+Possible outputs
+----------------
+
+`string`: absolute path of the produced file
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|-------------------------|-----------------|:--------:|----------|------------------------------------------|
+| `file_path` | `string` | **X** | | Path of the file to read from (absolute) |
+| `max_lines` | `int` | **X** | 1000 | Max number of line on a produced file |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+entry:
+ service: '@CleverAge\ProcessBundle\Task\File\FileSplitterTask'
+ options:
+ file_path: '%kernel.project_dir%/var/data/json_stream_reader.json'
+ max_lines: 1
+```
+
+
diff --git a/docs/reference/tasks/folder_browser_task.md b/docs/reference/tasks/folder_browser_task.md
new file mode 100644
index 00000000..3dcc44ef
--- /dev/null
+++ b/docs/reference/tasks/folder_browser_task.md
@@ -0,0 +1,43 @@
+FolderBrowserTask
+=============
+
+Reads a folder and iterate on each file, returning absolute path as string.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\FolderBrowserTask`
+* **Iterable task**
+
+Accepted inputs
+---------------
+
+Input is ignored
+
+Possible outputs
+----------------
+
+`string`: absolute path of the file.
+Underlying method is [Symfony Finder component](https://symfony.com/doc/current/components/finder.html).
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|-------------------|-----------------------------|:---------:|---------------------------|----------------------------------------------------------------------------------------|
+| `folder_path` | `string` | **X** | | Path of the directory to read from |
+| `name_pattern` | `null`, `string` or `array` | | null | Restrict files using a pattern (a regexp, a glob, or a string) or an array of patterns |
+| `empty_log_level` | `string` | | Psr\Log\LogLevel::WARNING | From Psr\Log\LogLevel constants |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\File\FolderBrowserTask'
+ options:
+ folder_path: '%kernel.project_dir%/var/data'
+```
+
+
diff --git a/doc/reference/tasks/input_aggregator_task.md b/docs/reference/tasks/input_aggregator_task.md
similarity index 100%
rename from doc/reference/tasks/input_aggregator_task.md
rename to docs/reference/tasks/input_aggregator_task.md
diff --git a/docs/reference/tasks/input_csv_reader_task.md b/docs/reference/tasks/input_csv_reader_task.md
new file mode 100644
index 00000000..59e67d2a
--- /dev/null
+++ b/docs/reference/tasks/input_csv_reader_task.md
@@ -0,0 +1,46 @@
+InputCsvReaderTask
+=============
+
+Reads a CSV file and iterate on each line, returning an array of key -> values. Skips empty lines.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\Csv\InputCsvReaderTask`
+* **Iterable task**
+
+Accepted inputs
+---------------
+
+`string`: file path
+
+Possible outputs
+----------------
+
+`array`: foreach line, it will return a php array where key comes from headers and values are strings.
+Underlying method is [fgetcsv](https://secure.php.net/manual/en/function.fgetcsv.php).
+
+Options
+-------
+
+Same as [CsvReaderTask](reference/tasks/csv_reader_task.md) except following :
+
+| Code | Type | Required | Default | Description |
+|-------------|----------|:--------:|---------|----------------------------|
+| `file_path` | | | | Removed, use input instead |
+| `base_path` | `string` | | `` | |
+
+Example
+-------
+
+```yaml
+clever_age_process:
+ configurations:
+ process.name:
+ entry_point: entrypoint # for upload_and_run process entry_point is required
+ tasks:
+ entrypoint:
+ service: '@CleverAge\ProcessBundle\Task\File\Csv\InputCsvReaderTask'
+ options:
+ delimiter: '{{ delimiter }}' ## delimiter is contextualized you must add -c delimiter:";" on console execute
+```
diff --git a/docs/reference/tasks/input_file_reader_task.md b/docs/reference/tasks/input_file_reader_task.md
new file mode 100644
index 00000000..d960ba21
--- /dev/null
+++ b/docs/reference/tasks/input_file_reader_task.md
@@ -0,0 +1,41 @@
+InputFileReaderTask
+=============
+
+Reads a file and return raw content as a string
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\InputFileReaderTask`
+
+Accepted inputs
+---------------
+
+`string`: file path
+
+Possible outputs
+----------------
+
+`string`: raw content of the file.
+Underlying method is [file_get_contents](https://www.php.net/manual/en/function.file-get-contents.php).
+
+Options
+-------
+
+None
+
+Example
+-------
+
+```yaml
+# Task configuration level
+entry:
+ service: '@CleverAge\ProcessBundle\Task\File\FolderBrowserTask'
+ options:
+ folder_path: '%kernel.project_dir%/var/data'
+ outputs: read
+read:
+ service: '@CleverAge\ProcessBundle\Task\File\InputFileReaderTask'
+```
+
+
diff --git a/docs/reference/tasks/input_folder_browser_task.md b/docs/reference/tasks/input_folder_browser_task.md
new file mode 100644
index 00000000..e95e2401
--- /dev/null
+++ b/docs/reference/tasks/input_folder_browser_task.md
@@ -0,0 +1,47 @@
+InputFolderBrowserTask
+=============
+
+Reads a folder and iterate on each file, returning absolute path as string.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\InputFolderBrowserTask`
+* **Iterable task**
+
+Accepted inputs
+---------------
+
+`string`: folder path
+
+Possible outputs
+----------------
+
+`string`: absolute path of the file.
+Underlying method is [Symfony Finder component](https://symfony.com/doc/current/components/finder.html).
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|--------------------|----------|:---------:|---------|---------------------------------------|
+| `base_folder_path` | `string` | | | Concatenated with input `folder_path` |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+entry:
+ service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
+ options:
+ output: '/var/data'
+ outputs: directory
+directory:
+ service: '@CleverAge\ProcessBundle\Task\File\InputFolderBrowserTask'
+ options:
+ base_folder_path: '%kernel.project_dir%'
+ outputs: read
+```
+
+
diff --git a/doc/reference/tasks/input_iterator_task.md b/docs/reference/tasks/input_iterator_task.md
similarity index 100%
rename from doc/reference/tasks/input_iterator_task.md
rename to docs/reference/tasks/input_iterator_task.md
diff --git a/docs/reference/tasks/input_line_reader_task.md b/docs/reference/tasks/input_line_reader_task.md
new file mode 100644
index 00000000..da185453
--- /dev/null
+++ b/docs/reference/tasks/input_line_reader_task.md
@@ -0,0 +1,42 @@
+InputLineReaderTask
+=============
+
+Reads a file and iterate on each line, returning content as string. Skips empty lines.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\InputLineReaderTask`
+* **Iterable task**
+
+Accepted inputs
+---------------
+
+`string`: file path
+
+Possible outputs
+----------------
+
+`string`: foreach line, it will return content as string.
+Underlying method is [SplFileObject](https://www.php.net/manual/en/class.splfileobject.php).
+
+Options
+-------
+
+None
+
+Example
+-------
+
+```yaml
+# Task configuration level
+entry:
+ service: '@CleverAge\ProcessBundle\Task\File\FolderBrowserTask'
+ options:
+ folder_path: '%kernel.project_dir%/var/data'
+ outputs: read
+read:
+ service: '@CleverAge\ProcessBundle\Task\File\InputLineReaderTask'
+```
+
+
diff --git a/doc/reference/tasks/iterable_batch_task.md b/docs/reference/tasks/iterable_batch_task.md
similarity index 100%
rename from doc/reference/tasks/iterable_batch_task.md
rename to docs/reference/tasks/iterable_batch_task.md
diff --git a/docs/reference/tasks/json_stream_reader_task.md b/docs/reference/tasks/json_stream_reader_task.md
new file mode 100644
index 00000000..77fc2329
--- /dev/null
+++ b/docs/reference/tasks/json_stream_reader_task.md
@@ -0,0 +1,51 @@
+JsonStreamReaderTask
+=============
+
+Reads a json file and iterate on each line, returning decoded content as array. Skips empty lines.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\JsonStream\JsonStreamReaderTask`
+* **Iterable task**
+
+Accepted inputs
+---------------
+
+`string`: Path of the file to read from (absolute)
+
+Possible outputs
+----------------
+
+`array`: foreach line, it will return content as array.
+Underlying method are [SplFileObject::fgets](https://www.php.net/manual/fr/splfileobject.fgets.php) and [json_decode](https://www.php.net/manual/en/function.json-decode.php).
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|-------------------------|-----------------|:--------:|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `spl_file_object_flags` | `array`, `null` | | `\SplFileObject::DROP_NEW_LINE \SplFileObject::READ_AHEAD \SplFileObject::SKIP_EMPTY` | Flags to pass to `SplFileObject` constructor, can be empty.
See [PHP documentation](https://www.php.net/manual/en/splfileobject.construct.php) for more information on available flags. |
+| `json_flags` | `array`, `null` | | `\JSON_THROW_ON_ERROR` | Flags to pass to `json_encode` function, can be empty.
See [PHP documentation](https://www.php.net/manual/en/function.json-encode.php) for more information on available flags. |
+
+
+Example
+-------
+
+```yaml
+# Task configuration level
+entry:
+ service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask'
+ outputs: read
+ options:
+ output:
+ file_path: '%kernel.project_dir%/var/data/json_stream_reader.json'
+read:
+ service: '@CleverAge\ProcessBundle\Task\File\JsonStream\JsonStreamReaderTask'
+ options:
+ spl_file_object_flags: []
+ json_flags:
+ - !php/const JSON_ERROR_NONE
+```
+
+
diff --git a/docs/reference/tasks/json_stream_writer_task.md b/docs/reference/tasks/json_stream_writer_task.md
new file mode 100644
index 00000000..9b4a2302
--- /dev/null
+++ b/docs/reference/tasks/json_stream_writer_task.md
@@ -0,0 +1,59 @@
+JsonStreamWriterTask
+===============
+
+Write given array to a json file, will wait until the end of the previous iteration (this is a blocking task) and outputs
+the file path.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\JsonStream\JsonStreamWriterTask`
+* **Blocking task**
+
+Accepted inputs
+---------------
+
+`array`
+
+Possible outputs
+----------------
+
+`string`: absolute path of the produced file
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|-------------------------|-----------------|:--------:|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `file_path` | `string` | **X** | | Path of the file to write to (relative to symfony root or absolute).
It can also take placeholders (`{date}`, `{date_time}`, `{timestamp}` `{unique_token}`) to insert data into the filename |
+| `spl_file_object_flags` | `array`, `null` | | `\SplFileObject::DROP_NEW_LINE \SplFileObject::READ_AHEAD \SplFileObject::SKIP_EMPTY` | Flags to pass to `SplFileObject` constructor, can be empty.
See [PHP documentation](https://www.php.net/manual/en/splfileobject.construct.php) for more information on available flags. |
+| `json_flags` | `array`, `null` | | `\JSON_THROW_ON_ERROR` | Flags to pass to `json_encode` function, can be empty.
See [PHP documentation](https://www.php.net/manual/en/function.json-encode.php) for more information on available flags. |
+
+Example
+----------------
+
+```yaml
+# Task configuration level
+entry:
+ service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask'
+ outputs: [ write ]
+ options:
+ output:
+ - column1: value1-1
+ column2: value2-1
+ column3: value3-1
+ - column1: value1-2
+ column2: value2-2
+ column3: value3-2
+ - column1: ''
+ column2: null
+ column3: value3-3
+write:
+ service: '@CleverAge\ProcessBundle\Task\File\JsonStream\JsonStreamWriterTask'
+ options:
+ file_path: '%kernel.project_dir%/var/data/json_stream_writer_{date_time}.csv'
+ spl_file_object_flags: []
+ json_flags:
+ - !php/const JSON_PRETTY_PRINT
+ - !php/const JSON_UNESCAPED_SLASHES
+```
diff --git a/docs/reference/tasks/line_reader_task.md b/docs/reference/tasks/line_reader_task.md
new file mode 100644
index 00000000..8c5f2e4e
--- /dev/null
+++ b/docs/reference/tasks/line_reader_task.md
@@ -0,0 +1,41 @@
+LineReaderTask
+=============
+
+Reads a file and iterate on each line, returning content as string. Skips empty lines.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\File\LineReaderTask`
+* **Iterable task**
+
+Accepted inputs
+---------------
+
+Input is ignored
+
+Possible outputs
+----------------
+
+`string`: foreach line, it will return content as string.
+Underlying method is [SplFileObject](https://www.php.net/manual/en/class.splfileobject.php).
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|------------|----------|:---------:|----------|------------------------------------------|
+| `filename` | `string` | **X** | | Path of the file to read from (absolute) |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\File\LineReaderTask'
+ options:
+ filename: 'path/to/file.txt'
+```
+
+
diff --git a/docs/reference/tasks/logger_task.md b/docs/reference/tasks/logger_task.md
new file mode 100644
index 00000000..ffcc51ac
--- /dev/null
+++ b/docs/reference/tasks/logger_task.md
@@ -0,0 +1,41 @@
+LoggerTask
+=============
+
+Log a specific message with context.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\Reporting\LoggerTask`
+
+Accepted inputs
+---------------
+
+`any`
+
+Possible outputs
+----------------
+
+`any` : forwarded input
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|-------------|--------------------|:---------:|-------------------|---------------------------------|
+| `level` | `string` | **X** | `debug` | Use `Psr\Log\LogLevel` values |
+| `message` | `string` | | `Log state input` | |
+| `context` | `array` | | `['input']` | |
+| `reference` | `string` or `null` | | `null` | Override `context['reference']` |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask'
+ options:
+ level: warning
+ message: DEMO LOGGER
+```
diff --git a/doc/reference/tasks/normalizer_task.md b/docs/reference/tasks/normalizer_task.md
similarity index 100%
rename from doc/reference/tasks/normalizer_task.md
rename to docs/reference/tasks/normalizer_task.md
diff --git a/doc/reference/tasks/property_getter_task.md b/docs/reference/tasks/property_getter_task.md
similarity index 100%
rename from doc/reference/tasks/property_getter_task.md
rename to docs/reference/tasks/property_getter_task.md
diff --git a/doc/reference/tasks/property_setter_task.md b/docs/reference/tasks/property_setter_task.md
similarity index 100%
rename from doc/reference/tasks/property_setter_task.md
rename to docs/reference/tasks/property_setter_task.md
diff --git a/docs/reference/tasks/stopwatch_task.md b/docs/reference/tasks/stopwatch_task.md
new file mode 100644
index 00000000..4953239b
--- /dev/null
+++ b/docs/reference/tasks/stopwatch_task.md
@@ -0,0 +1,33 @@
+StopwatchTask
+=============
+
+Log all the __root__ events of the Stopwatch component.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\Debug\StopwatchTask`
+
+Accepted inputs
+---------------
+
+`any`
+
+Possible outputs
+----------------
+
+None
+
+Options
+-------
+
+None
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\Debug\StopwatchTask'
+```
diff --git a/docs/reference/tasks/transformer_task.md b/docs/reference/tasks/transformer_task.md
new file mode 100644
index 00000000..efc98bcd
--- /dev/null
+++ b/docs/reference/tasks/transformer_task.md
@@ -0,0 +1,40 @@
+TransformerTask
+===============
+
+Pass an input into a chain of transformers.
+
+See transformers references.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Task\TransformerTask`
+
+Accepted inputs
+---------------
+
+`any`: it should match the 1st expected input of the transform chain
+
+Possible outputs
+----------------
+
+`any`: result of the transform chain
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|----------------|---------|:---------:|----------|------------------------------------------------------------------------------|
+| `transformers` | `array` | **X** | | List of transformers, see [TransformerTrait](../traits/transformer_trait.md) |
+
+Example
+-------
+
+```yaml
+# Task configuration level
+code:
+ service: '@CleverAge\ProcessBundle\Task\TransformerTask'
+ options:
+ transformers:
+ slugify: ~
+```
diff --git a/doc/reference/tasks/xml_reader_task.md b/docs/reference/tasks/xml_reader_task.md
similarity index 100%
rename from doc/reference/tasks/xml_reader_task.md
rename to docs/reference/tasks/xml_reader_task.md
diff --git a/doc/reference/tasks/xml_writer_task.md b/docs/reference/tasks/xml_writer_task.md
similarity index 100%
rename from doc/reference/tasks/xml_writer_task.md
rename to docs/reference/tasks/xml_writer_task.md
diff --git a/doc/reference/traits/condition_trait.md b/docs/reference/traits/condition_trait.md
similarity index 100%
rename from doc/reference/traits/condition_trait.md
rename to docs/reference/traits/condition_trait.md
diff --git a/doc/reference/traits/transformer_trait.md b/docs/reference/traits/transformer_trait.md
similarity index 100%
rename from doc/reference/traits/transformer_trait.md
rename to docs/reference/traits/transformer_trait.md
diff --git a/doc/reference/transformers/_template.md b/docs/reference/transformers/_template.md
similarity index 100%
rename from doc/reference/transformers/_template.md
rename to docs/reference/transformers/_template.md
diff --git a/doc/reference/transformers/array_filter_transformer.md b/docs/reference/transformers/array_filter_transformer.md
similarity index 100%
rename from doc/reference/transformers/array_filter_transformer.md
rename to docs/reference/transformers/array_filter_transformer.md
diff --git a/docs/reference/transformers/array_map_transformer.md b/docs/reference/transformers/array_map_transformer.md
new file mode 100644
index 00000000..32f9bd01
--- /dev/null
+++ b/docs/reference/transformers/array_map_transformer.md
@@ -0,0 +1,47 @@
+ArrayMapTransformer
+=========================
+
+Applies transformers to each element of an array.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Transformer\Array\ArrayMapTransformer`
+* **Transformer code**: `array_map`
+
+Accepted inputs
+---------------
+
+`array`
+
+Possible outputs
+----------------
+
+`string`
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|----------------|---------|:--------:|---------|------------------------------------------------------------------------------|
+| `transformers` | `array` | **X** | | List of transformers, see [TransformerTrait](../traits/transformer_trait.md) |
+| `skip_null` | `bool` | | `false` | If true continue without applying other transformers on null values |
+
+
+Examples
+--------
+
+```yaml
+# Transformer mapping level
+array_map:
+ code:
+ - '[id]'
+ - '[firstname]'
+ - '[lastname]'
+ transformers:
+ array_map:
+ transformers:
+ cast:
+ type: 'string'
+ uppercase: ~
+```
diff --git a/doc/reference/transformers/date_format.md b/docs/reference/transformers/date_format.md
similarity index 100%
rename from doc/reference/transformers/date_format.md
rename to docs/reference/transformers/date_format.md
diff --git a/doc/reference/transformers/date_parser.md b/docs/reference/transformers/date_parser.md
similarity index 100%
rename from doc/reference/transformers/date_parser.md
rename to docs/reference/transformers/date_parser.md
diff --git a/docs/reference/transformers/implode_transformer.md b/docs/reference/transformers/implode_transformer.md
new file mode 100644
index 00000000..fb5d27c7
--- /dev/null
+++ b/docs/reference/transformers/implode_transformer.md
@@ -0,0 +1,43 @@
+ImplodeTransformer
+=========================
+
+Join array elements with a string
+
+This transformer uses the php internal function: https://www.php.net/manual/en/function.implode.php
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Transformer\String\ImplodeTransformer`
+* **Transformer code**: `implode`
+
+Accepted inputs
+---------------
+
+`array`
+
+Possible outputs
+----------------
+
+`string`
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|-------------|----------|:--------:|---------|-------------|
+| `separator` | `string` | **X** | `|` | |
+
+Examples
+--------
+
+```yaml
+# Transformer mapping level
+sprintf_multiple:
+ code:
+ - '[firstname]'
+ - '[lastname]'
+ transformers:
+ implode:
+ separator: '-'
+```
diff --git a/docs/reference/transformers/mapping_transformer.md b/docs/reference/transformers/mapping_transformer.md
new file mode 100644
index 00000000..4971f66b
--- /dev/null
+++ b/docs/reference/transformers/mapping_transformer.md
@@ -0,0 +1,130 @@
+MappingTransformer
+==================
+
+Transform a set of properties into a (possibly) new output.
+
+Basically, the algorithm is:
+* determine destination (from `initial_value` or `keep_input`)
+* foreach property
+ - get value(s) from the source(s) (from `code`, `constant` or `set_null`)
+ - use additional transformers on the value
+ - merge the property and its value into the destination (with `merge_callback`, the property accessor, or as a simple array index)
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Transformer\MappingTransformer`
+* **Transformer code**: `mapping`
+
+Accepted inputs
+---------------
+
+`array` or `object` that can be accessed by the property accessor
+
+Possible outputs
+----------------
+
+`array` or `object` (the "destination") containing the property manipulated by the transformer
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|------------------|----------------------|:---------:|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `mapping` | `array` | **X** | | List of property => sub-mapping options. The property code can be a single string to be used as an array index, or a writable property path |
+| `ignore_missing` | `bool` | | `false` | Ignore property accessor errors for the whole mapping |
+| `keep_input` | `bool` | | `false` | Use input as the mapping destination (takes precedence on `initial_value`). Keep in mind that due to PHP behavior, arrays are cloned while objects are passed by reference |
+| `initial_value` | `any` | | `[]` | Set the mapping destination |
+| `merge_callback` | `callable` or `null` | | `null` | Allow to change how a property can be set in the destination |
+
+Foreach property there is the following options.
+
+| Code | Type | Required | Default | Description |
+|------------------|-------------------------------|:---------:|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `code` | `string` or `array` or `null` | | `null` | A property path, or a list of property path. By default it would be the same as the destination property. Will be used as a source. The special value '.' access the whole object. |
+| `constant` | `any` | | `null` | If not `null`, will be directly used as a source (takes precedence on `code`) |
+| `set_null` | `bool` | | `false` | If `true`, `null` will be directly used as a source (takes precedence on `code`) |
+| `ignore_missing` | `bool` | | `false` | Ignore property accessor errors for this source |
+| `transformers` | `array` | | `[]` | List of sub-transformers, see [TransformerTrait](../traits/transformer_trait.md) |
+
+Examples
+--------
+
+* Simple transformation, will output an array with keys "code", "label", "type", "reference", "required" and "slug"
+ - required input: an array with keys "Code", "label", "Type", "Name" and "ID"
+ - output: an array with keys "code", "label", "type", "reference", "required" and "slug"
+
+```yaml
+# Transformer options level
+mapping:
+ mapping:
+ code: # Simple mapping from "Code" to "code"
+ code: '[Code]'
+ "[label]": ~ # Value from "label" will be kept with the same name
+ type: # Get value from "type" and map values (with a default)
+ code: '[Type]'
+ transformers:
+ convert_value:
+ ignore_missing: true
+ map:
+ TEXTE: text
+ NUMERIQUE: number
+ LISTE_DEROULANTE: simpleselect
+ CHOIX_MULTIPLES: multiselect
+ DATE: date
+ default:
+ value: unknown
+ reference: # "null" column
+ set_null: true
+ required: # "true" column
+ constant: true
+ slug: # Get multiple sources, slugify them, and merge them
+ code:
+ name: '[Name]'
+ id: '[ID]'
+ transformers:
+ array_map:
+ transformers:
+ slugify: ~
+ implode:
+ separator: '_'
+```
+
+* Mapping in depth, using objects
+ - required input: an object with an iterable property "productItems", containing objects with property "longName"
+ - output: an array with key "items", containing a list of array with key "name"
+
+```yaml
+# Transformer options level
+mapping: # Transformer code
+ mapping: # MappingTransformer options
+ items: # property code
+ code: 'productItems' # property options
+ transformers:
+ array_map: # Transformer code
+ transformers: # ArrayMapTransformer options
+ mapping: # Transformer code
+ mapping: # MappingTransformer options
+ name: # property code
+ code: 'longName' # property options
+```
+
+* Advanced property setter
+ - required input: an object with a property "address", containing an object with properties "postCode" and "customer", itself containing an object with property "hasFlag"
+ - output: same object, with a modified "address.customer.hasFlag"
+
+```yaml
+# Transformer options level
+mapping:
+ keep_input: true
+ mapping:
+ address.customer.hasFlag:
+ code: address.postCode
+ transformers:
+ convert_value:
+ ignore_missing: true
+ map:
+ 69005: true
+ default:
+ value: false
+```
diff --git a/docs/reference/transformers/multi_replace_transformer.md b/docs/reference/transformers/multi_replace_transformer.md
new file mode 100644
index 00000000..4a3f035e
--- /dev/null
+++ b/docs/reference/transformers/multi_replace_transformer.md
@@ -0,0 +1,44 @@
+MultiReplaceTransformer
+=========================
+
+Quickly replace a list of values in a string.
+
+This transformer uses the php internal function: https://www.php.net/manual/en/function.str-replace.php
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Transformer\MultiReplaceTransformer`
+* **Transformer code**: `multi_replace`
+
+Accepted inputs
+---------------
+
+Any value that can be cast to string.
+
+Possible outputs
+----------------
+
+`string`
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|-------------------|---------|:--------:|---------|-----------------------------------|
+| `replace_mapping` | `array` | **X** | | $search as key, $replace as value |
+
+Examples
+--------
+
+```yaml
+# Transformer mapping level
+multi_replace:
+ code:
+ - '[firstname]'
+ transformers:
+ multi_replace:
+ replace_mapping:
+ ' ': '!'
+ 'name': ''
+```
diff --git a/docs/reference/transformers/preg_match_transformer.md b/docs/reference/transformers/preg_match_transformer.md
new file mode 100644
index 00000000..83270645
--- /dev/null
+++ b/docs/reference/transformers/preg_match_transformer.md
@@ -0,0 +1,53 @@
+PregMatchTransformer
+=========================
+
+Perform a regular expression match
+
+This transformer uses the php internal function: https://www.php.net/manual/en/function.preg-match.php
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Transformer\String\PregMatchTransformer`
+* **Transformer code**: `preg_match`
+
+Accepted inputs
+---------------
+
+`string`
+
+Possible outputs
+----------------
+
+`array` or `null`
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|------------|-----------|:--------:|---------|------------------------------------------|
+| `pattern` | `string` | **X** | | |
+| `flags` | `int` | | 0 | |
+| `offset` | `int` | | 0 | |
+| `mode_all` | `boolean` | | false | Use preg_match_all instead of preg_match |
+
+Examples
+--------
+
+```yaml
+# Transformer options level
+entry:
+ service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask'
+ outputs: [ preg_match ]
+ options:
+ output: 'foobarbaz'
+preg_match:
+ service: '@CleverAge\ProcessBundle\Task\TransformerTask'
+ options:
+ transformers:
+ preg_match:
+ pattern: '/(foo)(bar)(baz)/'
+ flags: !php/const PREG_OFFSET_CAPTURE
+ property_accessor:
+ property_path: '[2]'
+```
diff --git a/docs/reference/transformers/rules_transformer.md b/docs/reference/transformers/rules_transformer.md
new file mode 100644
index 00000000..71ecc40d
--- /dev/null
+++ b/docs/reference/transformers/rules_transformer.md
@@ -0,0 +1,93 @@
+RulesTransformer
+================
+
+Uses a set of rules to apply some set of transformers on a value. Basically behaves like a `if/elseif/else` block.
+
+By default a rule uses a variable named `value` containing anything you passed in input (`array`, `string`, ...). But this
+can be overridden using options `use_value_as_variables` as `true` and setting `expression_variables` to a static list of
+input variables.
+
+Note that `expression_variables` can also be set to `null` for more flexibility, but this disable initial parsing and decrease
+performances.
+
+See [The ExpressionLanguage Component Reference](https://symfony.com/doc/current/components/expression_language.html) for
+more information.
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Transformer\RulesTransformer`
+* **Transformer code**: `rules`
+
+Accepted inputs
+---------------
+
+`any` or an `array` of `variable code => value` injectable into an expression
+
+Possible outputs
+----------------
+
+`any` resulting from a transformation set.
+
+Without any matching rules, the value itself is returned.
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|--------------------------|-------------------|:--------:|-----------|---------------------------------------------------------------------|
+| `rules_set` | `array` | **X** | | Ordered list of rules, see bellow for details |
+| `use_value_as_variables` | `bool` | | `false` | Use given value as an array of variable to inject in expression |
+| `expression_variables` | `array` or `null` | | `[value]` | Name of variables injected in the expression at initialization time |
+
+Foreach rule there is the following options.
+
+| Code | Type | Required | Default | Description |
+|----------------|--------------------|:---------:|---------|----------------------------------------------------------------------------------------------------------------------------------------------|
+| `condition` | `string` or `null` | | `null` | An expression used to match a value |
+| `default` | `bool` | | `false` | Mark this rule as a default rule. The given rule must be the last, cannot have a condition, and there cannot have 2 default in the same time |
+| `transformers` | `array` | | `[]` | List of sub-transformers, see [TransformerTrait](../traits/transformer_trait.md) |
+| `constant` | `any` | | `null` | If not `null`, given value will be directly output (takes precedence on `transformers`) |
+| `set_null` | `bool` | | `false` | If `true`, `null` will be directly output (takes precedence on `constant`) |
+
+Examples
+--------
+
+* Simple rules with default value
+ - input value is an array containing an `order` object and a `customer` object
+ - output will be either a value from customer, or a numeric constant, or null
+
+```yaml
+# Transformer options level
+rules:
+ rules_set:
+ - condition: 'value["order"].origin === "marketplace"'
+ transformers:
+ property_accessor:
+ property_path: '[customer].id'
+ - condition: 'value["order"].origin === "e-commerce"'
+ constant: 1234
+ - default: true
+ set_null: true
+```
+
+* Use value as variables
+ - same example as above
+ - can be useful for more verbose expression
+ - transformers still get the input as the initial array
+
+```yaml
+# Transformer options level
+rules:
+ use_value_as_variables: true
+ expression_variables: [order, customer]
+ rules_set:
+ - condition: 'order.origin === "marketplace"'
+ transformers:
+ property_accessor:
+ property_path: '[customer].id'
+ - condition: 'order.origin === "e-commerce"'
+ constant: 1234
+ - default: true
+ set_null: true
+```
diff --git a/docs/reference/transformers/slugify_transformer.md b/docs/reference/transformers/slugify_transformer.md
new file mode 100644
index 00000000..3276f6de
--- /dev/null
+++ b/docs/reference/transformers/slugify_transformer.md
@@ -0,0 +1,43 @@
+SlugifyTransformer
+=========================
+
+Strip whitespace (or other characters) from the beginning and end of a string
+
+This transformer uses the php internal function: https://www.php.net/manual/en/class.transliterator.php
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Transformer\String\SlugifyTransformer`
+* **Transformer code**: `slugify`
+
+Accepted inputs
+---------------
+
+Any value that can be cast to string.
+
+Possible outputs
+----------------
+
+`string`
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|------------------|----------|:---------:|----------------------------------------|--------------------------------|
+| `transliterator` | `string` | | `NFD; [:Nonspacing Mark:] Remove; NFC` | Used to create \Transliterator |
+| `replace` | `string` | | `/[^a-z0-9]+/` | Used on preg_replace |
+| `separator` | `string` | | `_` | Used on preg_replace |
+
+Examples
+--------
+
+```yaml
+# Transformer mapping level
+slug:
+ code:
+ - '[firstname]'
+ transformers:
+ slugify: ~
+```
diff --git a/docs/reference/transformers/sprintf_transformer.md b/docs/reference/transformers/sprintf_transformer.md
new file mode 100644
index 00000000..e8f15f00
--- /dev/null
+++ b/docs/reference/transformers/sprintf_transformer.md
@@ -0,0 +1,48 @@
+SprintfTransformer
+=========================
+
+Return a formatted string.
+
+This transformer uses the php internal function: https://www.php.net/manual/en/function.vsprintf.php
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Transformer\String\SprintfTransformer`
+* **Transformer code**: `sprintf`
+
+Accepted inputs
+---------------
+
+Any value that can be cast to `string` | `int` | `float` or `array`
+
+Possible outputs
+----------------
+
+`string`
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+|----------|----------|:--------:|---------|----------------------------------------------------------------------------------------------------------------------|
+| `format` | `string` | **X** | `%s` | The format string is composed of zero or more directives. Escape % with another %% due to ParameterBag restrictions. |
+
+Examples
+--------
+
+```yaml
+# Transformer mapping level
+sprintf_one:
+ code: '[firstname]'
+ transformers:
+ sprintf:
+ format: 'one/%%d'
+sprintf_multiple:
+ code:
+ - '[firstname]'
+ - '[lastname]'
+ transformers:
+ sprintf:
+ format: 'multiple/%%s/%%s'
+```
diff --git a/docs/reference/transformers/trim_transformer.md b/docs/reference/transformers/trim_transformer.md
new file mode 100644
index 00000000..85a09053
--- /dev/null
+++ b/docs/reference/transformers/trim_transformer.md
@@ -0,0 +1,32 @@
+TrimTransformer
+=========================
+
+Strip whitespace (or other characters) from the beginning and end of a string
+
+This transformer uses the php internal function: https://www.php.net/manual/en/function.trim.php
+
+Task reference
+--------------
+
+* **Service**: `CleverAge\ProcessBundle\Transformer\String\TrimTransformer`
+* **Transformer code**: `trim`
+
+Accepted inputs
+---------------
+
+Any value that can be cast to string and null.
+
+Possible outputs
+----------------
+
+Depending on the input :
+- `null` if the input is null
+- `string` if the input is not null
+
+Options
+-------
+
+| Code | Type | Required | Default | Description |
+| ---- | ---- | :------: |-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `charlist` | `string` | | ***" \t\n\r\0\x0B"*** | List of characters to trim |
+
diff --git a/doc/reference/transformers/xpath_evaluator.md b/docs/reference/transformers/xpath_evaluator.md
similarity index 100%
rename from doc/reference/transformers/xpath_evaluator.md
rename to docs/reference/transformers/xpath_evaluator.md
diff --git a/ecs.php b/ecs.php
deleted file mode 100644
index 69fb8167..00000000
--- a/ecs.php
+++ /dev/null
@@ -1,24 +0,0 @@
-rule(LineLengthFixer::class);
-
- $ecsConfig->sets([
- SetList::CLEAN_CODE,
- SetList::SYMPLIFY,
- SetList::COMMON,
- SetList::PSR_12,
- SetList::DOCTRINE_ANNOTATIONS,
- ]);
-
- $ecsConfig->paths([__DIR__.'/src']);
-
- $ecsConfig->skip([AssignmentInConditionSniff::class]);
-};
diff --git a/phpstan.neon b/phpstan.neon
index a9f5c7bc..f0560a73 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -2,12 +2,8 @@ parameters:
level: 6
paths:
- src
+ - tests
excludePaths:
- - ecs.php
- - vendor/*
- - tests/*
- - rector.php
- - var/*
- src/Resources/tests/*
ignoreErrors:
- '#type has no value type specified in iterable type#'
@@ -18,7 +14,7 @@ parameters:
- '#process\(\) has no return type specified#'
- '#should return Iterator but returns Traversable#'
- '#Negated boolean expression is always false#'
- checkGenericClassInNonGenericObjectType: false
+ - identifier: missingType.generics
reportUnmatchedIgnoredErrors: false
inferPrivatePropertyTypeFromConstructor: true
- treatPhpDocTypesAsCertain: false
\ No newline at end of file
+ treatPhpDocTypesAsCertain: false
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 766495c5..c3e7947d 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,27 +1,22 @@
+ failOnWarning="true">
tests
-
-
+
src
-
-
+
+
\ No newline at end of file
diff --git a/rector.php b/rector.php
index 5a4479b2..a931fd42 100644
--- a/rector.php
+++ b/rector.php
@@ -2,20 +2,27 @@
declare(strict_types=1);
-/*
- * This file is part of the CleverAge/ProcessBundle package.
- *
- * Copyright (c) 2017-2024 Clever-Age
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
use Rector\Config\RectorConfig;
+use Rector\PHPUnit\Set\PHPUnitSetList;
+use Rector\Set\ValueObject\LevelSetList;
+use Rector\Symfony\Set\SymfonySetList;
+use Rector\ValueObject\PhpVersion;
return RectorConfig::configure()
- ->withPaths([__DIR__.'/src', __DIR__.'/tests'])
+ ->withPhpVersion(PhpVersion::PHP_85)
+ ->withPaths([
+ __DIR__.'/src',
+ __DIR__.'/tests',
+ ])
->withPhpSets(php82: true)
+ // here we can define, what prepared sets of rules will be applied
+ ->withPreparedSets(deadCode: true, codeQuality: true, symfonyCodeQuality: true)
->withAttributesSets(symfony: true)
- ->withImportNames(removeUnusedImports: true)
+ ->withSets([
+ LevelSetList::UP_TO_PHP_82,
+ SymfonySetList::SYMFONY_64,
+ SymfonySetList::SYMFONY_CODE_QUALITY,
+ SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
+ PHPUnitSetList::PHPUNIT_100,
+ ])
;
diff --git a/src/CleverAgeProcessBundle.php b/src/CleverAgeProcessBundle.php
index 27904639..cd704afa 100644
--- a/src/CleverAgeProcessBundle.php
+++ b/src/CleverAgeProcessBundle.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -15,8 +15,6 @@
use CleverAge\ProcessBundle\DependencyInjection\Compiler\CheckSerializerCompilerPass;
use CleverAge\ProcessBundle\DependencyInjection\Compiler\RegistryCompilerPass;
-use CleverAge\ProcessBundle\Registry\TransformerRegistry;
-use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
@@ -30,11 +28,15 @@ public function build(ContainerBuilder $container): void
parent::build($container);
$container->addCompilerPass(
- new RegistryCompilerPass(TransformerRegistry::class, 'cleverage.transformer', 'addTransformer'),
- PassConfig::TYPE_BEFORE_OPTIMIZATION,
- 0
+ new RegistryCompilerPass('cleverage_process.registry.transformer', 'cleverage.transformer', 'addTransformer')
);
- $container->addCompilerPass(new CheckSerializerCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
+ $container->addCompilerPass(new CheckSerializerCompilerPass());
+ }
+
+ #[\Override]
+ public function getPath(): string
+ {
+ return \dirname(__DIR__);
}
}
diff --git a/src/Command/ExecuteProcessCommand.php b/src/Command/ExecuteProcessCommand.php
index 73fec99a..088428f5 100644
--- a/src/Command/ExecuteProcessCommand.php
+++ b/src/Command/ExecuteProcessCommand.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -17,7 +17,6 @@
use CleverAge\ProcessBundle\Filesystem\JsonStreamFile;
use CleverAge\ProcessBundle\Manager\ProcessManager;
use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry;
-use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
@@ -25,6 +24,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\VarDumper\VarDumper;
use Symfony\Component\Yaml\Parser;
@@ -92,7 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (!$this->processRegistry->hasProcessConfiguration($code)) {
throw new InvalidConfigurationException("Unknown process {$code}");
}
-
+
if (!$output->isQuiet()) {
$output->writeln("Starting process '{$code}'...");
}
@@ -123,7 +123,7 @@ protected function parseContextValues(InputInterface $input): array
preg_match($pattern, (string) $contextValue, $parts);
if (3 !== \count($parts)
|| $parts[0] !== $contextValue) {
- throw new \InvalidArgumentException(sprintf('Invalid context %s', $contextValue));
+ throw new \InvalidArgumentException(\sprintf('Invalid context %s', $contextValue));
}
$context[$parts[1]] = $parser->parse($parts[2]);
}
@@ -148,7 +148,7 @@ protected function handleOutputData(mixed $data, InputInterface $input, OutputIn
} elseif (self::OUTPUT_FORMAT_JSON === $input->getOption('output-format')) {
$output->writeln(json_encode($data, \JSON_THROW_ON_ERROR));
} else {
- throw new \InvalidArgumentException(sprintf("Cannot handle data output with format '%s'", $input->getOption('output-format')));
+ throw new \InvalidArgumentException(\sprintf("Cannot handle data output with format '%s'", $input->getOption('output-format')));
}
}
} elseif (self::OUTPUT_FORMAT_JSON === $input->getOption('output-format')) {
@@ -160,10 +160,10 @@ protected function handleOutputData(mixed $data, InputInterface $input, OutputIn
}
if (isset($outputFile) && $output->isVerbose()) {
- $output->writeln(sprintf("Output stored in '%s'", $input->getOption('output')));
+ $output->writeln(\sprintf("Output stored in '%s'", $input->getOption('output')));
}
} else {
- throw new \InvalidArgumentException(sprintf("Cannot handle data output with format '%s'", $input->getOption('output-format')));
+ throw new \InvalidArgumentException(\sprintf("Cannot handle data output with format '%s'", $input->getOption('output-format')));
}
}
}
diff --git a/src/Command/ListProcessCommand.php b/src/Command/ListProcessCommand.php
index fcca76c1..01fdf997 100644
--- a/src/Command/ListProcessCommand.php
+++ b/src/Command/ListProcessCommand.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -28,7 +28,7 @@
class ListProcessCommand extends Command
{
public function __construct(
- protected ProcessConfigurationRegistry $processConfigRegistry
+ protected ProcessConfigurationRegistry $processConfigRegistry,
) {
parent::__construct();
}
diff --git a/src/Command/ProcessHelpCommand.php b/src/Command/ProcessHelpCommand.php
index 8fe4a510..ea22e351 100644
--- a/src/Command/ProcessHelpCommand.php
+++ b/src/Command/ProcessHelpCommand.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -61,7 +61,7 @@ class ProcessHelpCommand extends Command
public function __construct(
protected ProcessConfigurationRegistry $processConfigRegistry,
- protected ContainerInterface $container
+ protected ContainerInterface $container,
) {
parent::__construct();
}
@@ -83,13 +83,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln(str_repeat(' ', self::INDENT_SIZE).$processCode);
$output->writeln('');
- if ($process->getDescription()) {
+ if ('' !== $process->getDescription() && '0' !== $process->getDescription()) {
$output->writeln('Description:');
$output->writeln(str_repeat(' ', self::INDENT_SIZE).$process->getDescription());
$output->writeln('');
}
- if ($process->getHelp()) {
+ if ('' !== $process->getHelp() && '0' !== $process->getHelp()) {
$output->writeln('Help:');
$helpLines = array_filter(explode("\n", $process->getHelp()));
foreach ($helpLines as $helpLine) {
@@ -116,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$branches = array_filter($branches);
- if (!empty($branches)) {
+ if ([] !== $branches) {
$branchStr = '['.implode(', ', $branches).']';
$output->writeln("All branches are not resolved : {$branchStr}");
}
@@ -130,13 +130,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
protected function findBestNextTask(
array $branches,
array $taskList,
- ProcessConfiguration $process
- ): int|null|string {
+ ProcessConfiguration $process,
+ ): int|string|null {
// Get resolvable tasks
$taskCandidates = [];
foreach ($taskList as $taskCode) {
$task = $process->getTaskConfiguration($taskCode);
- if (empty($task->getPreviousTasksConfigurations())) {
+ if ([] === $task->getPreviousTasksConfigurations()) {
return $taskCode;
}
@@ -156,7 +156,7 @@ protected function findBestNextTask(
}
}
- if (empty($taskCandidates)) {
+ if ([] === $taskCandidates) {
throw new \UnexpectedValueException('Cannot find a task to output');
}
@@ -175,7 +175,7 @@ protected function findBestNextTask(
$weight += $key;
}
- if (!empty($task->getPreviousTasksConfigurations())) {
+ if ([] !== $task->getPreviousTasksConfigurations()) {
$weight /= \count($task->getPreviousTasksConfigurations());
}
@@ -194,7 +194,7 @@ protected function findBestNextTask(
// If a few tasks have the same weight, return the tasks with the lowest number of children
$childCounts = [];
- foreach ($equalWeights as $taskCode => $weight) {
+ foreach (array_keys($equalWeights) as $taskCode) {
$task = $process->getTaskConfiguration($taskCode);
$childCounts[$taskCode] = $this->getTaskChildrenCount($task);
}
@@ -228,7 +228,7 @@ protected function resolveBranchOutput(
array &$branches,
string $taskCode,
ProcessConfiguration $process,
- OutputInterface $output
+ OutputInterface $output,
): void {
$task = $process->getTaskConfiguration($taskCode);
$branchesToMerge = [];
@@ -243,7 +243,7 @@ protected function resolveBranchOutput(
}
// Check previous branches
- if (empty($previousTasks)) {
+ if ([] === $previousTasks) {
$branches[] = $task->getCode();
} elseif (1 === \count($previousTasks)) {
$prevTask = current($previousTasks)
@@ -292,7 +292,7 @@ protected function resolveBranchOutput(
}
// Merge branches
- if (!empty($branchesToMerge)) {
+ if ([] !== $branchesToMerge) {
$this->writeBranches($output, $branches);
$this->writeBranches(
@@ -322,7 +322,7 @@ static function ($taskCode, $i) use ($gapBranches, $origin, $final, $branches):
}
);
- foreach ($branches as $i => $branchTask) {
+ foreach (array_keys($branches) as $i) {
if (\in_array($i, $branchesToMerge, true)) {
$branches[$i] = null;
}
@@ -423,7 +423,7 @@ static function ($branchTask, $i) use ($origin, $branches, $gapBranches, $final)
);
}
- if (empty($nextTasks)) {
+ if ([] === $nextTasks) {
foreach ($branches as $i => $branchTask) {
if ($branchTask === $taskCode) {
$branches[$i] = null;
@@ -446,8 +446,8 @@ protected function writeBranches(
OutputInterface $output,
array $branches,
string|iterable $comment = '',
- callable $match = null,
- string|callable $char = null
+ ?callable $match = null,
+ string|callable|null $char = null,
): void {
$output->write(str_repeat(' ', self::INDENT_SIZE));
@@ -467,7 +467,7 @@ protected function writeBranches(
}
// Str_pad does not work with unicode ?
- $noFormatStrLen = mb_strlen(preg_replace('/<[^>]*>/', '', (string) $str));
+ $noFormatStrLen = mb_strlen((string) preg_replace('/<[^>]*>/', '', (string) $str));
for ($j = $noFormatStrLen; $j < self::BRANCH_SIZE; ++$j) {
$str .= ' ';
}
@@ -499,15 +499,15 @@ protected function getTaskDescription(TaskConfiguration $task): string
$subprocess[] = $task->getOption('process');
}
- if (\count($interfaces)) {
+ if ([] !== $interfaces) {
$description .= ' ('.implode(', ', $interfaces).')';
}
- if (\count($subprocess)) {
+ if ([] !== $subprocess) {
$description .= ' {'.implode(', ', $subprocess).'}';
}
- if ($task->getDescription()) {
+ if ('' !== $task->getDescription() && '0' !== $task->getDescription()) {
$description .= " {$task->getDescription()}";
}
diff --git a/src/Configuration/ProcessConfiguration.php b/src/Configuration/ProcessConfiguration.php
index 8aa0c979..48d9caa8 100644
--- a/src/Configuration/ProcessConfiguration.php
+++ b/src/Configuration/ProcessConfiguration.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -33,7 +33,7 @@ public function __construct(
protected ?string $endPoint = null,
protected string $description = '',
protected string $help = '',
- protected bool $public = true
+ protected bool $public = true,
) {
}
@@ -112,14 +112,7 @@ public function getDependencyGroups(): array
if (null === $this->dependencyGroups) {
$this->dependencyGroups = [];
foreach ($this->getTaskConfigurations() as $taskConfiguration) {
- $isInBranch = false;
- foreach ($this->dependencyGroups as $branch) {
- if (\in_array($taskConfiguration->getCode(), $branch, true)) {
- $isInBranch = true;
- break;
- }
- }
-
+ $isInBranch = array_any($this->dependencyGroups, static fn ($branch) => \in_array($taskConfiguration->getCode(), $branch, true));
if (!$isInBranch) {
$dependencies = $this->buildDependencies($taskConfiguration);
$dependencies = $this->sortDependencies($dependencies);
@@ -164,12 +157,12 @@ public function getMainTask(): ?TaskConfiguration
$entryTask = $this->getEntryPoint();
// If there's no entry point, we might use the end point
- if (!$entryTask) {
+ if (!$entryTask instanceof TaskConfiguration) {
$entryTask = $this->getEndPoint();
}
// By default use the first defined task
- if (!$entryTask) {
+ if (!$entryTask instanceof TaskConfiguration) {
$entryTask = reset($this->taskConfigurations);
}
@@ -243,9 +236,8 @@ protected function sortDependencies(array $dependencies): array
return $dependencies;
}
- /** @var int $midOffset */
$midOffset = round(\count($dependencies) / 2);
- $midTaskCode = $dependencies[$midOffset];
+ $midTaskCode = $dependencies[(int) $midOffset];
$midTask = $this->getTaskConfiguration($midTaskCode);
$previousTasks = [];
diff --git a/src/Configuration/TaskConfiguration.php b/src/Configuration/TaskConfiguration.php
index 6a59d872..1645939e 100644
--- a/src/Configuration/TaskConfiguration.php
+++ b/src/Configuration/TaskConfiguration.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -58,7 +58,7 @@ public function __construct(
protected array $outputs = [],
protected array $errorOutputs = [],
protected string $errorStrategy = self::STRATEGY_SKIP,
- protected string $logLevel = LogLevel::CRITICAL
+ protected string $logLevel = LogLevel::CRITICAL,
) {
$this->logErrors = LogLevel::DEBUG !== $logLevel; // @deprecated, remove me in next version
}
@@ -112,9 +112,7 @@ public function getOutputs(): array
return $this->outputs;
}
- /**
- * @deprecated Use getErrorOutputs method instead
- */
+ #[\Deprecated(message: 'Use getErrorOutputs method instead')]
public function getErrors(): array
{
@trigger_error('Deprecated method, use getErrorOutputs instead', \E_USER_DEPRECATED);
@@ -188,7 +186,7 @@ public function setInErrorBranch(bool $inErrorBranch): void
public function isRoot(): bool
{
- return empty($this->getPreviousTasksConfigurations()) && !$this->isInErrorBranch();
+ return [] === $this->getPreviousTasksConfigurations() && !$this->isInErrorBranch();
}
/**
diff --git a/src/Context/ContextualOptionResolver.php b/src/Context/ContextualOptionResolver.php
index a5bad58f..067e3509 100644
--- a/src/Context/ContextualOptionResolver.php
+++ b/src/Context/ContextualOptionResolver.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -27,7 +27,7 @@ public function contextualizeOption(mixed $value, array $context): mixed
}
if (\is_string($value)) {
- $pattern = sprintf('/{{[ ]*(%s){1}[ ]*}}/', implode('|', array_keys($context)));
+ $pattern = \sprintf('/{{[ ]*(%s){1}[ ]*}}/', implode('|', array_keys($context)));
$matches = [];
$result = preg_match($pattern, $value, $matches);
diff --git a/src/DependencyInjection/CleverAgeProcessExtension.php b/src/DependencyInjection/CleverAgeProcessExtension.php
index ebe8ef15..cf7830bf 100644
--- a/src/DependencyInjection/CleverAgeProcessExtension.php
+++ b/src/DependencyInjection/CleverAgeProcessExtension.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -13,33 +13,31 @@
namespace CleverAge\ProcessBundle\DependencyInjection;
-use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry;
use CleverAge\ProcessBundle\Transformer\GenericTransformer;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Finder\Finder;
/**
* This is the class that loads and manages your bundle configuration.
*
- * @see http://symfony.com/doc/current/cookbook/bundles/extension.html
+ * @see https://symfony.com/doc/current/bundles/extension.html
*/
class CleverAgeProcessExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container): void
{
// Get the path of the service folder wherever the bundle is installed
- $reflection = new \ReflectionClass($this);
- $serviceFolderPath = \dirname($reflection->getFileName(), 2).'/Resources/config/services';
- $this->findServices($container, $serviceFolderPath);
+ $this->findServices($container, __DIR__.'/../../config/services');
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
- $processConfigurationRegistry = $container->getDefinition(ProcessConfigurationRegistry::class);
+ $processConfigurationRegistry = $container->getDefinition('cleverage_process.registry.process_configuration');
$processConfigurationRegistry->replaceArgument(0, $config['configurations']);
$processConfigurationRegistry->replaceArgument(1, $config['default_error_strategy']);
@@ -48,6 +46,10 @@ public function load(array $configs, ContainerBuilder $container): void
$transformerDefinition = new Definition(GenericTransformer::class);
$transformerDefinition->setAutowired(true);
$transformerDefinition->setPublic(false);
+ $transformerDefinition->setArguments([
+ new Reference('cleverage_process.context.contextual_option_resolver'),
+ new Reference('cleverage_process.registry.transformer'),
+ ]);
$transformerDefinition->addMethodCall('initialize', [$transformerCode, $transformerConfig]);
$transformerDefinition->addTag('cleverage.transformer');
diff --git a/src/DependencyInjection/Compiler/CheckSerializerCompilerPass.php b/src/DependencyInjection/Compiler/CheckSerializerCompilerPass.php
index 0cd8e0f4..93006b1e 100644
--- a/src/DependencyInjection/Compiler/CheckSerializerCompilerPass.php
+++ b/src/DependencyInjection/Compiler/CheckSerializerCompilerPass.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/DependencyInjection/Compiler/RegistryCompilerPass.php b/src/DependencyInjection/Compiler/RegistryCompilerPass.php
index 517bb2d5..9de12c25 100644
--- a/src/DependencyInjection/Compiler/RegistryCompilerPass.php
+++ b/src/DependencyInjection/Compiler/RegistryCompilerPass.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -25,7 +25,7 @@ class RegistryCompilerPass implements CompilerPassInterface
public function __construct(
protected ?string $registry = null,
protected ?string $tag = null,
- protected ?string $method = null
+ protected ?string $method = null,
) {
}
@@ -41,7 +41,7 @@ public function process(ContainerBuilder $container): void
$definition = $container->findDefinition($this->registry);
$taggedServices = $container->findTaggedServiceIds($this->tag);
- foreach ($taggedServices as $id => $tags) {
+ foreach (array_keys($taggedServices) as $id) {
$definition->addMethodCall($this->method, [new Reference($id)]);
}
}
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index be337f93..bdb9b8ef 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -28,7 +28,7 @@
class Configuration implements ConfigurationInterface
{
public function __construct(
- protected string $root = 'clever_age_process'
+ protected string $root = 'clever_age_process',
) {
}
@@ -40,7 +40,7 @@ public function getConfigTreeBuilder(): TreeBuilder
// Default error strategy
$definition->enumNode('default_error_strategy')
->values([TaskConfiguration::STRATEGY_SKIP, TaskConfiguration::STRATEGY_STOP])
- ->isRequired();
+ ->defaultValue(TaskConfiguration::STRATEGY_STOP);
$this->appendRootProcessConfigDefinition($definition);
$this->appendRootTransformersConfigDefinition($definition);
@@ -77,11 +77,11 @@ protected function appendTransformerConfigDefinition(NodeBuilder $definition): v
->arrayNode('contextual_options')
->prototype('variable')
->end()
- ?->end()
+ ->end()
->arrayNode('transformers')
->prototype('variable')
->end()
- ?->end();
+ ->end();
}
/**
@@ -110,22 +110,22 @@ protected function appendProcessConfigDefinition(NodeBuilder $definition): void
->scalarNode('entry_point')
->defaultNull()
->end()
- ?->scalarNode('end_point')
+ ->scalarNode('end_point')
->defaultNull()
->end()
- ?->scalarNode('description')
+ ->scalarNode('description')
->defaultValue('')
->end()
- ?->scalarNode('help')
+ ->scalarNode('help')
->defaultValue('')
->end()
- ?->scalarNode('public')
+ ->scalarNode('public')
->defaultTrue()
->end()
- ?->arrayNode('options')
+ ->arrayNode('options')
->prototype('variable')
->end()
- ?->end();
+ ->end();
/** @var ArrayNodeDefinition $tasksArrayDefinition */
$tasksArrayDefinition = $definition
@@ -175,7 +175,7 @@ protected function appendTaskConfigDefinition(NodeBuilder $definition): void
$definition->arrayNode($nodeName)
->beforeNormalization()
->ifString()
- ->then(fn ($item): array => [$item])->end()
+ ->then(static fn ($item): array => [$item])->end()
->prototype('scalar');
}
}
diff --git a/src/Event/ConsoleProcessEvent.php b/src/Event/ConsoleProcessEvent.php
index f09c4303..e404e071 100644
--- a/src/Event/ConsoleProcessEvent.php
+++ b/src/Event/ConsoleProcessEvent.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -26,7 +26,7 @@ public function __construct(
private readonly InputInterface $consoleInput,
private readonly OutputInterface $consoleOutput,
private readonly mixed $processInput,
- private readonly array $processContext
+ private readonly array $processContext,
) {
}
diff --git a/src/Event/EventDispatcherTaskEvent.php b/src/Event/EventDispatcherTaskEvent.php
index 0d6b4394..e148e973 100644
--- a/src/Event/EventDispatcherTaskEvent.php
+++ b/src/Event/EventDispatcherTaskEvent.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -19,7 +19,7 @@
class EventDispatcherTaskEvent extends Event
{
public function __construct(
- protected ProcessState $state
+ protected ProcessState $state,
) {
}
diff --git a/src/Event/ProcessEvent.php b/src/Event/ProcessEvent.php
index f3b79d11..6c7b297f 100644
--- a/src/Event/ProcessEvent.php
+++ b/src/Event/ProcessEvent.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -31,7 +31,7 @@ public function __construct(
protected mixed $processInput = null,
protected array $processContext = [],
protected mixed $processOutput = null,
- protected ?\Throwable $processError = null
+ protected ?\Throwable $processError = null,
) {
}
diff --git a/src/EventListener/DataQueueEventListener.php b/src/EventListener/DataQueueEventListener.php
index 6f48ab5c..b405d886 100644
--- a/src/EventListener/DataQueueEventListener.php
+++ b/src/EventListener/DataQueueEventListener.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Exception/CircularProcessException.php b/src/Exception/CircularProcessException.php
index c4ff2516..81939d49 100644
--- a/src/Exception/CircularProcessException.php
+++ b/src/Exception/CircularProcessException.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Exception/InvalidProcessConfigurationException.php b/src/Exception/InvalidProcessConfigurationException.php
index 80a34779..aecaab1f 100644
--- a/src/Exception/InvalidProcessConfigurationException.php
+++ b/src/Exception/InvalidProcessConfigurationException.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -24,7 +24,7 @@ class InvalidProcessConfigurationException extends \UnexpectedValueException imp
public static function createNotInMain(
ProcessConfiguration $processConfiguration,
TaskConfiguration $taskConfig,
- array $mainTaskList
+ array $mainTaskList,
): self {
$taskListStr = '['.implode(', ', $mainTaskList).']';
@@ -35,7 +35,7 @@ public static function createNotInMain(
public static function createEntryPointHasAncestors(
ProcessConfiguration $processConfiguration,
- TaskConfiguration $taskConfig
+ TaskConfiguration $taskConfig,
): self {
return new self(
"The entry-point '{$taskConfig->getCode()}' cannot have an ancestor (from process: {$processConfiguration->getCode()})"
diff --git a/src/Exception/MissingProcessException.php b/src/Exception/MissingProcessException.php
index 3642ee67..045372f9 100644
--- a/src/Exception/MissingProcessException.php
+++ b/src/Exception/MissingProcessException.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Exception/MissingTaskConfigurationException.php b/src/Exception/MissingTaskConfigurationException.php
index 0445891c..ab1b3c77 100644
--- a/src/Exception/MissingTaskConfigurationException.php
+++ b/src/Exception/MissingTaskConfigurationException.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Exception/MissingTransformerException.php b/src/Exception/MissingTransformerException.php
index a0ea2772..565ef481 100644
--- a/src/Exception/MissingTransformerException.php
+++ b/src/Exception/MissingTransformerException.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Exception/ProcessExceptionInterface.php b/src/Exception/ProcessExceptionInterface.php
index f4f39edf..a0b539f8 100644
--- a/src/Exception/ProcessExceptionInterface.php
+++ b/src/Exception/ProcessExceptionInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Exception/TransformerException.php b/src/Exception/TransformerException.php
index 0c88e44a..5ce332df 100644
--- a/src/Exception/TransformerException.php
+++ b/src/Exception/TransformerException.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -23,7 +23,7 @@ class TransformerException extends \RuntimeException implements ProcessException
public function __construct(
protected string $transformerCode,
int $code = 0,
- \Throwable $previous = null
+ ?\Throwable $previous = null,
) {
parent::__construct('', $code, $previous);
$this->updateMessage();
@@ -38,15 +38,15 @@ public function setTargetProperty(string $targetProperty): void
protected function updateMessage(): void
{
if (isset($this->targetProperty)) {
- $m = sprintf(
+ $m = \sprintf(
"For target property '%s', transformation '%s' have failed",
$this->targetProperty,
$this->transformerCode
);
} else {
- $m = sprintf("Transformation '%s' have failed", $this->transformerCode);
+ $m = \sprintf("Transformation '%s' have failed", $this->transformerCode);
}
- if ($this->getPrevious()) {
+ if ($this->getPrevious() instanceof \Throwable) {
$m .= ": {$this->getPrevious()
->getMessage()}";
}
diff --git a/src/ExpressionLanguage/PhpFunctionProvider.php b/src/ExpressionLanguage/PhpFunctionProvider.php
index 4d157b01..9a2632b7 100644
--- a/src/ExpressionLanguage/PhpFunctionProvider.php
+++ b/src/ExpressionLanguage/PhpFunctionProvider.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -22,7 +22,7 @@
class PhpFunctionProvider implements ExpressionFunctionProviderInterface
{
public function __construct(
- protected array $functions
+ protected array $functions,
) {
}
diff --git a/src/Filesystem/CsvFile.php b/src/Filesystem/CsvFile.php
index 529096ae..d8944e87 100644
--- a/src/Filesystem/CsvFile.php
+++ b/src/Filesystem/CsvFile.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -29,13 +29,13 @@ public function __construct(
string $delimiter = ',',
string $enclosure = '"',
string $escape = '\\',
- array $headers = null,
- string $mode = 'rb'
+ ?array $headers = null,
+ string $mode = 'rb',
) {
if (!\in_array($filePath, ['php://stdin', 'php://stdout', 'php://stderr'], true)) {
$dirname = \dirname($this->filePath);
- if (!@mkdir($dirname, 0755, true) && !is_dir($dirname)) {
- throw new \RuntimeException(sprintf('Directory "%s" was not created', $dirname));
+ if (!@mkdir($dirname, 0o755, true) && !is_dir($dirname)) {
+ throw new \RuntimeException(\sprintf('Directory "%s" was not created', $dirname));
}
}
@@ -56,11 +56,13 @@ public function __construct(
/**
* Will return a resource if the file was created using a resource.
*/
+ #[\Override]
public function getFilePath(): string
{
return $this->filePath;
}
+ #[\Override]
protected function getResourceName(): string
{
return "CSV file '{$this->filePath}'";
diff --git a/src/Filesystem/CsvResource.php b/src/Filesystem/CsvResource.php
index bab85e4e..3c536dca 100644
--- a/src/Filesystem/CsvResource.php
+++ b/src/Filesystem/CsvResource.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -13,8 +13,6 @@
namespace CleverAge\ProcessBundle\Filesystem;
-use function count;
-
/**
* Read and write CSV resources through a simple API.
*/
@@ -40,11 +38,11 @@ class CsvResource implements WritableStructuredFileInterface, SeekableFileInterf
protected bool $seekCalled = false;
public function __construct(
- $resource,
+ mixed $resource,
protected string $delimiter = ',',
protected string $enclosure = '"',
protected string $escape = '\\',
- array $headers = null
+ ?array $headers = null,
) {
if (!\is_resource($resource)) {
$type = \gettype($resource);
@@ -149,7 +147,7 @@ public function isEndOfFile(): bool
/**
* Warning, this function will return exactly the same value as the fgetcsv() function.
*/
- public function readRaw(int $length = null): array|false
+ public function readRaw(?int $length = null): array|false
{
$this->assertOpened();
++$this->lineNumber;
@@ -157,13 +155,9 @@ public function readRaw(int $length = null): array|false
return fgetcsv($this->handler, $length, $this->delimiter, $this->enclosure, $this->escape);
}
- public function readLine(int $length = null): ?array
+ public function readLine(?int $length = null): ?array
{
- if ($this->seekCalled) {
- $filePosition = "at position {$this->tell()}";
- } else {
- $filePosition = "on line {$this->getLineNumber()}";
- }
+ $filePosition = $this->seekCalled ? "at position {$this->tell()}" : "on line {$this->getLineNumber()}";
$values = $this->readRaw($length);
if (false === $values) {
@@ -290,12 +284,12 @@ protected function assertOpened(): void
}
}
- protected function parseHeaders(array $headers = null): array
+ protected function parseHeaders(?array $headers = null): array
{
// If headers are not passed in the constructor but file is readable, try to read headers from file
if (null === $headers) {
$autoHeaders = $this->readRaw();
- if (false === $autoHeaders || 0 === \count($autoHeaders)) {
+ if (false === $autoHeaders || [] === $autoHeaders) {
throw new \UnexpectedValueException("Unable to read headers for {$this->getResourceName()}");
}
// Remove BOM if any
@@ -307,11 +301,7 @@ protected function parseHeaders(array $headers = null): array
$this->manualHeaders = true;
- if (!\is_array($headers)) {
- throw new \UnexpectedValueException("Invalid headers for {$this->getResourceName()}, you need to pass the headers manually");
- }
-
- if (0 === \count($headers)) {
+ if ([] === $headers) {
throw new \UnexpectedValueException("Empty headers for {$this->getResourceName()}, you need to pass the headers manually");
}
diff --git a/src/Filesystem/FileStreamInterface.php b/src/Filesystem/FileStreamInterface.php
index 542799cd..65b5b819 100644
--- a/src/Filesystem/FileStreamInterface.php
+++ b/src/Filesystem/FileStreamInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -27,7 +27,7 @@ public function getLineNumber(): int;
public function isEndOfFile(): bool;
- public function readLine(int $length = null): ?array;
+ public function readLine(?int $length = null): ?array;
/**
* This methods rewinds the file to the first line of data, skipping the headers.
diff --git a/src/Filesystem/JsonStreamFile.php b/src/Filesystem/JsonStreamFile.php
index 5fa7d4f0..fc76dc62 100644
--- a/src/Filesystem/JsonStreamFile.php
+++ b/src/Filesystem/JsonStreamFile.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -20,16 +20,30 @@ class JsonStreamFile implements FileStreamInterface, WritableFileInterface
{
protected \SplFileObject $file;
+ private readonly int $jsonFlags;
+
protected ?int $lineCount = null;
protected int $lineNumber = 1;
- public function __construct(string $filename, string $mode = 'rb')
- {
+ public function __construct(
+ string $filename,
+ string $mode = 'rb',
+ ?array $splFileObjectFlags = null,
+ ?array $jsonFlags = null,
+ ) {
$this->file = new \SplFileObject($filename, $mode);
- // Useful to skip empty trailing lines
- $this->file->setFlags(\SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY);
+ // Useful to skip empty trailing lines (doesn't work well on PHP 8, see readLine() code)
+ $this->file->setFlags(null !== $splFileObjectFlags
+ ? array_sum($splFileObjectFlags)
+ : \SplFileObject::DROP_NEW_LINE | \SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY
+ );
+
+ $this->jsonFlags = null !== $jsonFlags
+ ? array_sum($jsonFlags)
+ : \JSON_THROW_ON_ERROR
+ ;
}
/**
@@ -65,21 +79,25 @@ public function isEndOfFile(): bool
/**
* Return an array containing current data and moving the file pointer.
*/
- public function readLine(int $length = null): ?array
+ public function readLine(?int $length = null): ?array
{
if ($this->isEndOfFile()) {
return null;
}
$rawLine = $this->file->fgets();
+ // Fix issue on PHP 8 with empty line at the end, even if SKIP_EMPTY is set
+ if ('' === $rawLine) {
+ return null;
+ }
++$this->lineNumber;
- return json_decode($rawLine, true, 512, \JSON_THROW_ON_ERROR);
+ return json_decode($rawLine, true, 512, $this->jsonFlags);
}
public function writeLine(array $fields): int
{
- $this->file->fwrite(json_encode($fields, \JSON_THROW_ON_ERROR).\PHP_EOL);
+ $this->file->fwrite(json_encode($fields, $this->jsonFlags).\PHP_EOL);
++$this->lineNumber;
return $this->lineNumber;
diff --git a/src/Filesystem/SeekableFileInterface.php b/src/Filesystem/SeekableFileInterface.php
index 2d7ca906..f647ce7f 100644
--- a/src/Filesystem/SeekableFileInterface.php
+++ b/src/Filesystem/SeekableFileInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Filesystem/SplFile.php b/src/Filesystem/SplFile.php
new file mode 100644
index 00000000..14f38c40
--- /dev/null
+++ b/src/Filesystem/SplFile.php
@@ -0,0 +1,106 @@
+file = new \SplFileObject($filename, $mode);
+
+ // Useful to skip empty trailing lines (doesn't work well on PHP 8, see readLine() code)
+ $this->file->setFlags(null !== $splFileObjectFlags
+ ? array_sum($splFileObjectFlags)
+ : \SplFileObject::DROP_NEW_LINE | \SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY
+ );
+ }
+
+ /**
+ * Warning! This method will rewind the file to the beginning before and after counting the lines!
+ */
+ public function getLineCount(): int
+ {
+ if (null === $this->lineCount) {
+ $this->rewind();
+ $line = 0;
+ while (!$this->isEndOfFile()) {
+ ++$line;
+ $this->file->next();
+ }
+ $this->rewind();
+
+ $this->lineCount = $line;
+ }
+
+ return $this->lineCount;
+ }
+
+ public function getLineNumber(): int
+ {
+ return $this->lineNumber;
+ }
+
+ public function isEndOfFile(): bool
+ {
+ return $this->file->eof();
+ }
+
+ /**
+ * Return an array containing current data and moving the file pointer.
+ */
+ public function readLine(?int $length = null): ?string
+ {
+ if ($this->isEndOfFile()) {
+ return null;
+ }
+
+ $rawLine = $this->file->fgets();
+ // Fix issue on PHP 8 with empty line at the end, even if SKIP_EMPTY is set
+ if ('' === $rawLine) {
+ return null;
+ }
+ ++$this->lineNumber;
+
+ return $rawLine;
+ }
+
+ public function writeLine(string $data): int
+ {
+ $this->file->fwrite($data.\PHP_EOL);
+ ++$this->lineNumber;
+
+ return $this->lineNumber;
+ }
+
+ /**
+ * Rewind data to array.
+ */
+ public function rewind(): void
+ {
+ $this->file->rewind();
+ $this->lineNumber = 1;
+ }
+}
diff --git a/src/Filesystem/StructuredFileInterface.php b/src/Filesystem/StructuredFileInterface.php
index 70ce3026..15e7db2e 100644
--- a/src/Filesystem/StructuredFileInterface.php
+++ b/src/Filesystem/StructuredFileInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Filesystem/WritableFileInterface.php b/src/Filesystem/WritableFileInterface.php
index 2509c329..a4a61376 100644
--- a/src/Filesystem/WritableFileInterface.php
+++ b/src/Filesystem/WritableFileInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Filesystem/WritableStructuredFileInterface.php b/src/Filesystem/WritableStructuredFileInterface.php
index e6e283eb..62ce9c82 100644
--- a/src/Filesystem/WritableStructuredFileInterface.php
+++ b/src/Filesystem/WritableStructuredFileInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Filesystem/XmlFile.php b/src/Filesystem/XmlFile.php
index 194a6248..99f20607 100644
--- a/src/Filesystem/XmlFile.php
+++ b/src/Filesystem/XmlFile.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Logger/AbstractLogger.php b/src/Logger/AbstractLogger.php
index 804d11cd..0a0ca91f 100644
--- a/src/Logger/AbstractLogger.php
+++ b/src/Logger/AbstractLogger.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -24,11 +24,11 @@
abstract class AbstractLogger extends BaseAbstractLogger
{
public function __construct(
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
}
- public function log($level, $message, array $context = []): void
+ public function log($level, string|\Stringable $message, array $context = []): void
{
$this->logger->log($level, $message, $context);
}
diff --git a/src/Logger/AbstractProcessor.php b/src/Logger/AbstractProcessor.php
index 544c7508..715167ab 100644
--- a/src/Logger/AbstractProcessor.php
+++ b/src/Logger/AbstractProcessor.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -13,19 +13,21 @@
namespace CleverAge\ProcessBundle\Logger;
+use CleverAge\ProcessBundle\Configuration\TaskConfiguration;
use CleverAge\ProcessBundle\Manager\ProcessManager;
+use CleverAge\ProcessBundle\Model\ProcessHistory;
use Monolog\LogRecord;
class AbstractProcessor
{
public function __construct(
- protected ProcessManager $processManager
+ protected ProcessManager $processManager,
) {
}
public function __invoke(LogRecord $record): LogRecord
{
- if (!empty($record->context)) {
+ if ([] !== $record->context) {
$context = $this->normalizeRecordData($record->context);
$record = new LogRecord(
$record->datetime,
@@ -58,7 +60,7 @@ protected function normalizeRecordData(array $record): array
protected function addProcessInfoToRecord(array &$record): void
{
$processHistory = $this->processManager->getProcessHistory();
- if (!$processHistory) {
+ if (!$processHistory instanceof ProcessHistory) {
return;
}
@@ -70,7 +72,7 @@ protected function addProcessInfoToRecord(array &$record): void
protected function addTaskInfoToRecord(array &$record): void
{
$taskConfiguration = $this->processManager->getTaskConfiguration();
- if (!$taskConfiguration) {
+ if (!$taskConfiguration instanceof TaskConfiguration) {
return;
}
$this->addToRecord($record, 'task_code', $taskConfiguration->getCode());
@@ -82,7 +84,7 @@ protected function addTaskInfoToRecord(array &$record): void
$this->addToRecord($record, 'error', $state->getErrorOutput());
}
- if ($state->getException()) {
+ if ($state->getException() instanceof \Throwable) {
$this->addToRecord($record, 'exception', $state->getException());
}
}
diff --git a/src/Logger/ProcessLogger.php b/src/Logger/ProcessLogger.php
index 7565d9ef..5b17b68c 100644
--- a/src/Logger/ProcessLogger.php
+++ b/src/Logger/ProcessLogger.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Logger/ProcessProcessor.php b/src/Logger/ProcessProcessor.php
index 35d1f3a4..819ddf1b 100644
--- a/src/Logger/ProcessProcessor.php
+++ b/src/Logger/ProcessProcessor.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Logger/TaskLogger.php b/src/Logger/TaskLogger.php
index cb00efd3..8bee634e 100644
--- a/src/Logger/TaskLogger.php
+++ b/src/Logger/TaskLogger.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Logger/TaskProcessor.php b/src/Logger/TaskProcessor.php
index 7a262eb1..374c5e46 100644
--- a/src/Logger/TaskProcessor.php
+++ b/src/Logger/TaskProcessor.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -17,6 +17,7 @@
class TaskProcessor extends AbstractProcessor
{
+ #[\Override]
public function __invoke(LogRecord $record): LogRecord
{
$record = parent::__invoke($record);
diff --git a/src/Logger/TransformerProcessor.php b/src/Logger/TransformerProcessor.php
index cc8cb65e..b296b016 100644
--- a/src/Logger/TransformerProcessor.php
+++ b/src/Logger/TransformerProcessor.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -17,6 +17,7 @@
class TransformerProcessor extends AbstractProcessor
{
+ #[\Override]
public function __invoke(LogRecord $record): LogRecord
{
$record = parent::__invoke($record);
diff --git a/src/Manager/ProcessManager.php b/src/Manager/ProcessManager.php
index d0b2751c..e561366f 100644
--- a/src/Manager/ProcessManager.php
+++ b/src/Manager/ProcessManager.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -29,9 +29,9 @@
use CleverAge\ProcessBundle\Model\ProcessState;
use CleverAge\ProcessBundle\Model\TaskInterface;
use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry;
-use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\ErrorHandler\Error\FatalError;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Execute processes.
@@ -64,7 +64,7 @@ public function __construct(
protected TaskLogger $taskLogger,
protected ProcessConfigurationRegistry $processConfigurationRegistry,
protected ContextualOptionResolver $contextualOptionResolver,
- protected EventDispatcherInterface $eventDispatcher
+ protected EventDispatcherInterface $eventDispatcher,
) {
}
@@ -133,7 +133,7 @@ protected function doExecute(string $processCode, mixed $input = null, array $co
}
// If defined, set the input of a task
- if ($processConfiguration->getEntryPoint()) {
+ if ($processConfiguration->getEntryPoint() instanceof TaskConfiguration) {
$processConfiguration->getEntryPoint()
->getState()
->setInput($input);
@@ -159,7 +159,7 @@ protected function doExecute(string $processCode, mixed $input = null, array $co
// If defined, return the output of a task
$returnValue = null;
- if ($processConfiguration->getEndPoint()) {
+ if ($processConfiguration->getEndPoint() instanceof TaskConfiguration) {
$returnValue = $processConfiguration->getEndPoint()
->getState()
->getOutput();
@@ -225,7 +225,7 @@ protected function initialize(TaskConfiguration $taskConfiguration): void
$this->taskConfiguration = $taskConfiguration;
if (TaskConfiguration::STRATEGY_STOP === $taskConfiguration->getErrorStrategy()
- && \count($taskConfiguration->getErrorOutputs()) > 0) {
+ && [] !== $taskConfiguration->getErrorOutputs()) {
$m = "Task configuration {$taskConfiguration->getCode()} has error outputs ";
$m .= "but it's error strategy 'stop' implies they will never be reached.";
$this->taskLogger->debug($m);
@@ -289,7 +289,7 @@ protected function process(TaskConfiguration $taskConfiguration, int $executionF
}
if ($state->isStopped()) {
$exception = $state->getException();
- if ($exception) {
+ if ($exception instanceof \Throwable) {
$m = "Process {$state->getProcessConfiguration()
->getCode()} has failed";
$m .= " during process {$state->getTaskConfiguration()
@@ -353,7 +353,7 @@ protected function process(TaskConfiguration $taskConfiguration, int $executionF
protected function processExecution(TaskConfiguration $taskConfiguration, int $executionFlag): void
{
$task = $taskConfiguration->getTask();
- if (null === $task) {
+ if (!$task instanceof TaskInterface) {
throw new \RuntimeException("Missing task for configuration {$taskConfiguration->getCode()}");
}
$state = $taskConfiguration->getState();
@@ -393,7 +393,7 @@ protected function processExecution(TaskConfiguration $taskConfiguration, int $e
}
// Manage exception catching and setting the same
- if ($exception) {
+ if ($exception instanceof \Throwable) {
$this->taskLogger->log(
$taskConfiguration->getLogLevel(),
$exception->getMessage(),
@@ -460,7 +460,7 @@ protected function finalize(TaskConfiguration $taskConfiguration): void
protected function initializeStates(
ProcessConfiguration $processConfiguration,
- array $context = []
+ array $context = [],
): ProcessHistory {
$processHistory = new ProcessHistory($processConfiguration, $context);
@@ -479,7 +479,7 @@ protected function initializeStates(
protected function prepareNextProcess(
TaskConfiguration $previousTaskConfiguration,
TaskConfiguration $nextTaskConfiguration,
- bool $isError = false
+ bool $isError = false,
): void {
if ($isError) {
$input = $previousTaskConfiguration->getState()
diff --git a/src/Model/AbstractConfigurableTask.php b/src/Model/AbstractConfigurableTask.php
index 309af297..5228cec6 100644
--- a/src/Model/AbstractConfigurableTask.php
+++ b/src/Model/AbstractConfigurableTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -14,11 +14,12 @@
namespace CleverAge\ProcessBundle\Model;
use Symfony\Component\OptionsResolver\OptionsResolver;
+use Symfony\Contracts\Service\ResetInterface;
/**
* Allow the task to configure it's options, set default basic options for errors handling.
*/
-abstract class AbstractConfigurableTask implements InitializableTaskInterface
+abstract class AbstractConfigurableTask implements InitializableTaskInterface, ResetInterface
{
protected ?array $options = null;
@@ -30,6 +31,11 @@ public function initialize(ProcessState $state): void
$this->getOptions($state);
}
+ public function reset(): void
+ {
+ $this->options = null;
+ }
+
protected function getOptions(ProcessState $state): ?array
{
if (null === $this->options) {
diff --git a/src/Model/BlockingTaskInterface.php b/src/Model/BlockingTaskInterface.php
index ad0bb7fb..5236f8ae 100644
--- a/src/Model/BlockingTaskInterface.php
+++ b/src/Model/BlockingTaskInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Model/FinalizableTaskInterface.php b/src/Model/FinalizableTaskInterface.php
index 063ce14c..c71bed9b 100644
--- a/src/Model/FinalizableTaskInterface.php
+++ b/src/Model/FinalizableTaskInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Model/FlushableTaskInterface.php b/src/Model/FlushableTaskInterface.php
index 757fb5ba..8f56f5fa 100644
--- a/src/Model/FlushableTaskInterface.php
+++ b/src/Model/FlushableTaskInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Model/InitializableTaskInterface.php b/src/Model/InitializableTaskInterface.php
index 9cb9a5eb..434f60b2 100644
--- a/src/Model/InitializableTaskInterface.php
+++ b/src/Model/InitializableTaskInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Model/IterableTaskInterface.php b/src/Model/IterableTaskInterface.php
index 7d17856b..08b34111 100644
--- a/src/Model/IterableTaskInterface.php
+++ b/src/Model/IterableTaskInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Model/ProcessHistory.php b/src/Model/ProcessHistory.php
index 419f1927..1149c99b 100644
--- a/src/Model/ProcessHistory.php
+++ b/src/Model/ProcessHistory.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -38,7 +38,7 @@ class ProcessHistory implements \Stringable
public function __construct(
ProcessConfiguration $processConfiguration,
- protected array $context = []
+ protected array $context = [],
) {
$this->id = microtime(true);
$this->processCode = $processConfiguration->getCode();
@@ -120,7 +120,7 @@ public function isFailed(): bool
*/
public function getDuration(): ?int
{
- if ($this->getEndDate()) {
+ if ($this->getEndDate() instanceof \DateTimeInterface) {
return $this->getEndDate()
->getTimestamp() - $this->getStartDate()
->getTimestamp();
diff --git a/src/Model/ProcessState.php b/src/Model/ProcessState.php
index abbb2567..b6ec5c9d 100644
--- a/src/Model/ProcessState.php
+++ b/src/Model/ProcessState.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -69,7 +69,7 @@ class ProcessState
public function __construct(
protected ProcessConfiguration $processConfiguration,
- protected ProcessHistory $processHistory
+ protected ProcessHistory $processHistory,
) {
}
@@ -163,9 +163,9 @@ public function hasErrorOutput(): bool
return $this->hasErrorOutput;
}
- public function stop(\Throwable $e = null): void
+ public function stop(?\Throwable $e = null): void
{
- if ($e) {
+ if ($e instanceof \Throwable) {
$this->setException($e);
}
$this->setStopped(true);
@@ -186,7 +186,7 @@ public function getException(): ?\Throwable
return $this->exception;
}
- public function setException(\Throwable $exception = null): void
+ public function setException(?\Throwable $exception = null): void
{
$this->exception = $exception;
}
diff --git a/src/Model/SubprocessInstance.php b/src/Model/SubprocessInstance.php
index fb444e53..35b05d5c 100644
--- a/src/Model/SubprocessInstance.php
+++ b/src/Model/SubprocessInstance.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -40,7 +40,7 @@ public function __construct(
protected string $processCode,
protected ?string $input,
protected array $context = [],
- array $options = []
+ array $options = [],
) {
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
@@ -80,10 +80,8 @@ public function buildProcess(): static
$arguments = [...$arguments, '--output='.$this->bufferPath, '--output-format=json-stream'];
}
- if (!empty($this->context)) {
- foreach ($this->context as $key => $value) {
- $arguments[] = sprintf('--context=%s:%s', $key, $value);
- }
+ foreach ($this->context as $key => $value) {
+ $arguments[] = \sprintf('--context=%s:%s', $key, $value);
}
$arguments[] = $this->processCode;
diff --git a/src/Model/TaskInterface.php b/src/Model/TaskInterface.php
index 748e282d..0e0c0a28 100644
--- a/src/Model/TaskInterface.php
+++ b/src/Model/TaskInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Registry/ProcessConfigurationRegistry.php b/src/Registry/ProcessConfigurationRegistry.php
index 6c403cda..2c5c9fa4 100644
--- a/src/Registry/ProcessConfigurationRegistry.php
+++ b/src/Registry/ProcessConfigurationRegistry.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -31,7 +31,7 @@ class ProcessConfigurationRegistry
public function __construct(
protected array $rawConfiguration,
- protected string $defaultErrorStrategy
+ protected string $defaultErrorStrategy,
) {
}
diff --git a/src/Registry/TransformerRegistry.php b/src/Registry/TransformerRegistry.php
index 3ab519fb..9fd4fbff 100644
--- a/src/Registry/TransformerRegistry.php
+++ b/src/Registry/TransformerRegistry.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Resources/config/services/command.yaml b/src/Resources/config/services/command.yaml
deleted file mode 100644
index 4c700e2f..00000000
--- a/src/Resources/config/services/command.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-services:
- CleverAge\ProcessBundle\Command\:
- resource: '../../../Command/*'
- autowire: true
- autoconfigure: true
- bind:
- $container: '@service_container'
diff --git a/src/Resources/config/services/event.yaml b/src/Resources/config/services/event.yaml
deleted file mode 100644
index b5a218a1..00000000
--- a/src/Resources/config/services/event.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-services:
- Symfony\Contracts\EventDispatcher\EventDispatcherInterface:
- public: false
- autowire: true
-
- CleverAge\ProcessBundle\EventListener\DataQueueEventListener:
- public: false
- tags:
- - { name: kernel.event_listener, event: cleverage_process.data_queue, method: pushData }
diff --git a/src/Resources/config/services/expression_language.yaml b/src/Resources/config/services/expression_language.yaml
deleted file mode 100644
index 63a47a74..00000000
--- a/src/Resources/config/services/expression_language.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-services:
- CleverAge\ProcessBundle\ExpressionLanguage\PhpFunctionProvider:
- arguments:
- - [ 'preg_match' ]
-
- cleverage_process.expression_language:
- class: Symfony\Component\ExpressionLanguage\ExpressionLanguage
- calls:
- - ['registerProvider', ['@CleverAge\ProcessBundle\ExpressionLanguage\PhpFunctionProvider']]
diff --git a/src/Resources/config/services/logger.yaml b/src/Resources/config/services/logger.yaml
deleted file mode 100644
index 1968bd79..00000000
--- a/src/Resources/config/services/logger.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-services:
- CleverAge\ProcessBundle\Logger\ProcessProcessor:
- autowire: true
- tags:
- - { name: monolog.processor, channel: cleverage_process }
-
- CleverAge\ProcessBundle\Logger\TaskProcessor:
- autowire: true
- tags:
- - { name: monolog.processor, channel: cleverage_process_task }
-
- CleverAge\ProcessBundle\Logger\TransformerProcessor:
- autowire: true
- tags:
- - { name: monolog.processor, channel: cleverage_process_transformer }
-
- CleverAge\ProcessBundle\Logger\ProcessLogger:
- autowire: true
- tags:
- - { name: monolog.logger, channel: cleverage_process }
-
- CleverAge\ProcessBundle\Logger\TaskLogger:
- autowire: true
- tags:
- - { name: monolog.logger, channel: cleverage_process_task }
diff --git a/src/Resources/config/services/manager.yaml b/src/Resources/config/services/manager.yaml
deleted file mode 100644
index a4360642..00000000
--- a/src/Resources/config/services/manager.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-services:
- CleverAge\ProcessBundle\Manager\ProcessManager:
- autowire: true
- public: false
- arguments:
- $container: '@service_container'
-
- CleverAge\ProcessBundle\Context\ContextualOptionResolver:
- public: false
diff --git a/src/Resources/config/services/registry.yaml b/src/Resources/config/services/registry.yaml
deleted file mode 100644
index 7e0ec1aa..00000000
--- a/src/Resources/config/services/registry.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-services:
- CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry:
- arguments:
- - ~
- - ~
-
- CleverAge\ProcessBundle\Registry\TransformerRegistry:
- public: false
diff --git a/src/Resources/config/services/task.yaml b/src/Resources/config/services/task.yaml
deleted file mode 100644
index 61e64bf7..00000000
--- a/src/Resources/config/services/task.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-services:
- CleverAge\ProcessBundle\Task\:
- resource: '../../../Task/*'
- autowire: true
- public: true
- shared: false
- tags:
- - { name: monolog.logger, channel: cleverage_process_task }
diff --git a/src/Task/AbstractIterableOutputTask.php b/src/Task/AbstractIterableOutputTask.php
index b2c8f7f2..8e8ccb7a 100644
--- a/src/Task/AbstractIterableOutputTask.php
+++ b/src/Task/AbstractIterableOutputTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -47,7 +47,7 @@ public function execute(ProcessState $state): void
*/
public function next(ProcessState $state): bool
{
- if (!$this->iterator) {
+ if (!$this->iterator instanceof \Iterator) {
return false;
}
$this->iterator->next();
diff --git a/src/Task/AggregateIterableTask.php b/src/Task/AggregateIterableTask.php
index f4fcc122..893d2206 100644
--- a/src/Task/AggregateIterableTask.php
+++ b/src/Task/AggregateIterableTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -32,7 +32,7 @@ public function execute(ProcessState $state): void
public function proceed(ProcessState $state): void
{
- if (0 === \count($this->result)) {
+ if ([] === $this->result) {
$state->setSkipped(true);
} else {
$state->setOutput($this->result);
diff --git a/src/Task/ArrayMergeTask.php b/src/Task/ArrayMergeTask.php
index 6e20e7fd..a00e45ae 100644
--- a/src/Task/ArrayMergeTask.php
+++ b/src/Task/ArrayMergeTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/ColumnAggregatorTask.php b/src/Task/ColumnAggregatorTask.php
index 033e14e2..829753b3 100644
--- a/src/Task/ColumnAggregatorTask.php
+++ b/src/Task/ColumnAggregatorTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -32,7 +32,7 @@ class ColumnAggregatorTask extends AbstractConfigurableTask implements BlockingT
public function __construct(
PropertyAccessorInterface $accessor,
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
$this->accessor = $accessor;
}
@@ -63,7 +63,7 @@ public function execute(ProcessState $state): void
}
}
- if (!empty($missingColumns)) {
+ if ([] !== $missingColumns) {
$colStr = implode(', ', $missingColumns);
$message = "Missing columns [{$colStr}] in input";
@@ -84,7 +84,7 @@ protected function addValueToAggregationGroup(
mixed $column,
mixed $input,
string $referenceKey,
- string $aggregationKey
+ string $aggregationKey,
): void {
if (!isset($this->result[$column])) {
$this->result[$column] = [
diff --git a/src/Task/ConstantIterableOutputTask.php b/src/Task/ConstantIterableOutputTask.php
index 415e1164..60eeeb56 100644
--- a/src/Task/ConstantIterableOutputTask.php
+++ b/src/Task/ConstantIterableOutputTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/ConstantOutputTask.php b/src/Task/ConstantOutputTask.php
index 040b882d..7037cafa 100644
--- a/src/Task/ConstantOutputTask.php
+++ b/src/Task/ConstantOutputTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/CounterTask.php b/src/Task/CounterTask.php
index df16e969..9b2020e5 100644
--- a/src/Task/CounterTask.php
+++ b/src/Task/CounterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/Debug/DebugTask.php b/src/Task/Debug/DebugTask.php
index 2f3dce09..9020262d 100644
--- a/src/Task/Debug/DebugTask.php
+++ b/src/Task/Debug/DebugTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -19,8 +19,6 @@
/**
* Dump the content of the input.
- *
- * @example https://github.com/cleverage/process-bundle-ui-demo/blob/main/config/packages/process/demo.debug.yaml
*/
class DebugTask implements TaskInterface
{
diff --git a/src/Task/Debug/DieTask.php b/src/Task/Debug/DieTask.php
index 1884d133..b8625914 100644
--- a/src/Task/Debug/DieTask.php
+++ b/src/Task/Debug/DieTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -15,20 +15,16 @@
use CleverAge\ProcessBundle\Model\ProcessState;
use CleverAge\ProcessBundle\Model\TaskInterface;
-use Symfony\Component\Console\Helper\Helper;
/**
* Class DieTask.
*
* Stops the process brutally
- *
- * @example https://github.com/cleverage/process-bundle-ui-demo/blob/main/config/packages/process/demo.die.yaml
*/
class DieTask implements TaskInterface
{
public function execute(ProcessState $state): never
{
- var_dump(Helper::formatMemory(memory_get_peak_usage(true)));
exit;
}
}
diff --git a/src/Task/Debug/ErrorForwarderTask.php b/src/Task/Debug/ErrorForwarderTask.php
index 80f235ed..9dbc1da8 100644
--- a/src/Task/Debug/ErrorForwarderTask.php
+++ b/src/Task/Debug/ErrorForwarderTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/Debug/MemInfoDumpTask.php b/src/Task/Debug/MemInfoDumpTask.php
deleted file mode 100644
index a793c680..00000000
--- a/src/Task/Debug/MemInfoDumpTask.php
+++ /dev/null
@@ -1,48 +0,0 @@
-getOption($state, 'file_path'), 'w');
- meminfo_dump($handler);
- fclose($handler);
- } else {
- $this->logger->critical('meminfo PHP extension is not loaded');
- }
- }
-
- protected function configureOptions(OptionsResolver $resolver): void
- {
- $resolver->setRequired(['file_path']);
- $resolver->setAllowedTypes('file_path', ['string']);
- }
-}
diff --git a/src/Task/Debug/StopwatchTask.php b/src/Task/Debug/StopwatchTask.php
index 8bbaf85e..160db265 100644
--- a/src/Task/Debug/StopwatchTask.php
+++ b/src/Task/Debug/StopwatchTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -19,13 +19,13 @@
use Symfony\Component\Stopwatch\Stopwatch;
/**
- * Ouputs the stopwatch the content of the input.
+ * Log all the __root__ events of the Stopwatch component.
*/
class StopwatchTask implements TaskInterface
{
public function __construct(
protected LoggerInterface $logger,
- private readonly Stopwatch $stopwatch
+ private readonly Stopwatch $stopwatch,
) {
}
diff --git a/src/Task/DummyTask.php b/src/Task/DummyTask.php
index 71b9f4fe..7cb1bcae 100644
--- a/src/Task/DummyTask.php
+++ b/src/Task/DummyTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/Event/EventDispatcherTask.php b/src/Task/Event/EventDispatcherTask.php
index 1233fb6b..fcf8bc92 100644
--- a/src/Task/Event/EventDispatcherTask.php
+++ b/src/Task/Event/EventDispatcherTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -16,7 +16,7 @@
use CleverAge\ProcessBundle\Event\EventDispatcherTaskEvent;
use CleverAge\ProcessBundle\Model\AbstractConfigurableTask;
use CleverAge\ProcessBundle\Model\ProcessState;
-use Psr\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
@@ -26,7 +26,7 @@
class EventDispatcherTask extends AbstractConfigurableTask
{
public function __construct(
- protected EventDispatcherInterface $eventDispatcher
+ protected EventDispatcherInterface $eventDispatcher,
) {
}
diff --git a/src/Task/File/Csv/AbstractCsvResourceTask.php b/src/Task/File/Csv/AbstractCsvResourceTask.php
index 6d4d5416..a0ed37b9 100644
--- a/src/Task/File/Csv/AbstractCsvResourceTask.php
+++ b/src/Task/File/Csv/AbstractCsvResourceTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -35,7 +35,7 @@ public function finalize(ProcessState $state): void
protected function initFile(ProcessState $state): void
{
- if ($this->csv) {
+ if ($this->csv instanceof CsvResource) {
return;
}
$options = $this->getOptions($state);
diff --git a/src/Task/File/Csv/AbstractCsvTask.php b/src/Task/File/Csv/AbstractCsvTask.php
index a1c2f884..2119dcb9 100644
--- a/src/Task/File/Csv/AbstractCsvTask.php
+++ b/src/Task/File/Csv/AbstractCsvTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -14,6 +14,7 @@
namespace CleverAge\ProcessBundle\Task\File\Csv;
use CleverAge\ProcessBundle\Filesystem\CsvFile;
+use CleverAge\ProcessBundle\Filesystem\CsvResource;
use CleverAge\ProcessBundle\Model\ProcessState;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -23,9 +24,10 @@
*/
abstract class AbstractCsvTask extends AbstractCsvResourceTask
{
+ #[\Override]
protected function initFile(ProcessState $state): void
{
- if ($this->csv) {
+ if ($this->csv instanceof CsvResource) {
return;
}
$options = $this->getOptions($state);
@@ -40,6 +42,7 @@ protected function initFile(ProcessState $state): void
);
}
+ #[\Override]
protected function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
diff --git a/src/Task/File/Csv/CsvReaderTask.php b/src/Task/File/Csv/CsvReaderTask.php
index 2a0c9e85..6168388e 100644
--- a/src/Task/File/Csv/CsvReaderTask.php
+++ b/src/Task/File/Csv/CsvReaderTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -26,7 +26,7 @@
class CsvReaderTask extends AbstractCsvTask implements IterableTaskInterface
{
public function __construct(
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
}
@@ -82,6 +82,7 @@ protected function getHeaders(ProcessState $state, array $options): ?array
return $options['headers'];
}
+ #[\Override]
protected function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
diff --git a/src/Task/File/Csv/CsvSplitterTask.php b/src/Task/File/Csv/CsvSplitterTask.php
index 8cbc3b8b..c11a0b9d 100644
--- a/src/Task/File/Csv/CsvSplitterTask.php
+++ b/src/Task/File/Csv/CsvSplitterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -23,10 +23,11 @@
*/
class CsvSplitterTask extends InputCsvReaderTask
{
+ #[\Override]
public function execute(ProcessState $state): void
{
$options = $this->getOptions($state);
- if (null === $this->csv) {
+ if (!$this->csv instanceof CsvResource) {
$headers = $this->getHeaders($state, $options);
$csv = new CsvFile(
$options['file_path'],
@@ -49,6 +50,7 @@ public function execute(ProcessState $state): void
* return true if the task has a next element
* return false if the task has terminated it's iteration.
*/
+ #[\Override]
public function next(ProcessState $state): bool
{
if (!$this->csv instanceof CsvResource) {
@@ -64,6 +66,7 @@ public function next(ProcessState $state): bool
return !$endOfFile;
}
+ #[\Override]
public function finalize(ProcessState $state): void
{
if ($this->csv instanceof CsvResource) {
@@ -72,7 +75,7 @@ public function finalize(ProcessState $state): void
}
}
- protected function splitCsv(CsvFile $csv, int $maxLines): string
+ protected function splitCsv(CsvResource $csv, int $maxLines): string
{
$tmpFilePath = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'php_'.uniqid('process', false).'.csv';
$tmpFile = fopen($tmpFilePath, 'wb+');
@@ -100,6 +103,7 @@ protected function splitCsv(CsvFile $csv, int $maxLines): string
return $tmpFilePath;
}
+ #[\Override]
protected function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
diff --git a/src/Task/File/Csv/CsvWriterTask.php b/src/Task/File/Csv/CsvWriterTask.php
index 813013e5..c4c70e55 100644
--- a/src/Task/File/Csv/CsvWriterTask.php
+++ b/src/Task/File/Csv/CsvWriterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -43,6 +43,7 @@ public function proceed(ProcessState $state): void
$state->setOutput($this->csv->getFilePath());
}
+ #[\Override]
protected function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@@ -59,6 +60,7 @@ protected function configureOptions(OptionsResolver $resolver): void
[
'{date}' => date('Ymd'),
'{date_time}' => date('Ymd_His'),
+ '{timestamp}' => time(),
'{unique_token}' => uniqid('', true),
]
)
diff --git a/src/Task/File/Csv/InputCsvReaderTask.php b/src/Task/File/Csv/InputCsvReaderTask.php
index b819548a..2234a263 100644
--- a/src/Task/File/Csv/InputCsvReaderTask.php
+++ b/src/Task/File/Csv/InputCsvReaderTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -21,6 +21,7 @@
*/
class InputCsvReaderTask extends CsvReaderTask
{
+ #[\Override]
protected function getOptions(ProcessState $state): array
{
$options = parent::getOptions($state);
@@ -31,6 +32,7 @@ protected function getOptions(ProcessState $state): array
return $options;
}
+ #[\Override]
protected function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
diff --git a/src/Task/File/FileFetchTask.php b/src/Task/File/FileFetchTask.php
deleted file mode 100644
index e9cb12c5..00000000
--- a/src/Task/File/FileFetchTask.php
+++ /dev/null
@@ -1,142 +0,0 @@
-mountManager) {
- throw new ServiceNotFoundException('MountManager service not found, you need to install FlySystemBundle');
- }
- // Configure options
- parent::initialize($state);
-
- $this->sourceFS = new Filesystem($this->getOption($state, 'source_filesystem'));
- $this->destinationFS = new Filesystem($this->getOption($state, 'destination_filesystem'));
- }
-
- public function execute(ProcessState $state): void
- {
- $this->findMatchingFiles($state);
-
- $file = current($this->matchingFiles);
- if (!$file) {
- $state->setSkipped(true);
-
- return;
- }
-
- $this->doFileCopy($state, $file, $this->getOption($state, 'remove_source'));
- $state->setOutput($file);
- }
-
- public function next(ProcessState $state): bool
- {
- $this->findMatchingFiles($state);
-
- return next($this->matchingFiles);
- }
-
- protected function findMatchingFiles(ProcessState $state): void
- {
- $filePattern = $this->getOption($state, 'file_pattern');
- if ($filePattern) {
- foreach ($this->sourceFS->listContents('/') as $file) {
- if ('file' === $file['type']
- && preg_match($filePattern, (string) $file['path'])
- && !\in_array($file['path'], $this->matchingFiles, true)) {
- $this->matchingFiles[] = $file['path'];
- }
- }
- } else {
- $input = $state->getInput();
- if (!$input) {
- throw new \UnexpectedValueException('No pattern neither input provided for the Task');
- }
- if (\is_array($input)) {
- foreach ($input as $file) {
- if (!\in_array($file, $this->matchingFiles, true)) {
- $this->matchingFiles[] = $file;
- }
- }
- } elseif (!\in_array($input, $this->matchingFiles, true)) {
- $this->matchingFiles[] = $input;
- }
- }
- }
-
- protected function doFileCopy(ProcessState $state, string $filename, bool $removeSource): string|bool|null
- {
- $prefixFrom = $this->getOption($state, 'source_filesystem');
-
- $buffer = $this->sourceFS->readStream($filename);
-
- try {
- $this->destinationFS->writeStream($filename, $buffer);
- $result = true;
- } catch (FilesystemException) {
- $result = false;
- }
-
- if (\is_resource($buffer)) {
- fclose($buffer);
- }
-
- if ($removeSource) {
- $this->sourceFS->delete(sprintf('%s://%s', $prefixFrom, $filename));
- }
-
- return $result ? $filename : null;
- }
-
- protected function configureOptions(OptionsResolver $resolver): void
- {
- $resolver->setRequired(['source_filesystem', 'destination_filesystem']);
- $resolver->setAllowedTypes('source_filesystem', 'string');
- $resolver->setAllowedTypes('destination_filesystem', 'string');
-
- $resolver->setDefault('file_pattern', null);
- $resolver->setAllowedTypes('file_pattern', ['string', 'null']);
-
- $resolver->setDefault('remove_source', false);
- $resolver->setAllowedTypes('remove_source', 'boolean');
- }
-}
diff --git a/src/Task/File/FileMoverTask.php b/src/Task/File/FileMoverTask.php
index 81cf17c2..e9070cd1 100644
--- a/src/Task/File/FileMoverTask.php
+++ b/src/Task/File/FileMoverTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/File/FileReaderTask.php b/src/Task/File/FileReaderTask.php
index ea69db22..2261acbe 100644
--- a/src/Task/File/FileReaderTask.php
+++ b/src/Task/File/FileReaderTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/File/FileRemoverTask.php b/src/Task/File/FileRemoverTask.php
index 03e68145..dda53166 100644
--- a/src/Task/File/FileRemoverTask.php
+++ b/src/Task/File/FileRemoverTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/File/FileSplitterTask.php b/src/Task/File/FileSplitterTask.php
new file mode 100644
index 00000000..e87bc2e0
--- /dev/null
+++ b/src/Task/File/FileSplitterTask.php
@@ -0,0 +1,110 @@
+getMergedOptions($state);
+ $this->splFileObjectFlags = [\SplFileObject::READ_AHEAD, \SplFileObject::SKIP_EMPTY];
+ if (!$this->file instanceof SplFile) {
+ $this->file = new SplFile($options['file_path'], 'rb', $this->splFileObjectFlags);
+ $this->lineCount = $this->file->getLineCount();
+ }
+
+ // Return a temporary file containing a limited number of lines
+ $splittedFilename = $this->splitFile($this->file, $options['max_lines']);
+ $state->setOutput($splittedFilename);
+ }
+
+ /**
+ * Moves the internal pointer to the next element,
+ * return true if the task has a next element
+ * return false if the task has terminated it's iteration.
+ */
+ public function next(ProcessState $state): bool
+ {
+ if (!$this->file instanceof SplFile) {
+ return false;
+ }
+
+ // Fix issue on PHP 8 with empty line at the end, even if SKIP_EMPTY is set
+ $endOfFile = $this->file->isEndOfFile() || $this->file->getLineNumber() > $this->lineCount;
+ if ($endOfFile) {
+ $this->file = null;
+ }
+
+ return !$endOfFile;
+ }
+
+ protected function splitFile(SplFile $file, int $maxLines): string
+ {
+ $tmpFilePath = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'php_'.uniqid('process', false).'.tmp';
+ $splitFile = new SplFile($tmpFilePath, 'wb', $this->splFileObjectFlags);
+
+ while ($splitFile->getLineNumber() <= $maxLines && !$file->isEndOfFile()) {
+ $line = $file->readLine();
+ if ('' === $line || null === $line) {
+ continue; // This is probably an empty line, no harm to skip it
+ }
+ $splitFile->writeLine($line);
+ }
+
+ return $tmpFilePath;
+ }
+
+ protected function configureOptions(OptionsResolver $resolver): void
+ {
+ $resolver->setRequired(['file_path']);
+ $resolver->setAllowedTypes('file_path', ['string']);
+ $resolver->setDefaults([
+ 'max_lines' => 1000,
+ ]);
+ $resolver->setAllowedTypes('max_lines', ['int']);
+ }
+
+ /**
+ * @return array
+ */
+ protected function getMergedOptions(ProcessState $state): array
+ {
+ /** @var array $options */
+ $options = $this->getOptions($state);
+
+ /** @var array|mixed $input */
+ $input = $state->getInput() ?: [];
+ if (!\is_array($input)) {
+ $input = [];
+ }
+ // @var array $input
+
+ return array_merge($options, $input);
+ }
+}
diff --git a/src/Task/File/FileWriterTask.php b/src/Task/File/FileWriterTask.php
index d3dc0740..5378099b 100644
--- a/src/Task/File/FileWriterTask.php
+++ b/src/Task/File/FileWriterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/File/FolderBrowserTask.php b/src/Task/File/FolderBrowserTask.php
index 6eeb8e5d..6668c3eb 100644
--- a/src/Task/File/FolderBrowserTask.php
+++ b/src/Task/File/FolderBrowserTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -35,7 +35,7 @@ class FolderBrowserTask extends AbstractConfigurableTask implements IterableTask
protected \Iterator|array|null $files = null;
public function __construct(
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
}
diff --git a/src/Task/File/InputFileReaderTask.php b/src/Task/File/InputFileReaderTask.php
new file mode 100644
index 00000000..d378a6dd
--- /dev/null
+++ b/src/Task/File/InputFileReaderTask.php
@@ -0,0 +1,41 @@
+getInput()) {
+ $options['filename'] = $state->getInput();
+ }
+
+ return $options;
+ }
+
+ #[\Override]
+ protected function configureOptions(OptionsResolver $resolver): void
+ {
+ parent::configureOptions($resolver);
+ $resolver->remove('filename');
+ }
+}
diff --git a/src/Task/File/InputFolderBrowserTask.php b/src/Task/File/InputFolderBrowserTask.php
index 5d1fb90b..a0151ae1 100644
--- a/src/Task/File/InputFolderBrowserTask.php
+++ b/src/Task/File/InputFolderBrowserTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -31,11 +31,13 @@ public function flush(ProcessState $state): void
$state->setSkipped(true);
}
+ #[\Override]
public function initialize(ProcessState $state): void
{
parent::getOptions($state);
}
+ #[\Override]
protected function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@@ -47,6 +49,7 @@ protected function configureOptions(OptionsResolver $resolver): void
$resolver->setAllowedTypes('base_folder_path', ['string']);
}
+ #[\Override]
protected function getOptions(ProcessState $state): array
{
$options = parent::getOptions($state);
diff --git a/src/Task/File/InputLineReaderTask.php b/src/Task/File/InputLineReaderTask.php
new file mode 100644
index 00000000..73ac0ea2
--- /dev/null
+++ b/src/Task/File/InputLineReaderTask.php
@@ -0,0 +1,41 @@
+getInput()) {
+ $options['filename'] = $state->getInput();
+ }
+
+ return $options;
+ }
+
+ #[\Override]
+ protected function configureOptions(OptionsResolver $resolver): void
+ {
+ parent::configureOptions($resolver);
+ $resolver->remove('filename');
+ }
+}
diff --git a/src/Task/File/JsonStream/JsonStreamReaderTask.php b/src/Task/File/JsonStream/JsonStreamReaderTask.php
index 9f77ab0d..e1924b0f 100644
--- a/src/Task/File/JsonStream/JsonStreamReaderTask.php
+++ b/src/Task/File/JsonStream/JsonStreamReaderTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -14,17 +14,25 @@
namespace CleverAge\ProcessBundle\Task\File\JsonStream;
use CleverAge\ProcessBundle\Filesystem\JsonStreamFile;
+use CleverAge\ProcessBundle\Model\AbstractConfigurableTask;
use CleverAge\ProcessBundle\Model\IterableTaskInterface;
use CleverAge\ProcessBundle\Model\ProcessState;
+use Symfony\Component\OptionsResolver\OptionsResolver;
-class JsonStreamReaderTask implements IterableTaskInterface
+class JsonStreamReaderTask extends AbstractConfigurableTask implements IterableTaskInterface
{
protected ?JsonStreamFile $file = null;
public function execute(ProcessState $state): void
{
- if (null === $this->file) {
- $this->file = new JsonStreamFile($this->getFilePath($state), 'rb');
+ if (!$this->file instanceof JsonStreamFile) {
+ $options = $this->getOptions($state);
+ $this->file = new JsonStreamFile(
+ $this->getFilePath($state),
+ 'rb',
+ $options['spl_file_object_flags'],
+ $options['json_flags'],
+ );
}
$line = $this->file->readLine();
@@ -49,4 +57,14 @@ protected function getFilePath(ProcessState $state): string
{
return $state->getInput();
}
+
+ protected function configureOptions(OptionsResolver $resolver): void
+ {
+ $resolver->setDefaults([
+ 'spl_file_object_flags' => null,
+ 'json_flags' => null,
+ ]);
+ $resolver->setAllowedTypes('spl_file_object_flags', ['array', 'null']);
+ $resolver->setAllowedTypes('json_flags', ['array', 'null']);
+ }
}
diff --git a/src/Task/File/JsonStream/JsonStreamWriterTask.php b/src/Task/File/JsonStream/JsonStreamWriterTask.php
new file mode 100644
index 00000000..c57446b5
--- /dev/null
+++ b/src/Task/File/JsonStream/JsonStreamWriterTask.php
@@ -0,0 +1,75 @@
+file instanceof JsonStreamFile) {
+ $options = $this->getOptions($state);
+ $this->file = new JsonStreamFile(
+ $options['file_path'],
+ 'wb',
+ $options['spl_file_object_flags'],
+ $options['json_flags'],
+ );
+ }
+
+ $input = $state->getInput();
+ if (!\is_array($input)) {
+ throw new \UnexpectedValueException('Input value is not an array');
+ }
+ $this->file->writeLine($input);
+ }
+
+ public function proceed(ProcessState $state): void
+ {
+ $options = $this->getOptions($state);
+ $state->setOutput($options['file_path']);
+ }
+
+ protected function configureOptions(OptionsResolver $resolver): void
+ {
+ $resolver->setRequired(['file_path']);
+ $resolver->setAllowedTypes('file_path', ['string']);
+ $resolver->setNormalizer(
+ 'file_path',
+ static fn (Options $options, $value): string => strtr(
+ $value,
+ [
+ '{date}' => date('Ymd'),
+ '{date_time}' => date('Ymd_His'),
+ '{timestamp}' => time(),
+ '{unique_token}' => uniqid('', true),
+ ]
+ )
+ );
+ $resolver->setDefaults([
+ 'spl_file_object_flags' => null,
+ 'json_flags' => null,
+ ]);
+ $resolver->setAllowedTypes('spl_file_object_flags', ['array', 'null']);
+ $resolver->setAllowedTypes('json_flags', ['array', 'null']);
+ }
+}
diff --git a/src/Task/File/LineReaderTask.php b/src/Task/File/LineReaderTask.php
new file mode 100644
index 00000000..da103ab0
--- /dev/null
+++ b/src/Task/File/LineReaderTask.php
@@ -0,0 +1,70 @@
+getOptions($state);
+ $filename = $options['filename'];
+
+ if ($this->file instanceof \SplFileObject
+ && $this->file->getPathname() !== $filename) {
+ $this->file = null;
+ }
+
+ if (!$this->file instanceof \SplFileObject) {
+ if (!file_exists($filename)) {
+ throw new \UnexpectedValueException("File does not exist: '{$filename}'");
+ }
+
+ if (!is_readable($filename)) {
+ throw new \UnexpectedValueException("File is not readable: '{$filename}'");
+ }
+
+ $this->file = new \SplFileObject($filename);
+ $this->file->setFlags(\SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY);
+ $this->file->rewind();
+ }
+
+ $state->setOutput($this->file->current());
+ $this->file->next();
+ }
+
+ public function next(ProcessState $state): bool
+ {
+ if (!$this->file instanceof \SplFileObject) {
+ throw new \LogicException('No File initialized');
+ }
+
+ return !$this->file->eof();
+ }
+
+ protected function configureOptions(OptionsResolver $resolver): void
+ {
+ $resolver->setRequired(['filename']);
+ $resolver->setAllowedTypes('filename', ['string']);
+ }
+}
diff --git a/src/Task/File/Xml/XmlReaderTask.php b/src/Task/File/Xml/XmlReaderTask.php
index 69535635..236420a1 100644
--- a/src/Task/File/Xml/XmlReaderTask.php
+++ b/src/Task/File/Xml/XmlReaderTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -25,7 +25,7 @@
class XmlReaderTask extends AbstractConfigurableTask
{
public function __construct(
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
}
diff --git a/src/Task/File/Xml/XmlWriterTask.php b/src/Task/File/Xml/XmlWriterTask.php
index 64548f33..6c88226a 100644
--- a/src/Task/File/Xml/XmlWriterTask.php
+++ b/src/Task/File/Xml/XmlWriterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -25,7 +25,7 @@
class XmlWriterTask extends AbstractConfigurableTask
{
public function __construct(
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
}
diff --git a/src/Task/File/YamlReaderTask.php b/src/Task/File/Yaml/YamlReaderTask.php
similarity index 94%
rename from src/Task/File/YamlReaderTask.php
rename to src/Task/File/Yaml/YamlReaderTask.php
index 67174114..13277cf1 100644
--- a/src/Task/File/YamlReaderTask.php
+++ b/src/Task/File/Yaml/YamlReaderTask.php
@@ -5,13 +5,13 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Task\File;
+namespace CleverAge\ProcessBundle\Task\File\Yaml;
use CleverAge\ProcessBundle\Model\ProcessState;
use CleverAge\ProcessBundle\Task\AbstractIterableOutputTask;
diff --git a/src/Task/File/YamlWriterTask.php b/src/Task/File/Yaml/YamlWriterTask.php
similarity index 93%
rename from src/Task/File/YamlWriterTask.php
rename to src/Task/File/Yaml/YamlWriterTask.php
index 0fa18844..f557cae2 100644
--- a/src/Task/File/YamlWriterTask.php
+++ b/src/Task/File/Yaml/YamlWriterTask.php
@@ -5,13 +5,13 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Task\File;
+namespace CleverAge\ProcessBundle\Task\File\Yaml;
use CleverAge\ProcessBundle\Model\AbstractConfigurableTask;
use CleverAge\ProcessBundle\Model\ProcessState;
diff --git a/src/Task/FilterTask.php b/src/Task/FilterTask.php
index 38715c3c..290ba13e 100644
--- a/src/Task/FilterTask.php
+++ b/src/Task/FilterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -28,6 +28,7 @@ class FilterTask extends AbstractConfigurableTask
{
use ConditionTrait;
+ #[\Override]
public function initialize(ProcessState $state): void
{
parent::initialize($state);
diff --git a/src/Task/GroupByAggregateIterableTask.php b/src/Task/GroupByAggregateIterableTask.php
index 3d676ca3..b92e2f18 100644
--- a/src/Task/GroupByAggregateIterableTask.php
+++ b/src/Task/GroupByAggregateIterableTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -33,7 +33,7 @@ class GroupByAggregateIterableTask extends AbstractConfigurableTask implements B
protected array $result = [];
public function __construct(
- protected PropertyAccessorInterface $accessor
+ protected PropertyAccessorInterface $accessor,
) {
}
@@ -61,7 +61,7 @@ public function execute(ProcessState $state): void
public function proceed(ProcessState $state): void
{
- if (0 === \count($this->result)) {
+ if ([] === $this->result) {
$state->setSkipped(true);
} else {
$state->setOutput($this->result);
diff --git a/src/Task/InputAggregatorTask.php b/src/Task/InputAggregatorTask.php
index 28ccf5e4..c5b68fa3 100644
--- a/src/Task/InputAggregatorTask.php
+++ b/src/Task/InputAggregatorTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -54,7 +54,7 @@ public function execute(ProcessState $state): void
$state->setOutput($this->inputs);
$keepInputs = $this->getOption($state, 'keep_inputs');
// Only clear inputs that are not in the keep_inputs option
- foreach ($this->inputs as $inputCode => $value) {
+ foreach (array_keys($this->inputs) as $inputCode) {
if (null !== $keepInputs && \in_array($inputCode, $keepInputs, true)) {
continue;
}
@@ -83,7 +83,7 @@ protected function configureOptions(OptionsResolver $resolver): void
protected function getInputCode(ProcessState $state): string
{
$previousState = $state->getPreviousState();
- if (!$previousState) {
+ if (!$previousState instanceof ProcessState) {
throw new \RuntimeException('No previous state for current task');
}
$previousTaskCode = $previousState->getTaskConfiguration()
diff --git a/src/Task/InputIteratorTask.php b/src/Task/InputIteratorTask.php
index 301c24b3..a079626d 100644
--- a/src/Task/InputIteratorTask.php
+++ b/src/Task/InputIteratorTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/IterableBatchTask.php b/src/Task/IterableBatchTask.php
index 15f46e24..b8840a74 100644
--- a/src/Task/IterableBatchTask.php
+++ b/src/Task/IterableBatchTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -31,10 +31,11 @@ class IterableBatchTask extends AbstractConfigurableTask implements FlushableTas
protected bool $flushMode = false;
public function __construct(
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
}
+ #[\Override]
public function initialize(ProcessState $state): void
{
parent::initialize($state);
@@ -61,7 +62,7 @@ public function execute(ProcessState $state): void
}
// Detect flushing
- if (null !== $batchCount && (null === $this->outputQueue ? 0 : \count($this->outputQueue)) >= $batchCount) {
+ if (null !== $batchCount && ($this->outputQueue instanceof \SplQueue ? \count($this->outputQueue) : 0) >= $batchCount) {
$this->flushMode = true;
}
@@ -76,7 +77,7 @@ public function execute(ProcessState $state): void
public function next(ProcessState $state): bool
{
// Stop flushing once over
- if (!(null === $this->outputQueue ? 0 : \count($this->outputQueue))) {
+ if (($this->outputQueue instanceof \SplQueue ? \count($this->outputQueue) : 0) === 0) {
$this->flushMode = false;
}
diff --git a/src/Task/ObjectUpdaterTask.php b/src/Task/ObjectUpdaterTask.php
index 8136b7bd..30a53641 100644
--- a/src/Task/ObjectUpdaterTask.php
+++ b/src/Task/ObjectUpdaterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -24,7 +24,7 @@
class ObjectUpdaterTask extends AbstractConfigurableTask
{
public function __construct(
- protected PropertyAccessorInterface $accessor
+ protected PropertyAccessorInterface $accessor,
) {
}
diff --git a/src/Task/Process/CommandRunnerTask.php b/src/Task/Process/CommandRunnerTask.php
index 999e5573..a988ff3e 100644
--- a/src/Task/Process/CommandRunnerTask.php
+++ b/src/Task/Process/CommandRunnerTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -25,7 +25,7 @@
class CommandRunnerTask extends AbstractConfigurableTask
{
public function __construct(
- protected KernelInterface $kernel
+ protected KernelInterface $kernel,
) {
}
diff --git a/src/Task/Process/ProcessExecutorTask.php b/src/Task/Process/ProcessExecutorTask.php
index e9a515c2..6775e6c5 100644
--- a/src/Task/Process/ProcessExecutorTask.php
+++ b/src/Task/Process/ProcessExecutorTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -18,7 +18,7 @@
use CleverAge\ProcessBundle\Model\ProcessState;
use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry;
use Psr\Log\LoggerInterface;
-use Symfony\Component\Form\Exception\InvalidConfigurationException;
+use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -32,7 +32,7 @@ class ProcessExecutorTask extends AbstractConfigurableTask
public function __construct(
protected ProcessManager $processManager,
protected ProcessConfigurationRegistry $processRegistry,
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
}
@@ -45,6 +45,7 @@ public function execute(ProcessState $state): void
$state->setOutput($output);
}
+ #[\Override]
public function initialize(ProcessState $state): void
{
parent::initialize($state);
diff --git a/src/Task/Process/ProcessLauncherTask.php b/src/Task/Process/ProcessLauncherTask.php
index 1661b87f..30d5e6da 100644
--- a/src/Task/Process/ProcessLauncherTask.php
+++ b/src/Task/Process/ProcessLauncherTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -42,7 +42,7 @@ class ProcessLauncherTask extends AbstractConfigurableTask implements FlushableT
public function __construct(
protected LoggerInterface $logger,
protected ProcessConfigurationRegistry $processRegistry,
- protected KernelInterface $kernel
+ protected KernelInterface $kernel,
) {
$this->finishedBuffers = new \SplQueue();
}
@@ -78,7 +78,7 @@ public function flush(ProcessState $state): void
}
// After dequeue, stop flush
- if ($this->finishedBuffers->isEmpty() && !\count($this->launchedProcesses)) {
+ if ($this->finishedBuffers->isEmpty() && [] === $this->launchedProcesses) {
$this->flushMode = false;
}
}
@@ -96,7 +96,7 @@ public function next(ProcessState $state): bool
// if we are in flush mode, we should wait for process to finish
if ($this->flushMode) {
- return \count($this->launchedProcesses) > 0;
+ return [] !== $this->launchedProcesses;
}
usleep($this->getOption($state, 'sleep_on_finalize_interval'));
@@ -209,7 +209,7 @@ function (Options $options, $value) {
$resolver->setAllowedTypes('sleep_interval', ['integer', 'double']);
$resolver->setAllowedTypes('sleep_interval_after_launch', ['integer', 'double']);
$resolver->setAllowedTypes('sleep_on_finalize_interval', ['integer', 'double']);
- $microsecondNormalizer = fn (Options $options, $value): int => (int) ($value * 1_000_000);
+ $microsecondNormalizer = static fn (Options $options, $value): int => (int) ($value * 1_000_000);
$resolver->setNormalizer('sleep_interval', $microsecondNormalizer);
$resolver->setNormalizer('sleep_interval_after_launch', $microsecondNormalizer);
$resolver->setNormalizer('sleep_on_finalize_interval', $microsecondNormalizer);
diff --git a/src/Task/PropertyGetterTask.php b/src/Task/PropertyGetterTask.php
index a898f4ea..10d97f85 100644
--- a/src/Task/PropertyGetterTask.php
+++ b/src/Task/PropertyGetterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -26,7 +26,7 @@ class PropertyGetterTask extends AbstractConfigurableTask
{
public function __construct(
protected LoggerInterface $logger,
- protected PropertyAccessorInterface $accessor
+ protected PropertyAccessorInterface $accessor,
) {
}
diff --git a/src/Task/PropertySetterTask.php b/src/Task/PropertySetterTask.php
index 56be23f8..2117b4c9 100644
--- a/src/Task/PropertySetterTask.php
+++ b/src/Task/PropertySetterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -26,7 +26,7 @@ class PropertySetterTask extends AbstractConfigurableTask
{
public function __construct(
protected LoggerInterface $logger,
- protected PropertyAccessorInterface $accessor
+ protected PropertyAccessorInterface $accessor,
) {
}
diff --git a/src/Task/Reporting/AdvancedStatCounterTask.php b/src/Task/Reporting/AdvancedStatCounterTask.php
index fed1243c..e7d85b16 100644
--- a/src/Task/Reporting/AdvancedStatCounterTask.php
+++ b/src/Task/Reporting/AdvancedStatCounterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -32,14 +32,14 @@ class AdvancedStatCounterTask extends AbstractConfigurableTask
protected int $preInitCounter = 0;
public function __construct(
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
}
public function execute(ProcessState $state): void
{
$now = new \DateTime();
- if (!$this->startedAt) {
+ if (!$this->startedAt instanceof \DateTime) {
$this->startedAt = $now;
$this->lastUpdate = $now;
}
diff --git a/src/Task/Reporting/LoggerTask.php b/src/Task/Reporting/LoggerTask.php
index dc73bbd9..f990a2c6 100644
--- a/src/Task/Reporting/LoggerTask.php
+++ b/src/Task/Reporting/LoggerTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -28,7 +28,7 @@ class LoggerTask extends AbstractConfigurableTask
{
public function __construct(
protected LoggerInterface $logger,
- protected PropertyAccessorInterface $accessor
+ protected PropertyAccessorInterface $accessor,
) {
}
diff --git a/src/Task/Reporting/StatCounterTask.php b/src/Task/Reporting/StatCounterTask.php
index 21bc005d..c12285c1 100644
--- a/src/Task/Reporting/StatCounterTask.php
+++ b/src/Task/Reporting/StatCounterTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -25,7 +25,7 @@ class StatCounterTask implements FinalizableTaskInterface
protected int $counter = 0;
public function __construct(
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
}
diff --git a/src/Task/RowAggregatorTask.php b/src/Task/RowAggregatorTask.php
index 163b1bfc..c43317d3 100644
--- a/src/Task/RowAggregatorTask.php
+++ b/src/Task/RowAggregatorTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -31,7 +31,7 @@ class RowAggregatorTask extends AbstractConfigurableTask implements BlockingTask
protected array $result = [];
public function __construct(
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
}
diff --git a/src/Task/Serialization/DenormalizerTask.php b/src/Task/Serialization/DenormalizerTask.php
index 975b573a..6edecc00 100644
--- a/src/Task/Serialization/DenormalizerTask.php
+++ b/src/Task/Serialization/DenormalizerTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -24,7 +24,7 @@
class DenormalizerTask extends AbstractConfigurableTask
{
public function __construct(
- protected DenormalizerInterface $denormalizer
+ protected DenormalizerInterface $denormalizer,
) {
}
diff --git a/src/Task/Serialization/DeserializerTask.php b/src/Task/Serialization/DeserializerTask.php
index 1287eeff..654a535d 100644
--- a/src/Task/Serialization/DeserializerTask.php
+++ b/src/Task/Serialization/DeserializerTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -21,7 +21,7 @@
class DeserializerTask extends AbstractConfigurableTask
{
public function __construct(
- protected SerializerInterface $serializer
+ protected SerializerInterface $serializer,
) {
}
diff --git a/src/Task/Serialization/NormalizerTask.php b/src/Task/Serialization/NormalizerTask.php
index 2e7d43d3..8c43ed1b 100644
--- a/src/Task/Serialization/NormalizerTask.php
+++ b/src/Task/Serialization/NormalizerTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -24,7 +24,7 @@
class NormalizerTask extends AbstractConfigurableTask
{
public function __construct(
- protected NormalizerInterface $normalizer
+ protected NormalizerInterface $normalizer,
) {
}
diff --git a/src/Task/Serialization/SerializerTask.php b/src/Task/Serialization/SerializerTask.php
index 054208cb..644447b0 100644
--- a/src/Task/Serialization/SerializerTask.php
+++ b/src/Task/Serialization/SerializerTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -21,7 +21,7 @@
class SerializerTask extends AbstractConfigurableTask
{
public function __construct(
- protected SerializerInterface $serializer
+ protected SerializerInterface $serializer,
) {
}
diff --git a/src/Task/SimpleBatchTask.php b/src/Task/SimpleBatchTask.php
index e0173bc7..b022dd70 100644
--- a/src/Task/SimpleBatchTask.php
+++ b/src/Task/SimpleBatchTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -27,7 +27,7 @@ class SimpleBatchTask extends AbstractConfigurableTask implements FlushableTaskI
public function flush(ProcessState $state): void
{
- if (0 === \count($this->elements)) {
+ if ([] === $this->elements) {
$state->setSkipped(true);
} else {
$state->setOutput($this->elements);
diff --git a/src/Task/SkipEmptyTask.php b/src/Task/SkipEmptyTask.php
index b649864a..1663e28f 100644
--- a/src/Task/SkipEmptyTask.php
+++ b/src/Task/SkipEmptyTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/SplitJoinLineTask.php b/src/Task/SplitJoinLineTask.php
index 6079d851..9b6a614a 100644
--- a/src/Task/SplitJoinLineTask.php
+++ b/src/Task/SplitJoinLineTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -21,6 +21,7 @@
*/
class SplitJoinLineTask extends AbstractIterableOutputTask
{
+ #[\Override]
public function next(ProcessState $state): bool
{
$valid = parent::next($state);
diff --git a/src/Task/StopTask.php b/src/Task/StopTask.php
index c7ab909a..c8945cd8 100644
--- a/src/Task/StopTask.php
+++ b/src/Task/StopTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Task/TransformerTask.php b/src/Task/TransformerTask.php
index 64502a71..f04d8832 100644
--- a/src/Task/TransformerTask.php
+++ b/src/Task/TransformerTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -33,7 +33,7 @@ class TransformerTask extends AbstractConfigurableTask
public function __construct(
protected LoggerInterface $logger,
- TransformerRegistry $transformerRegistry
+ TransformerRegistry $transformerRegistry,
) {
$this->transformerRegistry = $transformerRegistry;
}
diff --git a/src/Task/Validation/ValidatorTask.php b/src/Task/Validation/ValidatorTask.php
index efd82b10..ae7510b6 100644
--- a/src/Task/Validation/ValidatorTask.php
+++ b/src/Task/Validation/ValidatorTask.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -30,7 +30,7 @@ class ValidatorTask extends AbstractConfigurableTask
{
public function __construct(
protected LoggerInterface $logger,
- protected ValidatorInterface $validator
+ protected ValidatorInterface $validator,
) {
}
diff --git a/src/Transformer/ArrayElementTransformer.php b/src/Transformer/Array/ArrayElementTransformer.php
similarity index 84%
rename from src/Transformer/ArrayElementTransformer.php
rename to src/Transformer/Array/ArrayElementTransformer.php
index 86cff75e..933e12a8 100644
--- a/src/Transformer/ArrayElementTransformer.php
+++ b/src/Transformer/Array/ArrayElementTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Array;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/ArrayFilterTransformer.php b/src/Transformer/Array/ArrayFilterTransformer.php
similarity index 87%
rename from src/Transformer/ArrayFilterTransformer.php
rename to src/Transformer/Array/ArrayFilterTransformer.php
index 2a942149..a755a985 100644
--- a/src/Transformer/ArrayFilterTransformer.php
+++ b/src/Transformer/Array/ArrayFilterTransformer.php
@@ -5,14 +5,16 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Array;
+use CleverAge\ProcessBundle\Transformer\ConditionTrait;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
diff --git a/src/Transformer/ArrayFirstTransformer.php b/src/Transformer/Array/ArrayFirstTransformer.php
similarity index 86%
rename from src/Transformer/ArrayFirstTransformer.php
rename to src/Transformer/Array/ArrayFirstTransformer.php
index 9d1f3739..fef817e4 100644
--- a/src/Transformer/ArrayFirstTransformer.php
+++ b/src/Transformer/Array/ArrayFirstTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Array;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/ArrayLastTransformer.php b/src/Transformer/Array/ArrayLastTransformer.php
similarity index 79%
rename from src/Transformer/ArrayLastTransformer.php
rename to src/Transformer/Array/ArrayLastTransformer.php
index e227143e..c2389852 100644
--- a/src/Transformer/ArrayLastTransformer.php
+++ b/src/Transformer/Array/ArrayLastTransformer.php
@@ -5,13 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Array;
+
+use CleverAge\ProcessBundle\Transformer\TransformerInterface;
/**
* Return the last element of an array.
diff --git a/src/Transformer/ArrayMapTransformer.php b/src/Transformer/Array/ArrayMapTransformer.php
similarity index 90%
rename from src/Transformer/ArrayMapTransformer.php
rename to src/Transformer/Array/ArrayMapTransformer.php
index 4e3f7fb3..1263a9f7 100644
--- a/src/Transformer/ArrayMapTransformer.php
+++ b/src/Transformer/Array/ArrayMapTransformer.php
@@ -5,16 +5,18 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Array;
use CleverAge\ProcessBundle\Exception\TransformerException;
use CleverAge\ProcessBundle\Registry\TransformerRegistry;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
+use CleverAge\ProcessBundle\Transformer\TransformerTrait;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/ArrayUnsetTransformer.php b/src/Transformer/Array/ArrayUnsetTransformer.php
similarity index 85%
rename from src/Transformer/ArrayUnsetTransformer.php
rename to src/Transformer/Array/ArrayUnsetTransformer.php
index e4527269..0e2bcf29 100644
--- a/src/Transformer/ArrayUnsetTransformer.php
+++ b/src/Transformer/Array/ArrayUnsetTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Array;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/CachedTransformer.php b/src/Transformer/CachedTransformer.php
index 522fda98..bcdcb38e 100644
--- a/src/Transformer/CachedTransformer.php
+++ b/src/Transformer/CachedTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -30,7 +30,7 @@ class CachedTransformer implements ConfigurableTransformerInterface
public function __construct(
TransformerRegistry $transformerRegistry,
protected CacheItemPoolInterface $cache,
- protected LoggerInterface $logger
+ protected LoggerInterface $logger,
) {
$this->transformerRegistry = $transformerRegistry;
}
@@ -44,7 +44,7 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setAllowedTypes('ttl', ['null', 'string', \DateTimeInterface::class]);
$resolver->setNormalizer(
'ttl',
- function (Options $options, $value) {
+ static function (Options $options, $value) {
/*
* Best use is a relative date string like "+1 hour".
*
@@ -65,7 +65,7 @@ function (Options $options, $value) {
public function transform(mixed $value, array $options = []): mixed
{
$cacheKey = $this->generateCacheKey($options['cache_key'], $value, $options);
- if ($cacheKey && $this->cache instanceof CacheItemPoolInterface) {
+ if ($cacheKey) {
try {
$cacheItem = $this->cache->getItem($cacheKey);
if ($cacheItem->isHit()) {
diff --git a/src/Transformer/CallbackTransformer.php b/src/Transformer/CallbackTransformer.php
index 94e695f8..88e1f275 100644
--- a/src/Transformer/CallbackTransformer.php
+++ b/src/Transformer/CallbackTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/CastTransformer.php b/src/Transformer/CastTransformer.php
index 8b099a5a..559af464 100644
--- a/src/Transformer/CastTransformer.php
+++ b/src/Transformer/CastTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/ConditionTrait.php b/src/Transformer/ConditionTrait.php
index a65bda4d..d5e2dec0 100644
--- a/src/Transformer/ConditionTrait.php
+++ b/src/Transformer/ConditionTrait.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -111,7 +111,7 @@ protected function checkValue(
string $key,
mixed $value,
bool $shouldMatch = true,
- bool $regexpMode = false
+ bool $regexpMode = false,
): bool {
$currentValue = $this->getValue($input, $key);
diff --git a/src/Transformer/ConfigurableTransformerInterface.php b/src/Transformer/ConfigurableTransformerInterface.php
index f5112455..af44c693 100644
--- a/src/Transformer/ConfigurableTransformerInterface.php
+++ b/src/Transformer/ConfigurableTransformerInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/ConstantTransformer.php b/src/Transformer/ConstantTransformer.php
index 9a234fcf..ec0ae7ca 100644
--- a/src/Transformer/ConstantTransformer.php
+++ b/src/Transformer/ConstantTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/ConvertValueTransformer.php b/src/Transformer/ConvertValueTransformer.php
index fc974174..e9a7775b 100644
--- a/src/Transformer/ConvertValueTransformer.php
+++ b/src/Transformer/ConvertValueTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/DateFormatTransformer.php b/src/Transformer/Date/DateFormatTransformer.php
similarity index 89%
rename from src/Transformer/DateFormatTransformer.php
rename to src/Transformer/Date/DateFormatTransformer.php
index 464ae658..e60324a0 100644
--- a/src/Transformer/DateFormatTransformer.php
+++ b/src/Transformer/Date/DateFormatTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Date;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/DateParserTransformer.php b/src/Transformer/Date/DateParserTransformer.php
similarity index 88%
rename from src/Transformer/DateParserTransformer.php
rename to src/Transformer/Date/DateParserTransformer.php
index 9553e1f6..a891ff40 100644
--- a/src/Transformer/DateParserTransformer.php
+++ b/src/Transformer/Date/DateParserTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Date;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/DebugTransformer.php b/src/Transformer/DebugTransformer.php
index 9d6bcfc2..16f11174 100644
--- a/src/Transformer/DebugTransformer.php
+++ b/src/Transformer/DebugTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/DefaultTransformer.php b/src/Transformer/DefaultTransformer.php
index 1ce9b633..96a847be 100644
--- a/src/Transformer/DefaultTransformer.php
+++ b/src/Transformer/DefaultTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/EvaluatorTransformer.php b/src/Transformer/EvaluatorTransformer.php
index 9a33db73..33ceba2b 100644
--- a/src/Transformer/EvaluatorTransformer.php
+++ b/src/Transformer/EvaluatorTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/ExpressionLanguageMapTransformer.php b/src/Transformer/ExpressionLanguageMapTransformer.php
index 9bfb65b0..0356e9a3 100644
--- a/src/Transformer/ExpressionLanguageMapTransformer.php
+++ b/src/Transformer/ExpressionLanguageMapTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -24,7 +24,7 @@
class ExpressionLanguageMapTransformer implements ConfigurableTransformerInterface
{
public function __construct(
- protected ExpressionLanguage $language
+ protected ExpressionLanguage $language,
) {
}
diff --git a/src/Transformer/GenericTransformer.php b/src/Transformer/GenericTransformer.php
index e033e281..f1863aa4 100644
--- a/src/Transformer/GenericTransformer.php
+++ b/src/Transformer/GenericTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -33,7 +33,7 @@ class GenericTransformer implements ConfigurableTransformerInterface
public function __construct(
protected ContextualOptionResolver $contextualOptionResolver,
- TransformerRegistry $transformerRegistry
+ TransformerRegistry $transformerRegistry,
) {
$this->transformerRegistry = $transformerRegistry;
}
diff --git a/src/Transformer/MappingTransformer.php b/src/Transformer/MappingTransformer.php
index 3ed3bc4e..ff8b0001 100644
--- a/src/Transformer/MappingTransformer.php
+++ b/src/Transformer/MappingTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -32,7 +32,7 @@ class MappingTransformer implements ConfigurableTransformerInterface
public function __construct(
TransformerRegistry $transformerRegistry,
protected LoggerInterface $logger,
- protected PropertyAccessorInterface $accessor
+ protected PropertyAccessorInterface $accessor,
) {
$this->transformerRegistry = $transformerRegistry;
}
diff --git a/src/Transformer/MultiReplaceTransformer.php b/src/Transformer/MultiReplaceTransformer.php
index 90d87424..5ff4b927 100644
--- a/src/Transformer/MultiReplaceTransformer.php
+++ b/src/Transformer/MultiReplaceTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/InstantiateTransformer.php b/src/Transformer/Object/InstantiateTransformer.php
similarity index 86%
rename from src/Transformer/InstantiateTransformer.php
rename to src/Transformer/Object/InstantiateTransformer.php
index 8da6c2f8..41993a58 100644
--- a/src/Transformer/InstantiateTransformer.php
+++ b/src/Transformer/Object/InstantiateTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Object;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/PropertyAccessorTransformer.php b/src/Transformer/Object/PropertyAccessorTransformer.php
similarity index 88%
rename from src/Transformer/PropertyAccessorTransformer.php
rename to src/Transformer/Object/PropertyAccessorTransformer.php
index 4e37c2fc..90e59b29 100644
--- a/src/Transformer/PropertyAccessorTransformer.php
+++ b/src/Transformer/Object/PropertyAccessorTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Object;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
@@ -22,7 +23,7 @@
class PropertyAccessorTransformer implements ConfigurableTransformerInterface
{
public function __construct(
- protected PropertyAccessorInterface $accessor
+ protected PropertyAccessorInterface $accessor,
) {
}
diff --git a/src/Transformer/RecursivePropertySetterTransformer.php b/src/Transformer/Object/RecursivePropertySetterTransformer.php
similarity index 93%
rename from src/Transformer/RecursivePropertySetterTransformer.php
rename to src/Transformer/Object/RecursivePropertySetterTransformer.php
index 9d06e256..b42c1df7 100644
--- a/src/Transformer/RecursivePropertySetterTransformer.php
+++ b/src/Transformer/Object/RecursivePropertySetterTransformer.php
@@ -5,15 +5,16 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Object;
use CleverAge\ProcessBundle\Exception\TransformerException;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
@@ -24,7 +25,7 @@
class RecursivePropertySetterTransformer implements ConfigurableTransformerInterface
{
public function __construct(
- protected PropertyAccessorInterface $accessor
+ protected PropertyAccessorInterface $accessor,
) {
}
diff --git a/src/Transformer/PregFilterTransformer.php b/src/Transformer/PregFilterTransformer.php
index 5a6d4f11..361dd119 100644
--- a/src/Transformer/PregFilterTransformer.php
+++ b/src/Transformer/PregFilterTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/RulesTransformer.php b/src/Transformer/RulesTransformer.php
index 4e19338c..7ef7d4e2 100644
--- a/src/Transformer/RulesTransformer.php
+++ b/src/Transformer/RulesTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -28,7 +28,7 @@ class RulesTransformer implements ConfigurableTransformerInterface
public function __construct(
TransformerRegistry $transformerRegistry,
- protected ExpressionLanguage $language
+ protected ExpressionLanguage $language,
) {
$this->transformerRegistry = $transformerRegistry;
}
@@ -93,7 +93,7 @@ public function configureOptions(OptionsResolver $resolver): void
/**
* Configure options for one "rule" block.
*/
- public function configureRuleOptions(OptionsResolver $resolver, array $expressionVariables = null): void
+ public function configureRuleOptions(OptionsResolver $resolver, ?array $expressionVariables = null): void
{
$resolver->setDefaults([
'condition' => null,
@@ -114,7 +114,7 @@ public function configureRuleOptions(OptionsResolver $resolver, array $expressio
};
$resolver->setNormalizer('condition', $expressionNormalizer);
- $resolver->setNormalizer('default', function (Options $options, $value) {
+ $resolver->setNormalizer('default', static function (Options $options, $value) {
if ($value && $options['condition']) {
throw new \InvalidArgumentException('A rule cannot have a condition and be the default in the same time');
}
diff --git a/src/Transformer/DenormalizeTransformer.php b/src/Transformer/Serialization/DenormalizeTransformer.php
similarity index 85%
rename from src/Transformer/DenormalizeTransformer.php
rename to src/Transformer/Serialization/DenormalizeTransformer.php
index 529f7dfb..f939b074 100644
--- a/src/Transformer/DenormalizeTransformer.php
+++ b/src/Transformer/Serialization/DenormalizeTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Serialization;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
@@ -22,7 +23,7 @@
class DenormalizeTransformer implements ConfigurableTransformerInterface
{
public function __construct(
- protected DenormalizerInterface $denormalizer
+ protected DenormalizerInterface $denormalizer,
) {
}
diff --git a/src/Transformer/NormalizeTransformer.php b/src/Transformer/Serialization/NormalizeTransformer.php
similarity index 84%
rename from src/Transformer/NormalizeTransformer.php
rename to src/Transformer/Serialization/NormalizeTransformer.php
index 5cd57635..f23293a6 100644
--- a/src/Transformer/NormalizeTransformer.php
+++ b/src/Transformer/Serialization/NormalizeTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\Serialization;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
@@ -22,7 +23,7 @@
class NormalizeTransformer implements ConfigurableTransformerInterface
{
public function __construct(
- protected NormalizerInterface $normalizer
+ protected NormalizerInterface $normalizer,
) {
}
diff --git a/src/Transformer/ExplodeTransformer.php b/src/Transformer/String/ExplodeTransformer.php
similarity index 86%
rename from src/Transformer/ExplodeTransformer.php
rename to src/Transformer/String/ExplodeTransformer.php
index 65b79427..32542a43 100644
--- a/src/Transformer/ExplodeTransformer.php
+++ b/src/Transformer/String/ExplodeTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\String;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/HashTransformer.php b/src/Transformer/String/HashTransformer.php
similarity index 86%
rename from src/Transformer/HashTransformer.php
rename to src/Transformer/String/HashTransformer.php
index c1fc610f..4082b845 100644
--- a/src/Transformer/HashTransformer.php
+++ b/src/Transformer/String/HashTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\String;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/ImplodeTransformer.php b/src/Transformer/String/ImplodeTransformer.php
similarity index 86%
rename from src/Transformer/ImplodeTransformer.php
rename to src/Transformer/String/ImplodeTransformer.php
index fb08288e..e005c67c 100644
--- a/src/Transformer/ImplodeTransformer.php
+++ b/src/Transformer/String/ImplodeTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\String;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/String/PregMatchTransformer.php b/src/Transformer/String/PregMatchTransformer.php
new file mode 100644
index 00000000..143ba36b
--- /dev/null
+++ b/src/Transformer/String/PregMatchTransformer.php
@@ -0,0 +1,58 @@
+setRequired(['pattern']);
+ $resolver->setAllowedTypes('pattern', ['string']);
+ $resolver->setDefault('flags', 0);
+ $resolver->setAllowedTypes('flags', ['int']);
+ $resolver->setDefault('offset', 0);
+ $resolver->setAllowedTypes('offset', ['int']);
+ $resolver->setDefault('mode_all', false);
+ $resolver->setAllowedTypes('mode_all', ['boolean']);
+ }
+}
diff --git a/src/Transformer/SlugifyTransformer.php b/src/Transformer/String/SlugifyTransformer.php
similarity index 89%
rename from src/Transformer/SlugifyTransformer.php
rename to src/Transformer/String/SlugifyTransformer.php
index 491eb52f..7d23bf92 100644
--- a/src/Transformer/SlugifyTransformer.php
+++ b/src/Transformer/String/SlugifyTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\String;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -28,7 +29,7 @@ public function transform(mixed $value, array $options = []): string
$string = $transliterator->transliterate($value);
return trim(
- preg_replace(
+ (string) preg_replace(
$options['replace'],
(string) $options['separator'],
strtolower(trim(strip_tags($string)))
diff --git a/src/Transformer/SprintfTransformer.php b/src/Transformer/String/SprintfTransformer.php
similarity index 86%
rename from src/Transformer/SprintfTransformer.php
rename to src/Transformer/String/SprintfTransformer.php
index e496d193..7013c72b 100644
--- a/src/Transformer/SprintfTransformer.php
+++ b/src/Transformer/String/SprintfTransformer.php
@@ -5,14 +5,15 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\String;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/TrimTransformer.php b/src/Transformer/String/TrimTransformer.php
similarity index 88%
rename from src/Transformer/TrimTransformer.php
rename to src/Transformer/String/TrimTransformer.php
index f9966f7d..95627dd6 100644
--- a/src/Transformer/TrimTransformer.php
+++ b/src/Transformer/String/TrimTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -13,8 +13,9 @@
namespace Transformer;
-namespace CleverAge\ProcessBundle\Transformer;
+namespace CleverAge\ProcessBundle\Transformer\String;
+use CleverAge\ProcessBundle\Transformer\ConfigurableTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
diff --git a/src/Transformer/TransformerInterface.php b/src/Transformer/TransformerInterface.php
index 34cd402b..7cf44d54 100644
--- a/src/Transformer/TransformerInterface.php
+++ b/src/Transformer/TransformerInterface.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/TransformerTrait.php b/src/Transformer/TransformerTrait.php
index e3874aa0..4bea4f87 100644
--- a/src/Transformer/TransformerTrait.php
+++ b/src/Transformer/TransformerTrait.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -52,7 +52,7 @@ public function normalizeTransformers(Options $options, array $transformers): ar
protected function applyTransformers(array $transformers, mixed $value): mixed
{
// Quick return for better perfs
- if (empty($transformers)) {
+ if ([] === $transformers) {
return $value;
}
@@ -92,7 +92,7 @@ protected function getCleanedTransfomerCode(string $transformerCode): string
protected function configureTransformersOptions(
OptionsResolver $resolver,
- string $optionName = 'transformers'
+ string $optionName = 'transformers',
): void {
$resolver->setDefault($optionName, []);
$resolver->setAllowedTypes($optionName, ['array']);
diff --git a/src/Transformer/TypeSetterTransformer.php b/src/Transformer/TypeSetterTransformer.php
index a9e621fc..64804d8a 100644
--- a/src/Transformer/TypeSetterTransformer.php
+++ b/src/Transformer/TypeSetterTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -32,7 +32,7 @@ public function transform(mixed $value, array $options = []): mixed
{
$return = settype($value, $options['type']);
- if (true === $return) {
+ if ($return) {
return $value;
}
diff --git a/src/Transformer/UnsetTransformer.php b/src/Transformer/UnsetTransformer.php
index 05d98d60..112f4ad0 100644
--- a/src/Transformer/UnsetTransformer.php
+++ b/src/Transformer/UnsetTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/WrapperTransformer.php b/src/Transformer/WrapperTransformer.php
index 6f55e294..297e7253 100644
--- a/src/Transformer/WrapperTransformer.php
+++ b/src/Transformer/WrapperTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/src/Transformer/Xml/XpathEvaluatorTransformer.php b/src/Transformer/Xml/XpathEvaluatorTransformer.php
index e4952d21..74b378a4 100644
--- a/src/Transformer/Xml/XpathEvaluatorTransformer.php
+++ b/src/Transformer/Xml/XpathEvaluatorTransformer.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -65,15 +65,15 @@ public function configureOptions(OptionsResolver $resolver): void
* Configure options about how to handle xpath query results.
* Available at root and subquery level.
*/
- public function configureQueryOptions(OptionsResolver $resolver, Options $parentOptions = null): void
+ public function configureQueryOptions(OptionsResolver $resolver, ?Options $parentOptions = null): void
{
- $resolver->setDefault('single_result', $parentOptions ? $parentOptions['single_result'] : true);
+ $resolver->setDefault('single_result', $parentOptions instanceof Options ? $parentOptions['single_result'] : true);
$resolver->setAllowedTypes('single_result', 'bool');
- $resolver->setDefault('ignore_missing', $parentOptions ? $parentOptions['ignore_missing'] : true);
+ $resolver->setDefault('ignore_missing', $parentOptions instanceof Options ? $parentOptions['ignore_missing'] : true);
$resolver->setAllowedTypes('ignore_missing', 'bool');
- $resolver->setDefault('unwrap_value', $parentOptions ? $parentOptions['unwrap_value'] : true);
+ $resolver->setDefault('unwrap_value', $parentOptions instanceof Options ? $parentOptions['unwrap_value'] : true);
$resolver->setAllowedTypes('unwrap_value', 'bool');
}
@@ -137,15 +137,11 @@ public function query(\DOMXPath $xpath, string $query, \DOMNode $node, array $op
throw new \UnexpectedValueException("There is too much results for query '{$query}'");
}
- if (!$options['ignore_missing'] && 0 === \count($results)) {
+ if (!$options['ignore_missing'] && [] === $results) {
throw new \UnexpectedValueException("There is not enough results for query '{$query}'");
}
- if (1 === \count($results)) {
- $results = $results[0];
- } else {
- $results = null;
- }
+ $results = 1 === \count($results) ? $results[0] : null;
}
return $results;
diff --git a/src/Validator/ConstraintLoader.php b/src/Validator/ConstraintLoader.php
index d767dc15..e2adab9b 100644
--- a/src/Validator/ConstraintLoader.php
+++ b/src/Validator/ConstraintLoader.php
@@ -5,7 +5,7 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
diff --git a/tests.old/ProcessManagerTest.php b/tests.old/ProcessManagerTest.php
index 42c49450..3d019b5e 100644
--- a/tests.old/ProcessManagerTest.php
+++ b/tests.old/ProcessManagerTest.php
@@ -21,7 +21,7 @@
use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry;
use Prophecy\Argument\Token\TypeToken;
use Prophecy\Prophecy\MethodProphecy;
-use Psr\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class ProcessManagerTest extends AbstractProcessTest
{
diff --git a/tests/Exception/MissingTransformerExceptionTest.php b/tests/Exception/MissingTransformerExceptionTest.php
index fad77c86..41d3628b 100644
--- a/tests/Exception/MissingTransformerExceptionTest.php
+++ b/tests/Exception/MissingTransformerExceptionTest.php
@@ -2,19 +2,24 @@
declare(strict_types=1);
+/*
+ * This file is part of the CleverAge/ProcessBundle package.
+ *
+ * Copyright (c) Clever-Age
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
namespace Exception;
use CleverAge\ProcessBundle\Exception\MissingTransformerException;
use PHPUnit\Framework\TestCase;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Exception\MissingTransformerException
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(MissingTransformerException::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(MissingTransformerException::class, 'create')]
class MissingTransformerExceptionTest extends TestCase
{
- /**
- * @covers ::create
- */
public function testCreate(): void
{
$exception = MissingTransformerException::create('my_transformer');
diff --git a/tests/Transformer/ArrayElementTransformerTest.php b/tests/Transformer/Array/ArrayElementTransformerTest.php
similarity index 71%
rename from tests/Transformer/ArrayElementTransformerTest.php
rename to tests/Transformer/Array/ArrayElementTransformerTest.php
index 6895a9c8..0d0cd18c 100644
--- a/tests/Transformer/ArrayElementTransformerTest.php
+++ b/tests/Transformer/Array/ArrayElementTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer\Array;
-use CleverAge\ProcessBundle\Transformer\ArrayElementTransformer;
+use CleverAge\ProcessBundle\Transformer\Array\ArrayElementTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\ArrayElementTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(ArrayElementTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ArrayElementTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ArrayElementTransformer::class, 'configureOptions')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ArrayElementTransformer::class, 'getCode')]
class ArrayElementTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransformReturnsNthElementFromArray(): void
{
$transformer = new ArrayElementTransformer();
@@ -36,9 +34,6 @@ public function testTransformReturnsNthElementFromArray(): void
$this->assertEquals('bar', $result);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptionsSetsRequiredOptions(): void
{
$resolver = new OptionsResolver();
@@ -52,9 +47,6 @@ public function testConfigureOptionsSetsRequiredOptions(): void
$this->assertEquals(['index'], array_keys($resolvedOptions));
}
- /**
- * @covers ::getCode
- */
public function testGetCodeReturnsCorrectCode(): void
{
$transformer = new ArrayElementTransformer();
diff --git a/tests/Transformer/ArrayFirstTransformerTest.php b/tests/Transformer/Array/ArrayFirstTransformerTest.php
similarity index 80%
rename from tests/Transformer/ArrayFirstTransformerTest.php
rename to tests/Transformer/Array/ArrayFirstTransformerTest.php
index 07b87049..611d3923 100644
--- a/tests/Transformer/ArrayFirstTransformerTest.php
+++ b/tests/Transformer/Array/ArrayFirstTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer\Array;
-use CleverAge\ProcessBundle\Transformer\ArrayFirstTransformer;
+use CleverAge\ProcessBundle\Transformer\Array\ArrayFirstTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\ArrayFirstTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(ArrayFirstTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ArrayFirstTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ArrayFirstTransformer::class, 'getCode')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ArrayFirstTransformer::class, 'configureOptions')]
class ArrayFirstTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransformReturnsFirstElementIfIterableAndAllowed(): void
{
$transformer = new ArrayFirstTransformer();
@@ -36,9 +34,6 @@ public function testTransformReturnsFirstElementIfIterableAndAllowed(): void
$this->assertEquals(1, $result);
}
- /**
- * @covers ::transform
- */
public function testTransformReturnsValueIfNotIterableAndAllowed(): void
{
$this->expectException(\TypeError::class);
@@ -52,9 +47,6 @@ public function testTransformReturnsValueIfNotIterableAndAllowed(): void
$this->assertEquals('not_iterable_value', $result);
}
- /**
- * @covers ::transform
- */
public function testTransformThrowsExceptionIfNotIterableAndNotAllowed(): void
{
$transformer = new ArrayFirstTransformer();
@@ -66,9 +58,6 @@ public function testTransformThrowsExceptionIfNotIterableAndNotAllowed(): void
$this->assertEquals($value, $result);
}
- /**
- * @covers ::getCode
- */
public function testGetCodeReturnsCorrectCode(): void
{
$transformer = new ArrayFirstTransformer();
@@ -78,9 +67,6 @@ public function testGetCodeReturnsCorrectCode(): void
$this->assertEquals('array_first', $code);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptionsSetsDefaultOptions(): void
{
$resolver = new OptionsResolver();
diff --git a/tests/Transformer/CastTransformerTest.php b/tests/Transformer/CastTransformerTest.php
index 5a667646..7470a1d0 100644
--- a/tests/Transformer/CastTransformerTest.php
+++ b/tests/Transformer/CastTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer;
use CleverAge\ProcessBundle\Transformer\CastTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\CastTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(CastTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(CastTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(CastTransformer::class, 'configureOptions')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(CastTransformer::class, 'getCode')]
class CastTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testCastToInt(): void
{
$transformer = new CastTransformer();
@@ -37,9 +35,6 @@ public function testCastToInt(): void
$this->assertEquals(123, $transformedValue);
}
- /**
- * @covers ::transform
- */
public function testCastToFloat(): void
{
$transformer = new CastTransformer();
@@ -52,9 +47,6 @@ public function testCastToFloat(): void
$this->assertEquals(123.45, $transformedValue);
}
- /**
- * @covers ::transform
- */
public function testCastToString(): void
{
$transformer = new CastTransformer();
@@ -67,9 +59,6 @@ public function testCastToString(): void
$this->assertEquals('123', $transformedValue);
}
- /**
- * @covers ::transform
- */
public function testCastToBool(): void
{
$transformer = new CastTransformer();
@@ -82,9 +71,6 @@ public function testCastToBool(): void
$this->assertTrue($transformedValue);
}
- /**
- * @covers ::transform
- */
public function testCastToInvalidType(): void
{
$transformer = new CastTransformer();
@@ -96,9 +82,6 @@ public function testCastToInvalidType(): void
$transformer->transform($value, $options);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptionsSetsRequiredOptions(): void
{
$resolver = new OptionsResolver();
@@ -112,9 +95,6 @@ public function testConfigureOptionsSetsRequiredOptions(): void
$this->assertEquals(['type'], array_keys($resolvedOptions));
}
- /**
- * @covers ::getCode
- */
public function testGetCodeReturnsCorrectCode(): void
{
$transformer = new CastTransformer();
diff --git a/tests/Transformer/ConstantTransformerTest.php b/tests/Transformer/ConstantTransformerTest.php
index 9d291e37..edabdf33 100644
--- a/tests/Transformer/ConstantTransformerTest.php
+++ b/tests/Transformer/ConstantTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer;
use CleverAge\ProcessBundle\Transformer\ConstantTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\ConstantTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(ConstantTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ConstantTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ConstantTransformer::class, 'configureOptions')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ConstantTransformer::class, 'getCode')]
class ConstantTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransform(): void
{
$transformer = new ConstantTransformer();
@@ -36,9 +34,6 @@ public function testTransform(): void
$this->assertEquals('default_value', $transformedValue);
}
- /**
- * @covers ::transform
- */
public function testTransformWithNullValue(): void
{
$transformer = new ConstantTransformer();
@@ -50,9 +45,6 @@ public function testTransformWithNullValue(): void
$this->assertEquals('default_value', $transformedValue);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptions(): void
{
$transformer = new ConstantTransformer();
@@ -63,9 +55,6 @@ public function testConfigureOptions(): void
$this->assertTrue($resolver->isRequired('constant'));
}
- /**
- * @covers ::getCode
- */
public function testGetCodeReturnsCorrectCode(): void
{
$transformer = new ConstantTransformer();
diff --git a/tests/Transformer/DateFormatTransformerTest.php b/tests/Transformer/Date/DateFormatTransformerTest.php
similarity index 80%
rename from tests/Transformer/DateFormatTransformerTest.php
rename to tests/Transformer/Date/DateFormatTransformerTest.php
index 6baf4821..54bdfb4d 100644
--- a/tests/Transformer/DateFormatTransformerTest.php
+++ b/tests/Transformer/Date/DateFormatTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer\Date;
-use CleverAge\ProcessBundle\Transformer\DateFormatTransformer;
+use CleverAge\ProcessBundle\Transformer\Date\DateFormatTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\DateFormatTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(DateFormatTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DateFormatTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DateFormatTransformer::class, 'getCode')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DateFormatTransformer::class, 'configureOptions')]
class DateFormatTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransformValidDate(): void
{
$transformer = new DateFormatTransformer();
@@ -37,9 +35,6 @@ public function testTransformValidDate(): void
$this->assertEquals('2023-09-28', $transformedValue);
}
- /**
- * @covers ::transform
- */
public function testTransformInvalidDate(): void
{
$transformer = new DateFormatTransformer();
@@ -51,9 +46,6 @@ public function testTransformInvalidDate(): void
$transformer->transform($value, $options);
}
- /**
- * @covers ::transform
- */
public function testTransformNullValue(): void
{
// Arrange
@@ -66,9 +58,6 @@ public function testTransformNullValue(): void
$this->assertNull($transformedValue);
}
- /**
- * @covers ::getCode
- */
public function testGetCode(): void
{
$transformer = new DateFormatTransformer();
@@ -78,9 +67,6 @@ public function testGetCode(): void
$this->assertEquals('date_format', $code);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptions(): void
{
$transformer = new DateFormatTransformer();
diff --git a/tests/Transformer/DateParserTransformerTest.php b/tests/Transformer/Date/DateParserTransformerTest.php
similarity index 82%
rename from tests/Transformer/DateParserTransformerTest.php
rename to tests/Transformer/Date/DateParserTransformerTest.php
index 7ac7a7d6..5cb330f7 100644
--- a/tests/Transformer/DateParserTransformerTest.php
+++ b/tests/Transformer/Date/DateParserTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer\Date;
-use CleverAge\ProcessBundle\Transformer\DateParserTransformer;
+use CleverAge\ProcessBundle\Transformer\Date\DateParserTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\DateParserTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(DateParserTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DateParserTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DateParserTransformer::class, 'getCode')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DateParserTransformer::class, 'configureOptions')]
class DateParserTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransformValidDate(): void
{
$transformer = new DateParserTransformer();
@@ -37,9 +35,6 @@ public function testTransformValidDate(): void
$this->assertEquals('2023-09-28', $transformedValue->format('Y-m-d'));
}
- /**
- * @covers ::transform
- */
public function testTransformInvalidDate(): void
{
$transformer = new DateParserTransformer();
@@ -51,9 +46,6 @@ public function testTransformInvalidDate(): void
$transformer->transform($value, $options);
}
- /**
- * @covers ::transform
- */
public function testTransformNullValue(): void
{
$transformer = new DateParserTransformer();
@@ -65,9 +57,6 @@ public function testTransformNullValue(): void
$this->assertNull($transformedValue);
}
- /**
- * @covers ::transform
- */
public function testTransformDateTimeObject(): void
{
// Arrange
@@ -80,9 +69,6 @@ public function testTransformDateTimeObject(): void
$this->assertSame($value, $transformedValue);
}
- /**
- * @covers ::getCode
- */
public function testGetCode(): void
{
$transformer = new DateParserTransformer();
@@ -92,9 +78,6 @@ public function testGetCode(): void
$this->assertEquals('date_parser', $code);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptions(): void
{
$transformer = new DateParserTransformer();
diff --git a/tests/Transformer/DebugTransformerTest.php b/tests/Transformer/DebugTransformerTest.php
index 5af9744e..b3802db5 100644
--- a/tests/Transformer/DebugTransformerTest.php
+++ b/tests/Transformer/DebugTransformerTest.php
@@ -5,26 +5,23 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer;
use CleverAge\ProcessBundle\Transformer\DebugTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\VarDumper\VarDumper;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\DebugTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(DebugTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DebugTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DebugTransformer::class, 'getCode')]
class DebugTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransform(): void
{
$transformer = new DebugTransformer();
@@ -39,9 +36,6 @@ public function testTransform(): void
}
}
- /**
- * @covers ::getCode
- */
public function testGetCodeReturnsCorrectCode(): void
{
$transformer = new DebugTransformer();
diff --git a/tests/Transformer/DefaultTransformerTest.php b/tests/Transformer/DefaultTransformerTest.php
index 64a71cfe..f4579c9f 100644
--- a/tests/Transformer/DefaultTransformerTest.php
+++ b/tests/Transformer/DefaultTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer;
use CleverAge\ProcessBundle\Transformer\DefaultTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\DefaultTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(DefaultTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DefaultTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DefaultTransformer::class, 'configureOptions')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(DefaultTransformer::class, 'getCode')]
class DefaultTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransformWithNonNullValue(): void
{
$transformer = new DefaultTransformer();
@@ -36,9 +34,6 @@ public function testTransformWithNonNullValue(): void
$this->assertSame($value, $transformedValue);
}
- /**
- * @covers ::transform
- */
public function testTransformWithNullValue(): void
{
$transformer = new DefaultTransformer();
@@ -50,9 +45,6 @@ public function testTransformWithNullValue(): void
$this->assertEquals('default_value', $transformedValue);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptions(): void
{
$resolver = new OptionsResolver();
@@ -66,9 +58,6 @@ public function testConfigureOptions(): void
$this->assertEquals(['value'], array_keys($resolvedOptions));
}
- /**
- * @covers ::getCode
- */
public function testGetCodeReturnsCorrectCode(): void
{
$transformer = new DefaultTransformer();
diff --git a/tests/Transformer/MultiReplaceTransformerTest.php b/tests/Transformer/MultiReplaceTransformerTest.php
index 8a3c58c6..158efe1f 100644
--- a/tests/Transformer/MultiReplaceTransformerTest.php
+++ b/tests/Transformer/MultiReplaceTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer;
use CleverAge\ProcessBundle\Transformer\MultiReplaceTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\MultiReplaceTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(MultiReplaceTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(MultiReplaceTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(MultiReplaceTransformer::class, 'configureOptions')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(MultiReplaceTransformer::class, 'getCode')]
class MultiReplaceTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransform(): void
{
$transformer = new MultiReplaceTransformer();
@@ -41,9 +39,6 @@ public function testTransform(): void
$this->assertEquals('That is a test sentence.', $transformedValue);
}
- /**
- * @covers ::transform
- */
public function testTransformWithEmptyReplaceMapping(): void
{
$transformer = new MultiReplaceTransformer();
@@ -57,9 +52,6 @@ public function testTransformWithEmptyReplaceMapping(): void
$this->assertEquals('This is a test string.', $transformedValue);
}
- /**
- * @covers ::transform
- */
public function testTransformWithNullValue(): void
{
$transformer = new MultiReplaceTransformer();
@@ -76,9 +68,6 @@ public function testTransformWithNullValue(): void
$this->assertEquals('', $transformedValue);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptions(): void
{
$transformer = new MultiReplaceTransformer();
@@ -93,9 +82,6 @@ public function testConfigureOptions(): void
$this->assertEquals(['replace_mapping'], array_keys($resolvedOptions));
}
- /**
- * @covers ::getCode
- */
public function testGetCodeReturnsCorrectCode(): void
{
$transformer = new MultiReplaceTransformer();
diff --git a/tests/Transformer/ExplodeTransformerTest.php b/tests/Transformer/String/ExplodeTransformerTest.php
similarity index 77%
rename from tests/Transformer/ExplodeTransformerTest.php
rename to tests/Transformer/String/ExplodeTransformerTest.php
index b454c27a..41b4afd3 100644
--- a/tests/Transformer/ExplodeTransformerTest.php
+++ b/tests/Transformer/String/ExplodeTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer\String;
-use CleverAge\ProcessBundle\Transformer\ExplodeTransformer;
+use CleverAge\ProcessBundle\Transformer\String\ExplodeTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\ExplodeTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(ExplodeTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ExplodeTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ExplodeTransformer::class, 'getCode')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ExplodeTransformer::class, 'configureOptions')]
class ExplodeTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransform(): void
{
$transformer = new ExplodeTransformer();
@@ -34,9 +32,6 @@ public function testTransform(): void
$this->assertEquals(['1', '2', '3'], $result);
}
- /**
- * @covers ::transform
- */
public function testTransformWithEmptyString(): void
{
$transformer = new ExplodeTransformer();
@@ -46,9 +41,6 @@ public function testTransformWithEmptyString(): void
$this->assertEquals([], $result);
}
- /**
- * @covers ::transform
- */
public function testTransformWithNullValue(): void
{
$transformer = new ExplodeTransformer();
@@ -58,9 +50,6 @@ public function testTransformWithNullValue(): void
$this->assertEquals([], $result);
}
- /**
- * @covers ::getCode
- */
public function testGetCode(): void
{
$transformer = new ExplodeTransformer();
@@ -70,9 +59,6 @@ public function testGetCode(): void
$this->assertEquals('explode', $code);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptions(): void
{
$transformer = new ExplodeTransformer();
diff --git a/tests/Transformer/ImplodeTransformerTest.php b/tests/Transformer/String/ImplodeTransformerTest.php
similarity index 77%
rename from tests/Transformer/ImplodeTransformerTest.php
rename to tests/Transformer/String/ImplodeTransformerTest.php
index 0a3751d4..d15c75e0 100644
--- a/tests/Transformer/ImplodeTransformerTest.php
+++ b/tests/Transformer/String/ImplodeTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer\String;
-use CleverAge\ProcessBundle\Transformer\ImplodeTransformer;
+use CleverAge\ProcessBundle\Transformer\String\ImplodeTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\ImplodeTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(ImplodeTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ImplodeTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ImplodeTransformer::class, 'getCode')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(ImplodeTransformer::class, 'configureOptions')]
class ImplodeTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransform(): void
{
$transformer = new ImplodeTransformer();
@@ -34,9 +32,6 @@ public function testTransform(): void
$this->assertEquals('1,2,3', $result);
}
- /**
- * @covers ::transform
- */
public function testTransformWithInvalidValue(): void
{
$this->expectException(\UnexpectedValueException::class);
@@ -46,9 +41,6 @@ public function testTransformWithInvalidValue(): void
$transformer->transform('invalid_value', ['separator' => ',']);
}
- /**
- * @covers ::transform
- */
public function testTransformWithDefaultSeparator(): void
{
$transformer = new ImplodeTransformer();
@@ -58,9 +50,6 @@ public function testTransformWithDefaultSeparator(): void
$this->assertEquals('1|2|3', $result);
}
- /**
- * @covers ::getCode
- */
public function testGetCode(): void
{
$transformer = new ImplodeTransformer();
@@ -70,9 +59,6 @@ public function testGetCode(): void
$this->assertEquals('implode', $code);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptions(): void
{
$transformer = new ImplodeTransformer();
diff --git a/tests/Transformer/SprintfTransformerTest.php b/tests/Transformer/String/SprintfTransformerTest.php
similarity index 53%
rename from tests/Transformer/SprintfTransformerTest.php
rename to tests/Transformer/String/SprintfTransformerTest.php
index 59397a0f..af8100da 100644
--- a/tests/Transformer/SprintfTransformerTest.php
+++ b/tests/Transformer/String/SprintfTransformerTest.php
@@ -2,19 +2,25 @@
declare(strict_types=1);
-namespace Transformer;
+/*
+ * This file is part of the CleverAge/ProcessBundle package.
+ *
+ * Copyright (c) Clever-Age
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace CleverAge\ProcessBundle\Tests\Transformer\String;
-use CleverAge\ProcessBundle\Transformer\SprintfTransformer;
+use CleverAge\ProcessBundle\Transformer\String\SprintfTransformer;
use PHPUnit\Framework\TestCase;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\SprintfTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(SprintfTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(SprintfTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(SprintfTransformer::class, 'getCode')]
class SprintfTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransform(): void
{
$sprintfTransformer = new SprintfTransformer();
@@ -25,9 +31,6 @@ public function testTransform(): void
$this->assertEquals('foo bar', $result);
}
- /**
- * @covers ::getCode
- */
public function testCode(): void
{
$trimTransformer = new SprintfTransformer();
diff --git a/tests/Transformer/TrimTransformerTest.php b/tests/Transformer/String/TrimTransformerTest.php
similarity index 78%
rename from tests/Transformer/TrimTransformerTest.php
rename to tests/Transformer/String/TrimTransformerTest.php
index 62aca460..962fdacf 100644
--- a/tests/Transformer/TrimTransformerTest.php
+++ b/tests/Transformer/String/TrimTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer\String;
-use CleverAge\ProcessBundle\Transformer\TrimTransformer;
+use CleverAge\ProcessBundle\Transformer\String\TrimTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\TrimTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(TrimTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(TrimTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(TrimTransformer::class, 'getCode')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(TrimTransformer::class, 'configureOptions')]
class TrimTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransformTrimsStringWithDefaultCharlist(): void
{
$transformer = new TrimTransformer();
@@ -35,9 +33,6 @@ public function testTransformTrimsStringWithDefaultCharlist(): void
$this->assertEquals('trim me', $result);
}
- /**
- * @covers ::transform
- */
public function testTransformTrimsStringWithCustomCharlist(): void
{
$transformer = new TrimTransformer();
@@ -49,9 +44,6 @@ public function testTransformTrimsStringWithCustomCharlist(): void
$this->assertEquals('trim me', $result);
}
- /**
- * @covers ::transform
- */
public function testTransformReturnsNullForNullValue(): void
{
$transformer = new TrimTransformer();
@@ -62,9 +54,6 @@ public function testTransformReturnsNullForNullValue(): void
$this->assertNull($result);
}
- /**
- * @covers ::getCode
- */
public function testGetCodeReturnsCorrectCode(): void
{
$transformer = new TrimTransformer();
@@ -74,9 +63,6 @@ public function testGetCodeReturnsCorrectCode(): void
$this->assertEquals('trim', $code);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptionsSetsDefaultOptions(): void
{
$resolver = new OptionsResolver();
diff --git a/tests/Transformer/WrapperTransformerTest.php b/tests/Transformer/WrapperTransformerTest.php
index 4699f7a3..a3bac458 100644
--- a/tests/Transformer/WrapperTransformerTest.php
+++ b/tests/Transformer/WrapperTransformerTest.php
@@ -5,26 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer;
use CleverAge\ProcessBundle\Transformer\WrapperTransformer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\WrapperTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(WrapperTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(WrapperTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(WrapperTransformer::class, 'getCode')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(WrapperTransformer::class, 'configureOptions')]
class WrapperTransformerTest extends TestCase
{
- /**
- * @covers ::transform
- */
public function testTransform(): void
{
$transformer = new WrapperTransformer();
@@ -38,9 +36,6 @@ public function testTransform(): void
$this->assertEquals(['key' => 'my_value'], $transformedValue);
}
- /**
- * @covers ::transform
- */
public function testTransformWithIntegerWrapperKey(): void
{
$transformer = new WrapperTransformer();
@@ -54,9 +49,6 @@ public function testTransformWithIntegerWrapperKey(): void
$this->assertEquals([1 => 'my_value'], $transformedValue);
}
- /**
- * @covers ::transform
- */
public function testTransformWithNullValue(): void
{
$transformer = new WrapperTransformer();
@@ -70,9 +62,6 @@ public function testTransformWithNullValue(): void
$this->assertEquals(['key' => null], $transformedValue);
}
- /**
- * @covers ::getCode
- */
public function testGetCodeReturnsCorrectCode(): void
{
$transformer = new WrapperTransformer();
@@ -82,9 +71,6 @@ public function testGetCodeReturnsCorrectCode(): void
$this->assertEquals('wrapper', $code);
}
- /**
- * @covers ::configureOptions
- */
public function testConfigureOptionsSetsDefaultOptions(): void
{
$resolver = new OptionsResolver();
diff --git a/tests/Transformer/XpathEvaluatorTransformerTest.php b/tests/Transformer/Xml/XpathEvaluatorTransformerTest.php
similarity index 84%
rename from tests/Transformer/XpathEvaluatorTransformerTest.php
rename to tests/Transformer/Xml/XpathEvaluatorTransformerTest.php
index 50fda077..cb1eb488 100644
--- a/tests/Transformer/XpathEvaluatorTransformerTest.php
+++ b/tests/Transformer/Xml/XpathEvaluatorTransformerTest.php
@@ -5,27 +5,24 @@
/*
* This file is part of the CleverAge/ProcessBundle package.
*
- * Copyright (c) 2017-2024 Clever-Age
+ * Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-namespace Transformer;
+namespace CleverAge\ProcessBundle\Tests\Transformer\Xml;
use CleverAge\ProcessBundle\Transformer\Xml\XpathEvaluatorTransformer;
use PHPUnit\Framework\TestCase;
-/**
- * @coversDefaultClass \CleverAge\ProcessBundle\Transformer\Xml\XpathEvaluatorTransformer
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(XpathEvaluatorTransformer::class)]
+#[\PHPUnit\Framework\Attributes\CoversMethod(XpathEvaluatorTransformer::class, 'buildXpath')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(XpathEvaluatorTransformer::class, 'query')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(XpathEvaluatorTransformer::class, 'transform')]
+#[\PHPUnit\Framework\Attributes\CoversMethod(XpathEvaluatorTransformer::class, 'getCode')]
class XpathEvaluatorTransformerTest extends TestCase
{
- /**
- * @covers ::buildXpath
- * @covers ::query
- * @covers ::transform
- */
public function testSimpleQuery(): void
{
$domDocument = new \DOMDocument();
@@ -45,11 +42,6 @@ public function testSimpleQuery(): void
$this->assertEquals('ok', $result);
}
- /**
- * @covers ::buildXpath
- * @covers ::query
- * @covers ::transform
- */
public function testAttributeValueQuery(): void
{
$domDocument = new \DOMDocument();
@@ -62,11 +54,6 @@ public function testAttributeValueQuery(): void
$this->assertEquals('ok', $result);
}
- /**
- * @covers ::buildXpath
- * @covers ::query
- * @covers ::transform
- */
public function testSubQuery(): void
{
$domDocument = new \DOMDocument();
@@ -80,11 +67,6 @@ public function testSubQuery(): void
$this->assertEquals('ok', $result);
}
- /**
- * @covers ::buildXpath
- * @covers ::query
- * @covers ::transform
- */
public function testMultiResults(): void
{
$domDocument = new \DOMDocument();
@@ -99,11 +81,6 @@ public function testMultiResults(): void
$this->assertEquals(['ok1', 'ok2', 'ok3'], $result);
}
- /**
- * @covers ::buildXpath
- * @covers ::query
- * @covers ::transform
- */
public function testMultiResultsAsNodeList(): void
{
$domDocument = new \DOMDocument();
@@ -122,9 +99,6 @@ public function testMultiResultsAsNodeList(): void
self::assertEquals('ok3', $result[2]->textContent);
}
- /**
- * @covers ::getCode
- */
public function testGetCodeReturnsCorrectCode(): void
{
$transformer = new XpathEvaluatorTransformer();