Skip to content

Commit a612da5

Browse files
Laravel 9.x Compatibility (#538)
1 parent b3877c9 commit a612da5

34 files changed

+140
-256
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
php-version: [7.3, 7.4, 8.0]
19+
php-version: [8.0, 8.1]
2020

2121
os: [ubuntu-latest, windows-latest, macos-latest]
2222

.github/workflows/demo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
php-version: [7.3, 7.4]
29-
laravel-version: [6, 7, 8]
28+
php-version: [8.0, 8.1]
29+
laravel-version: [9]
3030
os: [ubuntu-latest]
3131

3232
runs-on: ${{ matrix.os }}

.github/workflows/phplint.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ on: [pull_request]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
98

109
steps:
1110
- uses: actions/checkout@v2
1211

13-
- uses: jasonmccreary/PHP-Lint@fetch-signature
12+
- name: Setup PHP
13+
uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: '8.0'
16+
tools: phplint, php-cs-fixer
1417

1518
- name: Validate composer.json and composer.lock
1619
run: composer validate
20+
21+
- name: Check syntax
22+
run: phplint .

composer.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
],
99
"license": "MIT",
1010
"require": {
11-
"doctrine/dbal": "^2.9 || ^3.0",
12-
"illuminate/console": "^8.0",
13-
"illuminate/filesystem": "^8.0",
14-
"illuminate/support": "^8.0",
11+
"doctrine/dbal": "^3.3",
12+
"illuminate/console": "^9.0",
13+
"illuminate/filesystem": "^9.0",
14+
"illuminate/support": "^9.0",
1515
"laravel-shift/faker-registry": "^0.1",
16-
"symfony/yaml": "^5.1.4"
16+
"symfony/yaml": "^6.0"
1717
},
1818
"require-dev": {
19-
"mockery/mockery": "^1.3",
20-
"orchestra/testbench": "^6.0",
21-
"phpunit/phpunit": "^9.3"
19+
"mockery/mockery": "^1.4.4",
20+
"orchestra/testbench": "^7.0",
21+
"phpunit/phpunit": "^9.5.10"
2222
},
2323
"suggest": {
2424
"jasonmccreary/laravel-test-assertions": "Required to use additional assertions in generated tests (^1.0)."
@@ -42,5 +42,7 @@
4242
"psr-4": {
4343
"Tests\\": "tests/"
4444
}
45-
}
45+
},
46+
"minimum-stability": "dev",
47+
"prefer-stable": true
4648
}

src/Blueprint.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,41 +44,31 @@ public function parse($content, $strip_dashes = true)
4444

4545
$content = preg_replace_callback(
4646
'/^(\s+)(id|timestamps(Tz)?|softDeletes(Tz)?)$/mi',
47-
function ($matches) {
48-
return $matches[1] . strtolower($matches[2]) . ': ' . $matches[2];
49-
},
47+
fn ($matches) => $matches[1] . strtolower($matches[2]) . ': ' . $matches[2],
5048
$content
5149
);
5250

5351
$content = preg_replace_callback(
5452
'/^(\s+)(id|timestamps(Tz)?|softDeletes(Tz)?): true$/mi',
55-
function ($matches) {
56-
return $matches[1] . strtolower($matches[2]) . ': ' . $matches[2];
57-
},
53+
fn ($matches) => $matches[1] . strtolower($matches[2]) . ': ' . $matches[2],
5854
$content
5955
);
6056

6157
$content = preg_replace_callback(
6258
'/^(\s+)resource?$/mi',
63-
function ($matches) {
64-
return $matches[1] . 'resource: web';
65-
},
59+
fn ($matches) => $matches[1] . 'resource: web',
6660
$content
6761
);
6862

6963
$content = preg_replace_callback(
7064
'/^(\s+)invokable?$/mi',
71-
function ($matches) {
72-
return $matches[1] . 'invokable: true';
73-
},
65+
fn ($matches) => $matches[1] . 'invokable: true',
7466
$content
7567
);
7668

7769
$content = preg_replace_callback(
7870
'/^(\s+)uuid(: true)?$/mi',
79-
function ($matches) {
80-
return $matches[1] . 'id: uuid primary';
81-
},
71+
fn ($matches) => $matches[1] . 'id: uuid primary',
8272
$content
8373
);
8474

src/BlueprintServiceProvider.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,12 @@ public function register()
5454

5555
File::mixin(new FileMixins());
5656

