Skip to content

Commit 585980a

Browse files
committed
Added rector/rector
1 parent e51efeb commit 585980a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+389
-252
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"scripts": {
2222
"test": [
23-
"./vendor/bin/pest"
23+
"./vendor/bin/pest && ./vendor/bin/rector"
2424
],
2525
"generate-field": [
2626
"php field-generator/Generator.php"
@@ -38,7 +38,8 @@
3838
"orchestra/testbench": "^9.0",
3939
"spatie/laravel-ray": "^1.39",
4040
"pestphp/pest-plugin-laravel": "^3",
41-
"statamic/eloquent-driver": "^4.16"
41+
"statamic/eloquent-driver": "^4.16",
42+
"rector/rector": "^2.0"
4243
},
4344
"config": {
4445
"allow-plugins": {

composer.lock

Lines changed: 118 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

field-generator/FieldTestTemplate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use Tdwesten\StatamicBuilder\Enums\VisibilityOption;
44

5-
it('can render to a array', function () {
5+
it('can render to a array', function (): void {
66
$field = new \Tdwesten\StatamicBuilder\FieldTypes\__Field__('title');
77
$field->displayName('Display Name')
88
->instructions('Enter the title')

rector.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__ . '/config',
10+
__DIR__ . '/field-generator',
11+
__DIR__ . '/resources',
12+
__DIR__ . '/src',
13+
__DIR__ . '/tests',
14+
])
15+
// uncomment to reach your current PHP version
16+
// ->withPhpSets()
17+
->withTypeCoverageLevel(0)
18+
->withDeadCodeLevel(0)
19+
->withCodeQualityLevel(0);

src/Console/Export.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ private function exportBlueprints()
3333
{
3434
$namespaces = collect(config('statamic.builder.blueprints', []));
3535

36-
$namespaces->each(function ($blueprints, $namespace) {
36+
$namespaces->each(function ($blueprints, $namespace): void {
3737
$blueprints = collect($blueprints);
3838

39-
$blueprints->each(function ($blueprint, $handle) use ($namespace) {
39+
$blueprints->each(function ($blueprint, $handle) use ($namespace): void {
4040
$this->exportBlueprint($namespace, $handle, $blueprint);
4141
});
4242
});
@@ -64,7 +64,7 @@ private function exportFieldSets()
6464
{
6565
$namespaces = collect(config('statamic.builder.fieldsets', []));
6666

67-
$namespaces->each(function ($fieldset) {
67+
$namespaces->each(function ($fieldset): void {
6868
$this->exportFieldset($fieldset);
6969
});
7070
}

src/Repositories/CollectionRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private function initializeCollections()
2828

2929
$this->collections = collect();
3030

31-
$collections->each(function (string $collection) {
31+
$collections->each(function (string $collection): void {
3232
if (class_exists($collection, true)) {
3333
$this->collections->put($collection::handle(), $collection);
3434
}

src/Repositories/GlobalRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private function initializeGlobals()
5252

5353
$this->globals = collect();
5454

55-
$globals->each(function (string $set) {
55+
$globals->each(function (string $set): void {
5656
if (class_exists($set, true)) {
5757
$this->globals->put($set::handle(), $set);
5858
}

src/Repositories/TaxonomyRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private function initializeTaxonomies()
2828

2929
$this->taxonomies = collect();
3030

31-
$taxonomies->each(function (string $taxonomy) {
31+
$taxonomies->each(function (string $taxonomy): void {
3232
if (class_exists($taxonomy, true)) {
3333
$this->taxonomies->put($taxonomy::handle(), $taxonomy);
3434
}

tests/Unit/BlueprintTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55
use Tdwesten\StatamicBuilder\FieldTypes\Text;
66
use Tests\Helpers\TestBlueprint;
77

8-
test('Has a title', function () {
8+
test('Has a title', function (): void {
99
$blueprint = TestBlueprint::make('test_blueprint');
1010

1111
expect($blueprint->toArray()['title'])->toBe(
1212
'Test Blueprint'
1313
);
1414
});
1515

16-
it('can be set to hidden', function () {
16+
it('can be set to hidden', function (): void {
1717
$blueprint = TestBlueprint::make('test_blueprint');
1818
$blueprint->hidden(true);
1919

2020
expect($blueprint->toArray()['hide'])->toBe(true);
2121
});
2222

23-
test('Tabs are renderd', function () {
23+
test('Tabs are renderd', function (): void {
2424
$blueprint = TestBlueprint::make('test_blueprint');
2525

2626
$expected = [
@@ -58,7 +58,7 @@
5858
expect($blueprint->toArray())->toBe($expected);
5959
});
6060

61-
it('throws an exception when adding a field to a tab', function () {
61+
it('throws an exception when adding a field to a tab', function (): void {
6262
$blueprint = TestBlueprint::make('test_blueprint');
6363
$blueprint
6464
->title('School')
@@ -69,14 +69,14 @@
6969
$blueprint->toArray();
7070
})->throws(BlueprintRenderException::class, 'Only sections are allowed in tabs');
7171

72-
test('you can set a title', function () {
72+
test('you can set a title', function (): void {
7373
$blueprint = TestBlueprint::make('test_blueprint');
7474
$blueprint->title('School');
7575

7676
expect($blueprint->toArray()['title'])->toBe('School');
7777
});
7878

79-
test('you can get the handle', function () {
79+
test('you can get the handle', function (): void {
8080
$blueprint = TestBlueprint::make('test_blueprint');
8181

8282
expect($blueprint->getHandle())->toBe('test_blueprint');

tests/Unit/CollectionTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@
33
use Tests\Helpers\MultisiteTestCollection;
44
use Tests\Helpers\TestCollection;
55

6-
test('Has a title', function () {
6+
test('Has a title', function (): void {
77
$collection = new TestCollection;
88

99
expect($collection->title())->toBe(
1010
'Shows'
1111
);
1212
});
1313

14-
test('Has a handle', function () {
14+
test('Has a handle', function (): void {
1515
$collection = new TestCollection;
1616

1717
expect($collection->handle())->toBe(
1818
'shows'
1919
);
2020
});
2121

22-
test('Has a route', function () {
22+
test('Has a route', function (): void {
2323
$collection = new TestCollection;
2424

2525
expect($collection->route())->toBe(
2626
'/shows/{slug}'
2727
);
2828
});
2929

30-
test('Has multiple route for multisites', function () {
30+
test('Has multiple route for multisites', function (): void {
3131
$collection = new MultisiteTestCollection;
3232

3333
expect($collection->route())->toBe(
@@ -38,15 +38,15 @@
3838
);
3939
});
4040

41-
test('Can have multiple sites', function () {
41+
test('Can have multiple sites', function (): void {
4242
$collection = new MultisiteTestCollection;
4343

4444
expect($collection->sites())->toBe(
4545
['en', 'de']
4646
);
4747
});
4848

49-
test('Has slugs', function () {
49+
test('Has slugs', function (): void {
5050
$collection = new TestCollection;
5151

5252
expect($collection->slugs())->toBeTrue();

0 commit comments

Comments
 (0)