Skip to content

Commit dcab2ac

Browse files
authored
Chore: cleanup (#58)
* style: fix * Refactor: move thecodingmachine/safe to dev requirements * chore: fix coverage * chore: update CI configuration for PHP versions and checkout action * chore: update pestphp/pest to version 3.8 * chore: modify CI to handle PHP 8.5 platform requirements during dependency installation
1 parent f45bf62 commit dcab2ac

File tree

11 files changed

+53
-30
lines changed

11 files changed

+53
-30
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,29 @@ on:
66

77
jobs:
88
tests:
9-
runs-on: ubuntu-22.04
9+
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
1212
php:
1313
- 8.2
1414
- 8.3
15+
- 8.4
16+
- 8.5
1517
steps:
16-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
1719

1820
- name: Setup PHP
1921
uses: shivammathur/setup-php@v2
2022
with:
2123
php-version: ${{ matrix.php }}
2224

2325
- name: Install dependencies
24-
run: composer install --prefer-dist --no-progress
26+
run: |
27+
if [[ "${{ matrix.php }}" == "8.5" ]]; then
28+
composer install --prefer-dist --no-progress --ignore-platform-req=php
29+
else
30+
composer install --prefer-dist --no-progress
31+
fi
2532
2633
- name: Check types
2734
run: vendor/bin/phpstan analyse

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
"php": ">=8.2",
77
"psr/event-dispatcher": "^1.0",
88
"psr/log": "^3.0",
9-
"symfony/options-resolver": "@stable",
10-
"thecodingmachine/safe": "^2.5"
9+
"symfony/options-resolver": "@stable"
1110
},
1211
"require-dev": {
1312
"bentools/iterable-functions": "^2.1",
1413
"doctrine/orm": "^2.16",
1514
"friendsofphp/php-cs-fixer": "^3.35",
1615
"mockery/mockery": "^1.6",
1716
"monolog/monolog": "^3.5",
18-
"pestphp/pest": "^2.24",
17+
"pestphp/pest": "^3.8",
1918
"phpstan/phpstan": "^1.10",
2019
"phpstan/phpstan-mockery": "^1.1",
2120
"react/stream": "^1.3",
22-
"symfony/var-dumper": "*"
21+
"symfony/var-dumper": "*",
22+
"thecodingmachine/safe": "^3.3"
2323
},
2424
"license": "MIT",
2525
"autoload": {

phpstan.dist.neon

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,5 @@ parameters:
33
paths:
44
- src/
55
- tests/
6-
ignoreErrors:
7-
-
8-
message: "#Access to an undefined property#"
9-
path: "tests/Unit/Recipe/LoggerRecipeTest.php"
106
includes:
117
- vendor/phpstan/phpstan-mockery/extension.neon

src/Internal/EtlBuilderTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ trait EtlBuilderTrait
3535

3636
public function extractFrom(
3737
ExtractorInterface|callable $extractor,
38-
ExtractorInterface|callable ...$extractors
38+
ExtractorInterface|callable ...$extractors,
3939
): self {
4040
$extractors = [$extractor, ...$extractors];
4141

@@ -54,7 +54,7 @@ public function extractFrom(
5454

5555
public function transformWith(
5656
TransformerInterface|callable $transformer,
57-
TransformerInterface|callable ...$transformers
57+
TransformerInterface|callable ...$transformers,
5858
): self {
5959
$transformers = [$transformer, ...$transformers];
6060

src/Iterator/PregSplitIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use IteratorAggregate;
88
use Traversable;
99

10+
use function preg_split;
1011
use function rtrim;
11-
use function Safe\preg_split;
1212

1313
/**
1414
* @internal

src/functions.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ function array_fill_from(array $keys, array $values, array ...$extraValues): arr
4242
}
4343

4444
/**
45-
* @internal
46-
*
47-
* @template T
48-
*
4945
* @param iterable<T> $items
5046
*
5147
* @return Iterator<T>
48+
*
49+
* @internal
50+
*
51+
* @template T
5252
*/
5353
function iterable_to_iterator(iterable $items): Iterator
5454
{
@@ -62,7 +62,7 @@ function extractFrom(ExtractorInterface|callable $extractor, ExtractorInterface|
6262

6363
function transformWith(
6464
TransformerInterface|callable $transformer,
65-
TransformerInterface|callable ...$transformers
65+
TransformerInterface|callable ...$transformers,
6666
): EtlExecutor {
6767
return (new EtlExecutor())->transformWith(...func_get_args());
6868
}
@@ -107,6 +107,6 @@ function skipWhen(callable $filter, ?string $eventClass = ExtractEvent::class, i
107107
$filter(...),
108108
$eventClass ?? ExtractEvent::class,
109109
$priority,
110-
FilterRecipeMode::EXCLUDE
110+
FilterRecipeMode::EXCLUDE,
111111
);
112112
}

tests/Unit/EtlExecutorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
it('loads conditionally', function () {
6565
// Background
66-
$loader = new class() implements ConditionalLoaderInterface {
66+
$loader = new class implements ConditionalLoaderInterface {
6767
public function supports(mixed $item, EtlState $state): bool
6868
{
6969
return 'foo' !== $item;
@@ -98,7 +98,7 @@ public function flush(bool $isPartial, EtlState $state): mixed
9898
it('yells if it cannot process extracted data', function () {
9999
// Given
100100
$executor = (new EtlExecutor())->withProcessor(
101-
new class() implements ProcessorInterface {
101+
new class implements ProcessorInterface {
102102
public function supports(mixed $extracted): bool
103103
{
104104
return false;

tests/Unit/EventDispatcher/EventDispatcherTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public function visit(string $visitor): void
2929
it('dispatches events, to the appropriate listeners, in the correct order', function () {
3030
$listenerProvider = new PrioritizedListenerProvider();
3131
$bus = new EventDispatcher($listenerProvider);
32-
$ignored = new class() {
32+
$ignored = new class {
3333
use EventVisitor;
3434
};
35-
$event = new class() {
35+
$event = new class {
3636
use EventVisitor;
3737
};
3838

@@ -55,7 +55,7 @@ public function visit(string $visitor): void
5555
it('stops propagation of events', function () {
5656
$listenerProvider = new PrioritizedListenerProvider();
5757
$bus = new EventDispatcher($listenerProvider);
58-
$event = new class() implements StoppableEventInterface {
58+
$event = new class implements StoppableEventInterface {
5959
use EventVisitor;
6060
};
6161

tests/Unit/Extractor/ChainExtractorTest.php

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

77
use BenTools\ETL\EtlExecutor;
88
use BenTools\ETL\Extractor\CallableExtractor;
9+
use BenTools\ETL\Extractor\ChainExtractor;
910

1011
use function BenTools\ETL\chain;
1112
use function BenTools\ETL\extractFrom;
@@ -40,3 +41,8 @@
4041
// Then
4142
expect($report->output)->toBe(['banana', 'apple', 'strawberry', 'raspberry', 'peach']);
4243
});
44+
45+
it('returns self', function () {
46+
$chainTransformer = new ChainExtractor(fn () => null);
47+
expect(ChainExtractor::from($chainTransformer))->toBe($chainTransformer);
48+
});

tests/Unit/Loader/ChainLoaderTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use BenTools\ETL\EtlExecutor;
99
use BenTools\ETL\EtlState;
1010
use BenTools\ETL\Loader\CallableLoader;
11+
use BenTools\ETL\Loader\ChainLoader;
1112
use BenTools\ETL\Loader\ConditionalLoaderInterface;
1213

1314
use function BenTools\ETL\chain;
@@ -26,7 +27,7 @@
2627
chain($executor->loader)
2728
->with(fn (string $item) => $b[] = $item) // @phpstan-ignore-line
2829
->with(
29-
new class() implements ConditionalLoaderInterface {
30+
new class implements ConditionalLoaderInterface {
3031
public function supports(mixed $item, EtlState $state): bool
3132
{
3233
return 'foo' !== $item;
@@ -80,3 +81,8 @@ public function flush(bool $isPartial, EtlState $state): mixed
8081
expect([...$a])->toBe(['foo', 'bar'])
8182
->and([...$b])->toBe(['foo', 'bar']);
8283
});
84+
85+
it('returns self', function () {
86+
$chainTransformer = new ChainLoader(fn () => null);
87+
expect(ChainLoader::from($chainTransformer))->toBe($chainTransformer);
88+
});

0 commit comments

Comments
 (0)