Skip to content

Commit 057cc58

Browse files
committed
wip v4
1 parent 303571a commit 057cc58

21 files changed

+326
-317
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
os:
1414
- "ubuntu-latest"
1515
php:
16-
- "8.1"
1716
- "8.2"
17+
- "8.3"
1818
experimental:
1919
- false
2020

21-
name: PHP${{ matrix.php }} on ${{ matrix.os }}
21+
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
2222

2323
steps:
2424
- name: Checkout
@@ -36,4 +36,4 @@ jobs:
3636
composer-options: "--prefer-dist --no-cache"
3737

3838
- name: Run tests
39-
run: vendor/bin/testbench package:test
39+
run: vendor/bin/pest

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 4.0.0 - Unreleased
4+
5+
### Changed
6+
7+
* **Minimum PHP version is now 8.2**
8+
* Removed Orchestra Testbench in favor of PestPHP
9+
* Updated nunomaduro/collision to ^8.4
10+
* Added generic typing information across the package
11+
312
## 3.0.0 - 2023-02-07
413

514
### Changed

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@
3232
}
3333
},
3434
"require": {
35-
"php": ">=8.1"
35+
"php": "^8.2"
3636
},
3737
"require-dev": {
38-
"orchestra/testbench": "^7.21",
39-
"nunomaduro/collision": "^6.4"
38+
"nunomaduro/collision": "^8.4",
39+
"pestphp/pest": "^2.35"
4040
},
4141
"scripts": {
42-
"dump-and-test": [
43-
"@dump",
44-
"@test"
45-
],
46-
"dump": "composer dumpautoload",
47-
"test": "./vendor/bin/testbench package:test"
42+
"test": "./vendor/bin/pest"
43+
},
44+
"config": {
45+
"allow-plugins": {
46+
"pestphp/pest-plugin": true
47+
}
4848
}
4949
}

phpunit.xml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" bootstrap="vendor/autoload.php" cacheResultFile=".phpunit.cache/test-results" executionOrder="depends,defects" forceCoversAnnotation="true" beStrictAboutCoversAnnotation="true" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" verbose="true">
3-
<testsuites>
4-
<testsuite name="Pipeline Test Suite">
5-
<directory suffix="Test.php">tests</directory>
6-
</testsuite>
7-
</testsuites>
8-
9-
<coverage cacheDirectory=".phpunit.cache/code-coverage" processUncoveredFiles="true">
10-
<include>
11-
<directory suffix=".php">src</directory>
12-
</include>
13-
<exclude></exclude>
14-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" failOnRisky="true" failOnWarning="true" cacheDirectory=".phpunit.cache">
3+
<testsuites>
4+
<testsuite name="Pipeline Test Suite">
5+
<directory suffix="Test.php">
6+
tests
7+
</directory>
8+
</testsuite>
9+
</testsuites>
10+
<source>
11+
<include>
12+
<directory suffix=".php">
13+
./src
14+
</directory>
15+
</include>
16+
<exclude />
17+
</source>
1518
</phpunit>

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In the simplest form, the execution-chain can be represented as a `foreach` loop
1919
$output = $traveler;
2020

2121
foreach ($stages as $stage) {
22-
$output = $stage($output);
22+
$output = $stage($output);
2323
}
2424

2525
return $output;
@@ -108,9 +108,9 @@ use Rockett\Pipeline\Builder\PipelineBuilder;
108108

109109
// Prepare the builder
110110
$pipelineBuilder = (new PipelineBuilder)
111-
->add(new LogicalStage)
112-
->add(new AnotherStage)
113-
->add(new FinalStage);
111+
->add(new LogicalStage)
112+
->add(new AnotherStage)
113+
->add(new FinalStage);
114114

115115
// Do other work …
116116

@@ -209,7 +209,7 @@ $processor = (new TapProcessor)
209209
->afterEach(/** callable **/);
210210
```
211211

212-
If you are using PHP 8 or higher, it is encouraged that you use [named arguments](https://stitcher.io/blog/php-8-named-arguments) instead:
212+
However, it is encouraged that you use [named arguments](https://stitcher.io/blog/php-8-named-arguments):
213213

214214
```php
215215
$processor = new TapProcessor(

src/Builder/PipelineBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class PipelineBuilder implements PipelineBuilderContract
1616
public function add(callable $stage): PipelineBuilderContract
1717
{
1818
$this->stages[] = $stage;
19+
1920
return $this;
2021
}
2122

src/Contracts/PipelineContract.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@
44

55
namespace Rockett\Pipeline\Contracts;
66

7+
/**
8+
* @template T
9+
* @implements StageContract<T>
10+
*/
711
interface PipelineContract extends StageContract
812
{
13+
/**
14+
* @return PipelineContract<T>
15+
*/
916
public function pipe(callable $operation): PipelineContract;
17+
18+
/**
19+
* @param T $traveler
20+
*/
1021
public function process($traveler);
1122
}

src/Contracts/StageContract.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44

55
namespace Rockett\Pipeline\Contracts;
66

7+
/**
8+
* @template T
9+
*/
710
interface StageContract
811
{
12+
/**
13+
* @param T $traveler
14+
*/
915
public function __invoke($traveler);
1016
}

src/Pipeline.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,47 @@
77
use Rockett\Pipeline\Contracts\PipelineContract;
88
use Rockett\Pipeline\Processors\{FingersCrossedProcessor, ProcessorContract};
99

10-
/** @property callable[] $stages */
10+
/**
11+
* @template T
12+
* @implements PipelineContract<T>
13+
*/
1114
class Pipeline implements PipelineContract
1215
{
1316
private ProcessorContract $processor;
17+
18+
/** @var callable[] */
1419
private array $stages;
1520

1621
public function __construct(
17-
ProcessorContract $processor = null,
22+
?ProcessorContract $processor = null,
1823
callable ...$stages
1924
) {
20-
$this->processor = $processor ?? new FingersCrossedProcessor;
25+
$this->processor = $processor ?? new FingersCrossedProcessor();
2126
$this->stages = $stages;
2227
}
2328

24-
public function pipe(callable $stage): PipelineContract
29+
public function pipe(callable $stage): self
2530
{
2631
$pipeline = clone $this;
2732
$pipeline->stages[] = $stage;
2833

2934
return $pipeline;
3035
}
3136

32-
public function process($traveler)
37+
/**
38+
* @param T $traveler
39+
* @return T
40+
*/
41+
public function process($traveler): mixed
3342
{
3443
return $this->processor->process($traveler, ...$this->stages);
3544
}
3645

37-
public function __invoke($traveler)
46+
/**
47+
* @param T $traveler
48+
* @return T
49+
*/
50+
public function __invoke($traveler): mixed
3851
{
3952
return $this->process($traveler);
4053
}

src/Processors/FingersCrossedProcessor.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44

55
namespace Rockett\Pipeline\Processors;
66

7+
/**
8+
* @template T
9+
* @implements ProcessorContract<T>
10+
*/
711
class FingersCrossedProcessor implements ProcessorContract
812
{
13+
/**
14+
* @param T $traveler
15+
* @param callable ...$stages
16+
* @return T
17+
*/
918
public function process($traveler, callable ...$stages)
1019
{
1120
foreach ($stages as $stage) {

0 commit comments

Comments
 (0)