From c51837d101abf262a7a56aa1d014cd6009ee4218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Planchat?= Date: Tue, 21 Nov 2023 17:11:30 +0100 Subject: [PATCH] Updated code to be compatible with php-etl/pipeline-contracts:0.5 --- composer.json | 3 +- composer.lock | 272 +++++++++++++++------------------------ src/Console.php | 40 +++--- src/MemoryState.php | 61 +++++++++ src/Pipeline.php | 38 ++++++ src/Step/MemoryState.php | 54 ++++++++ src/Step/Step.php | 44 +++++++ 7 files changed, 324 insertions(+), 188 deletions(-) create mode 100644 src/MemoryState.php create mode 100644 src/Pipeline.php create mode 100644 src/Step/MemoryState.php create mode 100644 src/Step/Step.php diff --git a/composer.json b/composer.json index 0f9de84..c21cc03 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,7 @@ "require": { "php": "^8.2", "symfony/console": "^6.0", - "php-etl/pipeline-contracts": "0.5.*", - "php-etl/console-state": "*" + "php-etl/pipeline-contracts": "0.5.*" }, "require-dev": { "phpstan/phpstan": "^1.10", diff --git a/composer.lock b/composer.lock index 87d73e3..54cdf6e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "08964316a28e56bca7f1707f16188396", + "content-hash": "d9506237c06df7ff11a018915b134228", "packages": [ { "name": "php-etl/bucket-contracts", @@ -49,7 +49,7 @@ "homepage": "http://kiboko.fr" }, { - "name": "Grégory Planchat", + "name": "Grégory Planchatn rules", "email": "gregory@kiboko.fr" } ], @@ -60,76 +60,18 @@ }, "time": "2023-11-14T14:39:36+00:00" }, - { - "name": "php-etl/console-state", - "version": "v0.3.0", - "source": { - "type": "git", - "url": "https://github.com/php-etl/console-state.git", - "reference": "fa939c577925d65f658b0851ad59298fe179b153" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-etl/console-state/zipball/fa939c577925d65f658b0851ad59298fe179b153", - "reference": "fa939c577925d65f658b0851ad59298fe179b153", - "shasum": "" - }, - "require": { - "php": "^8.2", - "php-etl/pipeline-contracts": "0.5.*", - "symfony/console": "^6.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0", - "infection/infection": "^0.26.18", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.0", - "rector/rector": "^0.15" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "0.3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Kiboko\\Component\\State\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kiboko SAS", - "homepage": "http://kiboko.fr" - }, - { - "name": "Grégory Planchat", - "email": "gregory@kiboko.fr" - } - ], - "description": "This library allows you to use states", - "support": { - "issues": "https://github.com/php-etl/console-state/issues", - "source": "https://github.com/php-etl/console-state/tree/v0.3.0" - }, - "time": "2023-11-16T10:41:27+00:00" - }, { "name": "php-etl/pipeline-contracts", - "version": "v0.5.0", + "version": "v0.5.1", "source": { "type": "git", "url": "https://github.com/php-etl/pipeline-contracts.git", - "reference": "29aac4a1644c960355a17876e4a84bb8f0b89654" + "reference": "24c71241d16b7deca56d67ea0f1d591c8ae52f09" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-etl/pipeline-contracts/zipball/29aac4a1644c960355a17876e4a84bb8f0b89654", - "reference": "29aac4a1644c960355a17876e4a84bb8f0b89654", + "url": "https://api.github.com/repos/php-etl/pipeline-contracts/zipball/24c71241d16b7deca56d67ea0f1d591c8ae52f09", + "reference": "24c71241d16b7deca56d67ea0f1d591c8ae52f09", "shasum": "" }, "require": { @@ -138,7 +80,7 @@ "php-etl/satellite-contracts": "0.1.*" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0", + "friendsofphp/php-cs-fixer": "^3.38", "phpstan/phpstan": "^1.10", "rector/rector": "^0.15" }, @@ -170,29 +112,29 @@ "description": "This library describes contracts for the Extract-Transform-Load pattern.", "support": { "issues": "https://github.com/php-etl/pipeline-contracts/issues", - "source": "https://github.com/php-etl/pipeline-contracts/tree/v0.5.0" + "source": "https://github.com/php-etl/pipeline-contracts/tree/v0.5.1" }, - "time": "2023-11-15T10:45:24+00:00" + "time": "2023-11-20T10:48:56+00:00" }, { "name": "php-etl/satellite-contracts", - "version": "v0.1.0", + "version": "v0.1.1", "source": { "type": "git", "url": "https://github.com/php-etl/satellite-contracts.git", - "reference": "1d2bc6822bfdb3efc6a1f490e706db995c99ef41" + "reference": "d2be591800f42e460a59d864888aedf00f111dd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-etl/satellite-contracts/zipball/1d2bc6822bfdb3efc6a1f490e706db995c99ef41", - "reference": "1d2bc6822bfdb3efc6a1f490e706db995c99ef41", + "url": "https://api.github.com/repos/php-etl/satellite-contracts/zipball/d2be591800f42e460a59d864888aedf00f111dd7", + "reference": "d2be591800f42e460a59d864888aedf00f111dd7", "shasum": "" }, "require": { "php": "^8.2" }, "require-dev": { - "rector/rector": "^0.15.0" + "rector/rector": "^0.15" }, "type": "library", "extra": { @@ -222,9 +164,9 @@ "description": "This library describes contracts for defining satellite formats", "support": { "issues": "https://github.com/php-etl/satellite-contracts/issues", - "source": "https://github.com/php-etl/satellite-contracts/tree/v0.1.0" + "source": "https://github.com/php-etl/satellite-contracts/tree/v0.1.1" }, - "time": "2023-04-18T13:53:22+00:00" + "time": "2023-11-20T10:48:56+00:00" }, { "name": "psr/container", @@ -938,16 +880,16 @@ "packages-dev": [ { "name": "composer/pcre", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", "shasum": "" }, "require": { @@ -989,7 +931,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" + "source": "https://github.com/composer/pcre/tree/3.1.1" }, "funding": [ { @@ -1005,20 +947,20 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2023-10-11T07:11:09+00:00" }, { "name": "composer/semver", - "version": "3.3.2", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", + "url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", "shasum": "" }, "require": { @@ -1068,9 +1010,9 @@ "versioning" ], "support": { - "irc": "irc://irc.freenode.org/composer", + "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.3.2" + "source": "https://github.com/composer/semver/tree/3.4.0" }, "funding": [ { @@ -1086,7 +1028,7 @@ "type": "tidelift" } ], - "time": "2022-04-01T19:23:25+00:00" + "time": "2023-08-31T09:50:34+00:00" }, { "name": "composer/xdebug-handler", @@ -1249,16 +1191,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.12", + "version": "1.10.43", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "7b2aaf999e522e2b10011a594cf06dc37de7fbd8" + "reference": "2c4129f6ca8c7cfa870098884b8869b410a5a361" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7b2aaf999e522e2b10011a594cf06dc37de7fbd8", - "reference": "7b2aaf999e522e2b10011a594cf06dc37de7fbd8", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2c4129f6ca8c7cfa870098884b8869b410a5a361", + "reference": "2c4129f6ca8c7cfa870098884b8869b410a5a361", "shasum": "" }, "require": { @@ -1307,7 +1249,7 @@ "type": "tidelift" } ], - "time": "2023-04-12T10:33:29+00:00" + "time": "2023-11-19T19:55:25+00:00" }, { "name": "psr/event-dispatcher", @@ -1411,21 +1353,21 @@ }, { "name": "rector/rector", - "version": "0.15.24", + "version": "0.15.25", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "716473919bcfdc27bdd2a32afb72adbf4c224e59" + "reference": "015935c7ed9e48a4f5895ba974f337e20a263841" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/716473919bcfdc27bdd2a32afb72adbf4c224e59", - "reference": "716473919bcfdc27bdd2a32afb72adbf4c224e59", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/015935c7ed9e48a4f5895ba974f337e20a263841", + "reference": "015935c7ed9e48a4f5895ba974f337e20a263841", "shasum": "" }, "require": { "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.10.1" + "phpstan/phpstan": "^1.10.14" }, "conflict": { "rector/rector-doctrine": "*", @@ -1460,7 +1402,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/0.15.24" + "source": "https://github.com/rectorphp/rector/tree/0.15.25" }, "funding": [ { @@ -1468,20 +1410,20 @@ "type": "github" } ], - "time": "2023-04-05T08:49:11+00:00" + "time": "2023-04-20T16:07:39+00:00" }, { "name": "sebastian/diff", - "version": "5.0.1", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "aae9a0a43bff37bd5d8d0311426c87bf36153f02" + "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/aae9a0a43bff37bd5d8d0311426c87bf36153f02", - "reference": "aae9a0a43bff37bd5d8d0311426c87bf36153f02", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b", + "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b", "shasum": "" }, "require": { @@ -1527,7 +1469,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3" }, "funding": [ { @@ -1535,28 +1477,29 @@ "type": "github" } ], - "time": "2023-03-23T05:12:41+00:00" + "time": "2023-05-01T07:48:21+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v6.2.8", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "04046f35fd7d72f9646e721fc2ecb8f9c67d3339" + "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/04046f35fd7d72f9646e721fc2ecb8f9c67d3339", - "reference": "04046f35fd7d72f9646e721fc2ecb8f9c67d3339", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/adb01fe097a4ee930db9258a3cc906b5beb5cf2e", + "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e", "shasum": "" }, "require": { "php": ">=8.1", - "symfony/event-dispatcher-contracts": "^2|^3" + "symfony/event-dispatcher-contracts": "^2.5|^3" }, "conflict": { - "symfony/dependency-injection": "<5.4" + "symfony/dependency-injection": "<5.4", + "symfony/service-contracts": "<2.5" }, "provide": { "psr/event-dispatcher-implementation": "1.0", @@ -1569,13 +1512,9 @@ "symfony/error-handler": "^5.4|^6.0", "symfony/expression-language": "^5.4|^6.0", "symfony/http-foundation": "^5.4|^6.0", - "symfony/service-contracts": "^1.1|^2|^3", + "symfony/service-contracts": "^2.5|^3", "symfony/stopwatch": "^5.4|^6.0" }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, "type": "library", "autoload": { "psr-4": { @@ -1602,7 +1541,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.2.8" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.3.2" }, "funding": [ { @@ -1618,33 +1557,30 @@ "type": "tidelift" } ], - "time": "2023-03-20T16:06:02+00:00" + "time": "2023-07-06T06:56:43+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.2.1", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "0ad3b6f1e4e2da5690fefe075cd53a238646d8dd" + "reference": "a76aed96a42d2b521153fb382d418e30d18b59df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/0ad3b6f1e4e2da5690fefe075cd53a238646d8dd", - "reference": "0ad3b6f1e4e2da5690fefe075cd53a238646d8dd", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/a76aed96a42d2b521153fb382d418e30d18b59df", + "reference": "a76aed96a42d2b521153fb382d418e30d18b59df", "shasum": "" }, "require": { "php": ">=8.1", "psr/event-dispatcher": "^1" }, - "suggest": { - "symfony/event-dispatcher-implementation": "" - }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.3-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -1681,7 +1617,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.2.1" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.4.0" }, "funding": [ { @@ -1697,20 +1633,20 @@ "type": "tidelift" } ], - "time": "2023-03-01T10:32:47+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/filesystem", - "version": "v6.2.7", + "version": "v6.3.1", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "82b6c62b959f642d000456f08c6d219d749215b3" + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/82b6c62b959f642d000456f08c6d219d749215b3", - "reference": "82b6c62b959f642d000456f08c6d219d749215b3", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", "shasum": "" }, "require": { @@ -1744,7 +1680,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.2.7" + "source": "https://github.com/symfony/filesystem/tree/v6.3.1" }, "funding": [ { @@ -1760,20 +1696,20 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:44:56+00:00" + "time": "2023-06-01T08:30:39+00:00" }, { "name": "symfony/finder", - "version": "v6.2.7", + "version": "v6.3.5", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "20808dc6631aecafbe67c186af5dcb370be3a0eb" + "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/20808dc6631aecafbe67c186af5dcb370be3a0eb", - "reference": "20808dc6631aecafbe67c186af5dcb370be3a0eb", + "url": "https://api.github.com/repos/symfony/finder/zipball/a1b31d88c0e998168ca7792f222cbecee47428c4", + "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4", "shasum": "" }, "require": { @@ -1808,7 +1744,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.2.7" + "source": "https://github.com/symfony/finder/tree/v6.3.5" }, "funding": [ { @@ -1824,25 +1760,25 @@ "type": "tidelift" } ], - "time": "2023-02-16T09:57:23+00:00" + "time": "2023-09-26T12:56:25+00:00" }, { "name": "symfony/options-resolver", - "version": "v6.2.7", + "version": "v6.3.0", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "aa0e85b53bbb2b4951960efd61d295907eacd629" + "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/aa0e85b53bbb2b4951960efd61d295907eacd629", - "reference": "aa0e85b53bbb2b4951960efd61d295907eacd629", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/a10f19f5198d589d5c33333cffe98dc9820332dd", + "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd", "shasum": "" }, "require": { "php": ">=8.1", - "symfony/deprecation-contracts": "^2.1|^3" + "symfony/deprecation-contracts": "^2.5|^3" }, "type": "library", "autoload": { @@ -1875,7 +1811,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v6.2.7" + "source": "https://github.com/symfony/options-resolver/tree/v6.3.0" }, "funding": [ { @@ -1891,7 +1827,7 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:44:56+00:00" + "time": "2023-05-12T14:21:09+00:00" }, { "name": "symfony/polyfill-php80", @@ -1978,16 +1914,16 @@ }, { "name": "symfony/polyfill-php81", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a" + "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/707403074c8ea6e2edaf8794b0157a0bfa52157a", - "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/7581cd600fa9fd681b797d00b02f068e2f13263b", + "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b", "shasum": "" }, "require": { @@ -1996,7 +1932,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -2037,7 +1973,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.28.0" }, "funding": [ { @@ -2053,20 +1989,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/process", - "version": "v6.2.8", + "version": "v6.3.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "75ed64103df4f6615e15a7fe38b8111099f47416" + "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/75ed64103df4f6615e15a7fe38b8111099f47416", - "reference": "75ed64103df4f6615e15a7fe38b8111099f47416", + "url": "https://api.github.com/repos/symfony/process/zipball/0b5c29118f2e980d455d2e34a5659f4579847c54", + "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54", "shasum": "" }, "require": { @@ -2098,7 +2034,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.2.8" + "source": "https://github.com/symfony/process/tree/v6.3.4" }, "funding": [ { @@ -2114,25 +2050,25 @@ "type": "tidelift" } ], - "time": "2023-03-09T16:20:02+00:00" + "time": "2023-08-07T10:39:22+00:00" }, { "name": "symfony/stopwatch", - "version": "v6.2.7", + "version": "v6.3.0", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "f3adc98c1061875dd2edcd45e5b04e63d0e29f8f" + "reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/f3adc98c1061875dd2edcd45e5b04e63d0e29f8f", - "reference": "f3adc98c1061875dd2edcd45e5b04e63d0e29f8f", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2", + "reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2", "shasum": "" }, "require": { "php": ">=8.1", - "symfony/service-contracts": "^1|^2|^3" + "symfony/service-contracts": "^2.5|^3" }, "type": "library", "autoload": { @@ -2160,7 +2096,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v6.2.7" + "source": "https://github.com/symfony/stopwatch/tree/v6.3.0" }, "funding": [ { @@ -2176,7 +2112,7 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:44:56+00:00" + "time": "2023-02-16T10:14:28+00:00" } ], "aliases": [], @@ -2188,5 +2124,5 @@ "php": "^8.2" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/Console.php b/src/Console.php index c3b56e0..8e3d3de 100644 --- a/src/Console.php +++ b/src/Console.php @@ -4,36 +4,38 @@ namespace Kiboko\Component\Runtime\Pipeline; -use Kiboko\Component\State; use Kiboko\Contract\Pipeline\ExtractorInterface; use Kiboko\Contract\Pipeline\LoaderInterface; use Kiboko\Contract\Pipeline\PipelineInterface; -use Kiboko\Contract\Pipeline\RejectionInterface; -use Kiboko\Contract\Pipeline\StateInterface; +use Kiboko\Contract\Pipeline\StepCodeInterface; +use Kiboko\Contract\Pipeline\StepRejectionInterface; +use Kiboko\Contract\Pipeline\StepStateInterface; use Kiboko\Contract\Pipeline\TransformerInterface; use Kiboko\Contract\Pipeline\WalkableInterface; +use Kiboko\Component\Runtime\Pipeline\Step\MemoryState; use Symfony\Component\Console\Output\ConsoleOutput; final class Console implements PipelineRuntimeInterface { - private readonly State\StateOutput\Pipeline $state; + private readonly Pipeline $state; public function __construct( ConsoleOutput $output, private readonly PipelineInterface&WalkableInterface $pipeline, - ?State\StateOutput\Pipeline $state = null + ?Pipeline $state = null ) { - $this->state = $state ?? new State\StateOutput\Pipeline($output, 'A', 'Pipeline'); + $this->state = $state ?? new Pipeline($output, 'A', 'Pipeline'); } public function extract( + StepCodeInterface $step, ExtractorInterface $extractor, - RejectionInterface $rejection, - StateInterface $state, + StepRejectionInterface $rejection, + StepStateInterface $state, ): self { - $this->pipeline->extract($extractor, $rejection, $state = new State\MemoryState($state)); + $this->pipeline->extract($step, $extractor, $rejection, $state = new MemoryState($state)); - $this->state->withStep('extractor') + $this->state->withStep((string) $step) ->addMetric('read', $state->observeAccept()) ->addMetric('error', fn () => 0) ->addMetric('rejected', $state->observeReject()) @@ -43,13 +45,14 @@ public function extract( } public function transform( + StepCodeInterface $step, TransformerInterface $transformer, - RejectionInterface $rejection, - StateInterface $state, + StepRejectionInterface $rejection, + StepStateInterface $state, ): self { - $this->pipeline->transform($transformer, $rejection, $state = new State\MemoryState($state)); + $this->pipeline->transform($step, $transformer, $rejection, $state = new MemoryState($state)); - $this->state->withStep('transformer') + $this->state->withStep((string) $step) ->addMetric('read', $state->observeAccept()) ->addMetric('error', fn () => 0) ->addMetric('rejected', $state->observeReject()) @@ -59,13 +62,14 @@ public function transform( } public function load( + StepCodeInterface $step, LoaderInterface $loader, - RejectionInterface $rejection, - StateInterface $state, + StepRejectionInterface $rejection, + StepStateInterface $state, ): self { - $this->pipeline->load($loader, $rejection, $state = new State\MemoryState($state)); + $this->pipeline->load($step, $loader, $rejection, $state = new MemoryState($state)); - $this->state->withStep('loader') + $this->state->withStep((string) $step) ->addMetric('read', $state->observeAccept()) ->addMetric('error', fn () => 0) ->addMetric('rejected', $state->observeReject()) diff --git a/src/MemoryState.php b/src/MemoryState.php new file mode 100644 index 0000000..af0e9d7 --- /dev/null +++ b/src/MemoryState.php @@ -0,0 +1,61 @@ +metrics = [ + 'accept' => 0, + 'reject' => 0, + 'error' => 0, + ]; + + $this->decorated?->initialize($start); + } + + public function accept(int $step = 1): void + { + $this->metrics['accept'] += $step; + $this->decorated?->accept($step); + } + + public function reject(int $step = 1): void + { + $this->metrics['reject'] += $step; + $this->decorated?->reject($step); + } + + public function error(int $step = 1): void + { + $this->metrics['error'] += $step; + $this->decorated?->error($step); + } + + public function observeAccept(): callable + { + return fn () => $this->metrics['accept']; + } + + public function observeReject(): callable + { + return fn () => $this->metrics['reject']; + } + + public function teardown(): void + { + $this->decorated?->teardown(); + } +} diff --git a/src/Pipeline.php b/src/Pipeline.php new file mode 100644 index 0000000..5cefa58 --- /dev/null +++ b/src/Pipeline.php @@ -0,0 +1,38 @@ +section = $output->section(); + $this->section->writeln(''); + $this->section->writeln(sprintf(' % 2s. %-50s', $index, $label)); + } + + public function withStep(string $label): Step + { + return $this->steps[] = new Step($this->output, \count($this->steps) + 1, $label); + } + + public function update(): void + { + foreach ($this->steps as $step) { + $step->update(); + } + } +} diff --git a/src/Step/MemoryState.php b/src/Step/MemoryState.php new file mode 100644 index 0000000..bd2d6d7 --- /dev/null +++ b/src/Step/MemoryState.php @@ -0,0 +1,54 @@ + 0, + 'reject' => 0, + 'error' => 0, + ]; + + public function __construct( + private readonly ?StepStateInterface $decorated = null, + ) { + } + + public function accept(int $count = 1): void + { + $this->metrics['accept'] += $count; + $this->decorated?->accept($count); + } + + public function reject(int $count = 1): void + { + $this->metrics['reject'] += $count; + $this->decorated?->reject($count); + } + + public function error(int $count = 1): void + { + $this->metrics['error'] += $count; + $this->decorated?->error($count); + } + + public function observeAccept(): callable + { + return fn () => $this->metrics['accept']; + } + + public function observeReject(): callable + { + return fn () => $this->metrics['reject']; + } + + public function teardown(): void + { + $this->decorated?->teardown(); + } +} diff --git a/src/Step/Step.php b/src/Step/Step.php new file mode 100644 index 0000000..afe3181 --- /dev/null +++ b/src/Step/Step.php @@ -0,0 +1,44 @@ + */ + private array $metrics = []; + private readonly ConsoleSectionOutput $section; + + public function __construct( + private readonly ConsoleOutput $output, + int $index, + string $label, + ) { + $this->section = $this->output->section(); + $this->section->writeln(sprintf(' % 2d. %-50s', $index, $label)); + $this->section->writeln(''); + } + + public function addMetric(string $label, callable $callback): self + { + $this->metrics[$label] = $callback; + + return $this; + } + + public function update(): void + { + $this->section->clear(1); + $this->section + ->writeln(' '.implode(', ', array_map( + fn (string $label, callable $callback) => sprintf('%s %d', $label, ($callback)()), + array_keys($this->metrics), + array_values($this->metrics), + ))) + ; + } +}