57-
$this->app->bind('command.blueprint.build', function ($app) {
58-
return new BuildCommand($app['files'], app(Builder::class));
59-
});
60-
$this->app->bind('command.blueprint.erase', function ($app) {
61-
return new EraseCommand($app['files']);
62-
});
63-
$this->app->bind('command.blueprint.trace', function ($app) {
64-
return new TraceCommand($app['files'], app(Tracer::class));
65-
});
66-
$this->app->bind('command.blueprint.new', function ($app) {
67-
return new NewCommand($app['files']);
68-
});
69-
$this->app->bind('command.blueprint.init', function ($app) {
70-
return new InitCommand();
71-
});
72-
$this->app->bind('command.blueprint.stubs', function ($app) {
73-
return new PublishStubsCommand();
74-
});
57+
$this->app->bind('command.blueprint.build', fn ($app) => new BuildCommand($app['files'], app(Builder::class)));
58+
$this->app->bind('command.blueprint.erase', fn ($app) => new EraseCommand($app['files']));
59+
$this->app->bind('command.blueprint.trace', fn ($app) => new TraceCommand($app['files'], app(Tracer::class)));
60+
$this->app->bind('command.blueprint.new', fn ($app) => new NewCommand($app['files']));
61+
$this->app->bind('command.blueprint.init', fn ($app) => new InitCommand());
62+
$this->app->bind('command.blueprint.stubs', fn ($app) => new PublishStubsCommand());
7563

7664
$this->app->singleton(Blueprint::class, function ($app) {
7765
$blueprint = new Blueprint();

src/Concerns/HandlesImports.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ protected function addImport(Model $model, $class)
1616
protected function buildImports(Model $model)
1717
{
1818
return collect($this->imports[$model->name()])
19-
->map(function ($class) {
20-
return "use {$class};";
21-
})
19+
->map(fn ($class) => "use {$class};")
2220
->unique()
2321
->sort()
2422
->implode(PHP_EOL);

src/EnumType.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ class EnumType extends Type
1414
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
1515
{
1616
$values = array_map(
17-
function ($val) {
18-
return "'" . $val . "'";
19-
},
17+
fn ($val) => "'" . $val . "'",
2018
$this->values
2119
);
2220

src/Generators/FactoryGenerator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ private function fillableColumns(array $columns): array
196196

197197
return array_filter(
198198
$columns,
199-
function (Column $column) {
200-
return !in_array('nullable', $column->modifiers());
201-
}
199+
fn (Column $column) => !in_array('nullable', $column->modifiers())
202200
);
203201
}
204202

src/Generators/MigrationGenerator.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,11 @@ protected function buildDefinition(Model $model)
221221

222222
// TODO: unset the proper modifier
223223
$modifiers = collect($modifiers)->reject(
224-
function ($modifier) use ($column) {
225-
return (is_array($modifier) && key($modifier) === 'foreign')
226-
|| (is_array($modifier) && key($modifier) === 'onDelete')
227-
|| (is_array($modifier) && key($modifier) === 'onUpdate')
228-
|| $modifier === 'foreign'
229-
|| ($modifier === 'nullable' && $this->isIdOrUuid($column->dataType()));
230-
}
224+
fn ($modifier) => (is_array($modifier) && key($modifier) === 'foreign')
225+
|| (is_array($modifier) && key($modifier) === 'onDelete')
226+
|| (is_array($modifier) && key($modifier) === 'onUpdate')
227+
|| $modifier === 'foreign'
228+
|| ($modifier === 'nullable' && $this->isIdOrUuid($column->dataType()))
231229
);
232230
}
233231

@@ -410,9 +408,7 @@ protected function getTablePath($tableName, Carbon $timestamp, $overwrite = fals
410408
if ($overwrite) {
411409
$migrations = collect($this->filesystem->files($dir))
412410
->filter(
413-
function (SplFileInfo $file) use ($name) {
414-
return str_contains($file->getFilename(), $name);
415-
}
411+
fn (SplFileInfo $file) => str_contains($file->getFilename(), $name)
416412
)
417413
->sort();
418414

@@ -451,9 +447,7 @@ protected function getPivotTableName(array $segments)
451447
{
452448
$isCustom = collect($segments)
453449
->filter(
454-
function ($segment) {
455-
return Str::contains($segment, ':');
456-
}
450+
fn ($segment) => Str::contains($segment, ':')
457451
)->first();
458452

459453
if ($isCustom) {
@@ -463,9 +457,7 @@ function ($segment) {
463457
}
464458

465459
$segments = array_map(
466-
function ($name) {
467-
return Str::snake($name);
468-
},
460+
fn ($name) => Str::snake($name),
469461
$segments
470462
);
471463
sort($segments);
@@ -504,9 +496,7 @@ protected function isNumericDefault(string $type, string $value): bool
504496

505497
return collect(self::UNSIGNABLE_TYPES)
506498
->contains(
507-
function ($value) use ($type) {
508-
return strtolower($value) === strtolower($type);
509-
}
499+
fn ($value) => strtolower($value) === strtolower($type)
510500
);
511501
}
512502

0 commit comments

Comments
 (0)