Skip to content

Commit

Permalink
Merge pull request #210 from odolbeau/ensure-processor
Browse files Browse the repository at this point in the history
Deprecate usage of StackedProcessor without ProcessorInterface instance
  • Loading branch information
Olivier Dolbeau committed Jan 23, 2020
2 parents 4bb56eb + 452221a commit 2e8a4ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Swarrot/Processor/Stack/StackedProcessor.php
Expand Up @@ -27,6 +27,10 @@ class StackedProcessor implements ConfigurableInterface, InitializableInterface,
*/
public function __construct($processor, array $middlewares)
{
if (!$processor instanceof ProcessorInterface) {
@trigger_error(sprintf('Using "%s" without a ProcessorInterface have been deprecated since Swarrot 3.7', __CLASS__), E_USER_DEPRECATED);
}

$this->processor = $processor;
$this->middlewares = $middlewares;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/Swarrot/Processor/Stack/StackedProcessorTest.php
Expand Up @@ -86,4 +86,13 @@ public function test_sleep_return_false_if_at_least_a_processor_return_false()

$this->assertFalse($stackedProcessor->sleep([]));
}

/**
* @group legacy
* @expectedDeprecation Using "Swarrot\Processor\Stack\StackedProcessor" without a ProcessorInterface have been deprecated since Swarrot 3.7
*/
public function test_without_processor_interface()
{
$stackedProcessor = new StackedProcessor(function () {}, []);
}
}

0 comments on commit 2e8a4ce

Please sign in to comment.