From 8da659661ce0ea2a1e023165ae4d4c3467491cad Mon Sep 17 00:00:00 2001 From: otsch Date: Tue, 10 Sep 2024 22:10:22 +0200 Subject: [PATCH] Add the keep methods to the StepInterface --- CHANGELOG.md | 1 + src/Steps/StepInterface.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccd6c9db..be4b667b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2.0.0] - 2024-x-x ### Changed * __BREAKING__: Removed methods `BaseStep::addToResult()`, `BaseStep::addLaterToResult()`, `BaseStep::addsToOrCreatesResult()`, `BaseStep::createsResult()`, and `BaseStep::keepInputData()`. These methods were deprecated in v1.8.0 and should be replaced with `Step::keep()`, `Step::keepAs()`, `Step::keepFromInput()`, and `Step::keepInputAs()`. +* __BREAKING__: Added the following keep methods to the `StepInterface`: `StepInterface::keep()`, `StepInterface::keepAs()`, `StepInterface::keepFromInput()`, `StepInterface::keepInputAs()`, as well as `StepInterface::keepsAnything()`, `StepInterface::keepsAnythingFromInputData()` and `StepInterface::keepsAnythingFromOutputData()`. If you have a class that implements this interface without extending `Step` (or `BaseStep`), you will need to implement these methods yourself. However, it is strongly recommended to extend `Step` instead. * __BREAKING__: With the removal of the `addToResult()` method, the library no longer uses `toArrayForAddToResult()` methods on output objects. Instead, please use `toArrayForResult()`. Consequently, `RespondedRequest::toArrayForAddToResult()` has been renamed to `RespondedRequest::toArrayForResult()`. * __BREAKING__: Removed the `result` and `addLaterToResult` properties from `Io` objects (`Input` and `Output`). These properties were part of the `addToResult` feature and are now removed. Instead, use the `keep` property where kept data is added. * __BREAKING__: The signature of the `Crawler::addStep()` method has changed. You can no longer provide a result key as the first parameter. Previously, this key was passed to the `Step::addToResult()` method internally. Now, please handle this call yourself. diff --git a/src/Steps/StepInterface.php b/src/Steps/StepInterface.php index e47d443f..d2a4285c 100644 --- a/src/Steps/StepInterface.php +++ b/src/Steps/StepInterface.php @@ -18,6 +18,26 @@ public function addLogger(LoggerInterface $logger): static; */ public function invokeStep(Input $input): Generator; + /** + * @param string|string[]|null $keys + */ + public function keep(string|array|null $keys = null): static; + + public function keepAs(string $key): static; + + /** + * @param string|string[]|null $keys + */ + public function keepFromInput(string|array|null $keys = null): static; + + public function keepInputAs(string $key): static; + + public function keepsAnything(): bool; + + public function keepsAnythingFromInputData(): bool; + + public function keepsAnythingFromOutputData(): bool; + public function useInputKey(string $key): static; public function uniqueInputs(?string $key = null): static;