Skip to content

Commit 23598e9

Browse files
committed
style: integrate php-cs-fixer
1 parent 8e19549 commit 23598e9

File tree

6 files changed

+208
-134
lines changed

6 files changed

+208
-134
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Thumbs.db
99
/.fleet
1010
/.vscode
1111
.phpunit.result.cache
12+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->in([
5+
__DIR__ . '/src',
6+
__DIR__ . '/tests',
7+
])
8+
->name('*.php')
9+
->notName('*.blade.php')
10+
->ignoreDotFiles(true)
11+
->ignoreVCS(true);
12+
13+
return (new PhpCsFixer\Config())
14+
->setRules([
15+
'@PSR12' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
18+
'no_unused_imports' => true,
19+
'not_operator_with_successor_space' => true,
20+
'trailing_comma_in_multiline' => true,
21+
'phpdoc_scalar' => true,
22+
'unary_operator_spaces' => true,
23+
'binary_operator_spaces' => true,
24+
'blank_line_before_statement' => [
25+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
26+
],
27+
'phpdoc_single_line_var_spacing' => true,
28+
'phpdoc_var_without_name' => true,
29+
'method_argument_space' => [
30+
'on_multiline' => 'ensure_fully_multiline',
31+
'keep_multiple_spaces_after_comma' => true,
32+
],
33+
'single_trait_insert_per_statement' => true,
34+
])
35+
->setFinder($finder);

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
"require-dev": {
2323
"laravel/framework": "^11.35",
2424
"phpunit/phpunit": "^11.5",
25-
"orchestra/testbench-core": "^9.8"
25+
"orchestra/testbench-core": "^9.8",
26+
"friendsofphp/php-cs-fixer": "^3.65"
2627
},
2728
"scripts": {
28-
"test": "./vendor/bin/phpunit"
29+
"test": "./vendor/bin/phpunit",
30+
"lint": "./vendor/bin/php-cs-fixer fix"
2931
}
3032
}

src/Bus.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
namespace Circle33\LaravelBusFluentable;
44

5-
use Circle33\LaravelBusFluentable\FluentPendingBatch;
6-
use Illuminate\Support\Testing\Fakes\BusFake;
75
use Illuminate\Contracts\Bus\Dispatcher;
6+
use Illuminate\Support\Testing\Fakes\BusFake;
87
use PHPUnit\Framework\Assert as PHPUnit;
98

109
class Bus

src/FluentPendingBatch.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public function has(string|int $expectedJob, array $expectedParameters = [])
3737
}
3838

3939
PHPUnit::assertTrue(
40-
$this->jobs->contains(fn ($job) => get_class($job) === $expectedJob &&
40+
$this->jobs->contains(
41+
fn ($job) => get_class($job) === $expectedJob &&
4142
$this->parametersMatch($job, $expectedJob, $expectedParameters)
4243
),
4344
"The batch does not contain a job of type [{$expectedJob}]."
@@ -147,9 +148,11 @@ public function first(Closure $callback)
147148
throw new $e('The first one in the batch does not matches the given callback: '.$e->getMessage());
148149
}
149150

150-
array_push($this->expected, is_array($firstJob) ?
151-
array_map(fn ($job) => get_class($job), $firstJob) :
152-
get_class($firstJob)
151+
array_push(
152+
$this->expected,
153+
is_array($firstJob) ?
154+
array_map(fn ($job) => get_class($job), $firstJob) :
155+
get_class($firstJob)
153156
);
154157

155158
return $this;
@@ -186,9 +189,11 @@ public function nth(int $index, Closure|string $callback, array $parameters = []
186189
));
187190
}
188191

189-
array_push($this->expected, is_array($nthJob) ?
190-
array_map(fn ($job) => get_class($job), $nthJob) :
191-
get_class($nthJob)
192+
array_push(
193+
$this->expected,
194+
is_array($nthJob) ?
195+
array_map(fn ($job) => get_class($job), $nthJob) :
196+
get_class($nthJob)
192197
);
193198
}
194199

@@ -269,9 +274,10 @@ public function etc()
269274
$expectedJobs = array_map('serialize', $this->expected);
270275

271276
$actualJobs = $this->jobs->map(
272-
fn ($job) => serialize(is_array($job) ?
273-
array_map(fn ($j) => get_class($j), $job) :
274-
get_class($job)
277+
fn ($job) => serialize(
278+
is_array($job) ?
279+
array_map(fn ($j) => get_class($j), $job) :
280+
get_class($job)
275281
)
276282
)->toArray();
277283

0 commit comments

Comments
 (0)