diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 94c95788..c6670a31 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -2,7 +2,6 @@ name: Psalm on: push: - branches: [master] paths: - '**.php' - 'psalm*' diff --git a/.github/workflows/test-laravel.yml b/.github/workflows/test-laravel.yml index 0390b0d1..50851e44 100644 --- a/.github/workflows/test-laravel.yml +++ b/.github/workflows/test-laravel.yml @@ -2,7 +2,6 @@ name: Test laravel projects on: push: - branches: [master] paths: - '**.php' - '**.stubphp' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9bde91e4..8dbf1d86 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,6 @@ name: Tests on: workflow_dispatch: push: - branches: [master] paths: - '**.php' - '**.stubphp' diff --git a/composer.json b/composer.json index e56649fc..13b8485a 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,7 @@ "phpunit/phpunit": "^10.5 || ^11.0", "phpyh/psalm-tester": "^0.1.0", "ramsey/collection": "^1.3", + "rector/rector": "^1.0", "slevomat/coding-standard": "^8.8", "squizlabs/php_codesniffer": "*", "symfony/http-foundation": "^6.0 || ^7.0" @@ -74,6 +75,7 @@ "@test:type" ], "test:type": "phpunit --testsuite=type", - "test:unit": "phpunit --testsuite=unit" + "test:unit": "phpunit --testsuite=unit", + "rector": "./vendor/bin/rector --dry-run" } } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 812b8094..6a3abd58 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,24 +1,26 @@ - + + + + $abstract + + - - - config->get('auth.guards')]]> - + ?string |null]]> - config->get("auth.providers.$provider.model", null)]]> + config->get("auth.providers.{$provider}.model", null)]]> config->get('auth.defaults.guard')]]> - + null @@ -33,9 +35,9 @@ getFqClasslikeName()]]> - - - + array + array + array @@ -45,17 +47,17 @@ - + new TLiteralString($result) - - - + + + - + new TLiteralString($concrete) diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..ed2ea39f --- /dev/null +++ b/rector.php @@ -0,0 +1,34 @@ +withPaths(['src', 'tests']) + ->withPhpSets(php81: true) + ->withPreparedSets(deadCode: true, codingStyle: true, typeDeclarations: true) + ->withSkip([ + ReadOnlyPropertyRector::class, + ClosureToArrowFunctionRector::class, + FirstClassCallableRector::class, + NullToStrictStringFuncCallArgRector::class, + BooleanInIfConditionRuleFixerRector::class, + BooleanInBooleanNotRuleFixerRector::class, + RemoveUnusedPrivateMethodRector::class, + SimplifyUselessVariableRector::class, + NullableCompareToNullRector::class, + EncapsedStringsToSprintfRector::class, + StaticClosureRector::class, + SplitDoubleAssignRector::class, + ]); diff --git a/src/Fakes/FakeFilesystem.php b/src/Fakes/FakeFilesystem.php index 96d900b4..e6b20e89 100644 --- a/src/Fakes/FakeFilesystem.php +++ b/src/Fakes/FakeFilesystem.php @@ -6,8 +6,7 @@ final class FakeFilesystem extends Filesystem { - /** @var ?string */ - private $destination = ''; + private ?string $destination = ''; /** * Write the contents of a file. @@ -15,21 +14,17 @@ final class FakeFilesystem extends Filesystem * @param string $path * @param string $contents * @param bool $lock - * @return bool|int */ - public function put($path, $contents, $lock = false) + public function put($path, $contents, $lock = false): bool|int { - $destination = $this->destination !== null ? $this->destination : $path; + $destination = $this->destination ?? $path; $this->destination = null; return parent::put($destination, $contents, $lock); } - /** - * @return void - */ - public function setDestination(string $destination) + public function setDestination(string $destination): void { $this->destination = $destination; } diff --git a/src/Fakes/FakeModelsCommand.php b/src/Fakes/FakeModelsCommand.php index 391087ee..555aff56 100644 --- a/src/Fakes/FakeModelsCommand.php +++ b/src/Fakes/FakeModelsCommand.php @@ -19,15 +19,11 @@ class FakeModelsCommand extends ModelsCommand { /** @var list> */ - private $model_classes = []; + private array $model_classes = []; - /** @var SchemaAggregator */ - private $schema; - - public function __construct(Filesystem $files, SchemaAggregator $schema) + public function __construct(Filesystem $files, private SchemaAggregator $schema) { parent::__construct($files); - $this->schema = $schema; } /** @return list> */ @@ -66,7 +62,7 @@ public function getPropertiesFromTable($model): void return; } - $this->model_classes[] = get_class($model); + $this->model_classes[] = $model::class; $columns = $this->schema->tables[$table_name]->columns; @@ -74,7 +70,7 @@ public function getPropertiesFromTable($model): void $column_name = $column->name; if (in_array($column_name, $model->getDates(), true)) { - $get_type = $set_type = '\Illuminate\Support\Carbon'; + $get_type = $set_type = \Illuminate\Support\Carbon::class; } else { switch ($column->type) { case SchemaColumn::TYPE_STRING: @@ -101,7 +97,7 @@ public function getPropertiesFromTable($model): void if (!$column->options) { $get_type = $set_type = 'string'; } else { - $get_type = $set_type = '\'' . implode('\'|\'', $column->options) . '\''; + $get_type = $set_type = "'" . implode("'|'", $column->options) . "'"; } break; @@ -128,7 +124,7 @@ public function getPropertiesFromTable($model): void $this->setMethod( Str::camel("where_" . $column_name), '\Illuminate\Database\Eloquent\Builder', // @todo support custom EloquentBuilders - array('$value') + ['$value'] ); } } diff --git a/src/Handlers/Application/ContainerHandler.php b/src/Handlers/Application/ContainerHandler.php index 66caf7d0..e588b6d1 100644 --- a/src/Handlers/Application/ContainerHandler.php +++ b/src/Handlers/Application/ContainerHandler.php @@ -66,7 +66,7 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) * @see https://github.com/psalm/psalm-plugin-symfony/issues/25 * psalm needs to know about any classes that could be returned before analysis begins. This is a naive first approach */ - public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event) + public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event): void { if (!in_array($event->getStorage()->name, ApplicationInterfaceProvider::getApplicationInterfaceClassLikes())) { return; @@ -91,13 +91,13 @@ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event) if ($reflectionClass->isAnonymous()) { continue; } - } catch (Throwable $e) { + } catch (Throwable) { // cannot just catch binding exception as the following error is emitted within laravel: // Class 'Symfony\Component\Cache\Adapter\Psr16Adapter' not found continue; } - $className = get_class($concrete); + $className = $concrete::class; $filePath = $event->getStatementsSource()->getFilePath(); $fileStorage = $event->getCodebase()->file_storage_provider->get($filePath); $fileStorage->referenced_classlikes[strtolower($className)] = $className; diff --git a/src/Handlers/Auth/AuthConfigAnalyzer.php b/src/Handlers/Auth/AuthConfigAnalyzer.php index 63b43c1c..22094de7 100644 --- a/src/Handlers/Auth/AuthConfigAnalyzer.php +++ b/src/Handlers/Auth/AuthConfigAnalyzer.php @@ -14,11 +14,8 @@ final class AuthConfigAnalyzer { private static ?AuthConfigAnalyzer $instance = null; - private ConfigRepository $config; - - private function __construct(ConfigRepository $config) + private function __construct(private ConfigRepository $config) { - $this->config = $config; } public static function instance(): self @@ -43,17 +40,17 @@ public function getAuthenticatableFQCN(?string $guard = null): ?string } } - $provider = $this->config->get("auth.guards.$guard.provider"); + $provider = $this->config->get("auth.guards.{$guard}.provider"); if (! is_string($provider)) { return null; } - if ($this->config->get("auth.providers.$provider.driver") === 'database') { - return '\Illuminate\Auth\GenericUser'; + if ($this->config->get("auth.providers.{$provider}.driver") === 'database') { + return \Illuminate\Auth\GenericUser::class; } - return $this->config->get("auth.providers.$provider.model", null); + return $this->config->get("auth.providers.{$provider}.model", null); } public function getDefaultGuard(): ?string diff --git a/src/Handlers/Auth/GuardHandler.php b/src/Handlers/Auth/GuardHandler.php index b46d4cde..4c547d35 100644 --- a/src/Handlers/Auth/GuardHandler.php +++ b/src/Handlers/Auth/GuardHandler.php @@ -118,6 +118,7 @@ private static function findGuardNameInCallChain(MethodCall $methodCall): ?strin $previous_call = null; // exit from while loop } + unset($previous_call); if (! $call_contains_guard_name instanceof CallLike) { diff --git a/src/Handlers/Eloquent/ModelMethodHandler.php b/src/Handlers/Eloquent/ModelMethodHandler.php index 11f0fea6..4c0fc8b0 100644 --- a/src/Handlers/Eloquent/ModelMethodHandler.php +++ b/src/Handlers/Eloquent/ModelMethodHandler.php @@ -63,6 +63,7 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) if ($called_method_name_lowercase === null) { return null; } + $methodId = new MethodIdentifier($called_fq_classlike_name, $called_method_name_lowercase); $fake_method_call = new MethodCall( diff --git a/src/Handlers/Eloquent/ModelPropertyAccessorHandler.php b/src/Handlers/Eloquent/ModelPropertyAccessorHandler.php index b108ce07..b9686754 100644 --- a/src/Handlers/Eloquent/ModelPropertyAccessorHandler.php +++ b/src/Handlers/Eloquent/ModelPropertyAccessorHandler.php @@ -82,7 +82,7 @@ public static function getPropertyType(PropertyTypeProviderEvent $event): ?Type\ if (self::accessorExists($codebase, $fq_classlike_name, $property_name)) { $attributeGetterName = 'get' . str_replace('_', '', $property_name) . 'Attribute'; - return $codebase->getMethodReturnType("$fq_classlike_name::$attributeGetterName", $fq_classlike_name) + return $codebase->getMethodReturnType("{$fq_classlike_name}::{$attributeGetterName}", $fq_classlike_name) ?: Type::getMixed(); } @@ -94,7 +94,7 @@ private static function hasNativeProperty(string $fqcn, string $property_name): { try { new \ReflectionProperty($fqcn, $property_name); - } catch (\ReflectionException $exception) { + } catch (\ReflectionException) { return false; } diff --git a/src/Handlers/Eloquent/ModelRelationshipPropertyHandler.php b/src/Handlers/Eloquent/ModelRelationshipPropertyHandler.php index f2ffed0f..594306b4 100644 --- a/src/Handlers/Eloquent/ModelRelationshipPropertyHandler.php +++ b/src/Handlers/Eloquent/ModelRelationshipPropertyHandler.php @@ -152,13 +152,6 @@ public static function getPropertyType(PropertyTypeProviderEvent $event): ?Union return null; } - /** - * @param Codebase $codebase - * @param string $fq_classlike_name - * @param string $property_name - * - * @return bool - */ private static function relationExists(Codebase $codebase, string $fq_classlike_name, string $property_name): bool { // @todo: ensure this is a relation method diff --git a/src/Handlers/Eloquent/Schema/SchemaAggregator.php b/src/Handlers/Eloquent/Schema/SchemaAggregator.php index 404b5419..bd8fa246 100644 --- a/src/Handlers/Eloquent/Schema/SchemaAggregator.php +++ b/src/Handlers/Eloquent/Schema/SchemaAggregator.php @@ -458,6 +458,7 @@ private function processColumnUpdates(string $table_name, string $call_arg_name, if ($second_arg instanceof PhpParser\Node\Scalar\String_) { $table->renameColumn($column_name, $second_arg->value); } + break; case 'set': @@ -479,6 +480,7 @@ private function processColumnUpdates(string $table_name, string $call_arg_name, // @todo extract nullable value from 3rd arg $table->renameColumn($_column_type, $column_name); } + break; } } diff --git a/src/Handlers/Eloquent/Schema/SchemaColumn.php b/src/Handlers/Eloquent/Schema/SchemaColumn.php index 9d8dc86a..bbf09fb2 100644 --- a/src/Handlers/Eloquent/Schema/SchemaColumn.php +++ b/src/Handlers/Eloquent/Schema/SchemaColumn.php @@ -5,10 +5,15 @@ class SchemaColumn { public const TYPE_STRING = 'string'; + public const TYPE_INT = 'int'; + public const TYPE_FLOAT = 'float'; + public const TYPE_BOOL = 'bool'; + public const TYPE_ENUM = 'enum'; + public const TYPE_MIXED = 'mixed'; /** @var string */ @@ -35,6 +40,6 @@ public function __construct( $this->name = $name; $this->type = $type; $this->nullable = $nullable; - $this->options = $options !== null ? $options : []; + $this->options = $options ?? []; } } diff --git a/src/Handlers/SuppressHandler.php b/src/Handlers/SuppressHandler.php index 99bb7aab..17cc4f75 100644 --- a/src/Handlers/SuppressHandler.php +++ b/src/Handlers/SuppressHandler.php @@ -10,8 +10,8 @@ use function array_intersect; use function in_array; -use function strpos; use function strtolower; +use function str_starts_with; class SuppressHandler implements AfterClassLikeVisitInterface { @@ -76,7 +76,7 @@ class SuppressHandler implements AfterClassLikeVisitInterface ] ]; - public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event) + public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event): void { $class = $event->getStorage(); @@ -95,7 +95,7 @@ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event) foreach (self::BY_NAMESPACE as $issue => $namespaces) { foreach ($namespaces as $namespace) { - if (0 !== strpos($class->name, "$namespace\\")) { + if (!str_starts_with($class->name, "{$namespace}\\")) { continue; } @@ -106,7 +106,7 @@ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event) foreach (self::BY_NAMESPACE_METHOD as $issue => $methods_by_namespaces) { foreach ($methods_by_namespaces as $namespace => $method_names) { - if (0 !== strpos($class->name, "$namespace\\")) { + if (!str_starts_with($class->name, "{$namespace}\\")) { continue; } @@ -146,7 +146,6 @@ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event) } /** - * @param string $issue * @param ClassLikeStorage|PropertyStorage|MethodStorage|null $storage */ private static function suppress(string $issue, $storage): void diff --git a/src/Plugin.php b/src/Plugin.php index 957ae52b..2da1512c 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -42,8 +42,8 @@ public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement try { ApplicationProvider::bootApp(); $this->generateStubFiles(); - } catch (\Throwable $t) { - fwrite(\STDERR, "Laravel plugin error: “{$t->getMessage()}”\n"); + } catch (\Throwable $throwable) { + fwrite(\STDERR, "Laravel plugin error: “{$throwable->getMessage()}”\n"); return; } diff --git a/src/Providers/ApplicationProvider.php b/src/Providers/ApplicationProvider.php index 0510bbc5..dacb4f15 100644 --- a/src/Providers/ApplicationProvider.php +++ b/src/Providers/ApplicationProvider.php @@ -5,6 +5,7 @@ namespace Psalm\LaravelPlugin\Providers; use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider; +use Illuminate\Container\Container; use Illuminate\Contracts\Console\Kernel; use Illuminate\Foundation\Application as LaravelApplication; use Orchestra\Testbench\Concerns\CreatesApplication; @@ -21,8 +22,7 @@ final class ApplicationProvider { use CreatesApplication; - /** @var LaravelApplication|null */ - private static $app = null; + private static ?\Illuminate\Foundation\Application $app = null; public static function bootApp(): void { @@ -38,7 +38,7 @@ public static function bootApp(): void public static function getApp(): LaravelApplication { - if (self::$app instanceof \Illuminate\Container\Container) { + if (self::$app instanceof Container) { return self::$app; } @@ -70,33 +70,29 @@ public static function getApp(): LaravelApplication */ public static function getAppFullyQualifiedClassName(): string { - return get_class(self::getApp()); + return self::getApp()::class; } /** * Overrides {@see \Orchestra\Testbench\Concerns\CreatesApplication::resolveApplicationBootstrappers} * Resolve application bootstrapper. - * - * @param LaravelApplication $app - * - * @return void */ - protected function resolveApplicationBootstrappers($app) + protected function resolveApplicationBootstrappers(LaravelApplication $app): void { // we want to keep the default psalm exception handler, otherwise the Laravel one will always return exit codes // of 0 //$app->make('Illuminate\Foundation\Bootstrap\HandleExceptions')->bootstrap($app); /** @psalm-suppress MixedMethodCall */ - $app->make('Illuminate\Foundation\Bootstrap\RegisterFacades')->bootstrap($app); + $app->make(\Illuminate\Foundation\Bootstrap\RegisterFacades::class)->bootstrap($app); /** @psalm-suppress MixedMethodCall */ - $app->make('Illuminate\Foundation\Bootstrap\SetRequestForConsole')->bootstrap($app); + $app->make(\Illuminate\Foundation\Bootstrap\SetRequestForConsole::class)->bootstrap($app); /** @psalm-suppress MixedMethodCall */ - $app->make('Illuminate\Foundation\Bootstrap\RegisterProviders')->bootstrap($app); + $app->make(\Illuminate\Foundation\Bootstrap\RegisterProviders::class)->bootstrap($app); $this->getEnvironmentSetUp($app); /** @psalm-suppress MixedMethodCall */ - $app->make('Illuminate\Foundation\Bootstrap\BootProviders')->bootstrap($app); + $app->make(\Illuminate\Foundation\Bootstrap\BootProviders::class)->bootstrap($app); foreach ($this->getPackageBootstrappers($app) as $bootstrap) { /** @psalm-suppress MixedMethodCall */ @@ -104,7 +100,7 @@ protected function resolveApplicationBootstrappers($app) } /** @psalm-suppress MixedMethodCall */ - $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); + $app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap(); /** @var \Illuminate\Routing\Router $router */ $router = $app['router']; @@ -114,15 +110,12 @@ protected function resolveApplicationBootstrappers($app) * @psalm-suppress MissingClosureParamType * @psalm-suppress UnusedClosureParam */ - $app->resolving('url', static function ($url, $app) use ($router) { + $app->resolving('url', static function ($url, $app) use ($router): void { $router->getRoutes()->refreshNameLookups(); }); } - /** - * @param LaravelApplication $app - */ - protected function getEnvironmentSetUp($app): void + protected function getEnvironmentSetUp(LaravelApplication $app): void { /** @var \Illuminate\Config\Repository $config */ $config = $app['config']; diff --git a/src/Providers/GeneratesStubs.php b/src/Providers/GeneratesStubs.php index 73ee06a9..f06dd83c 100644 --- a/src/Providers/GeneratesStubs.php +++ b/src/Providers/GeneratesStubs.php @@ -5,5 +5,6 @@ interface GeneratesStubs { public static function generateStubFile(): void; + public static function getStubFileLocation(): string; } diff --git a/src/Providers/ModelStubProvider.php b/src/Providers/ModelStubProvider.php index 52ed780b..326dbc19 100644 --- a/src/Providers/ModelStubProvider.php +++ b/src/Providers/ModelStubProvider.php @@ -16,7 +16,7 @@ final class ModelStubProvider implements GeneratesStubs { /** @var list> */ - private static $model_classes = []; + private static array $model_classes = []; public static function generateStubFile(): void { diff --git a/src/Util/ContainerResolver.php b/src/Util/ContainerResolver.php index 7db95ff7..976f51b3 100644 --- a/src/Util/ContainerResolver.php +++ b/src/Util/ContainerResolver.php @@ -23,10 +23,9 @@ final class ContainerResolver { /** * map of abstract to concrete class fqn - * @var array * @psalm-var array */ - private static $cache = []; + private static array $cache = []; /** * @psalm-return class-string|string|null @@ -41,7 +40,7 @@ private static function resolveFromApplicationContainer(string $abstract): ?stri try { /** @var mixed $concrete */ $concrete = ApplicationProvider::getApp()->make($abstract); - } catch (\Throwable $e) { + } catch (\Throwable) { return null; } @@ -50,7 +49,7 @@ private static function resolveFromApplicationContainer(string $abstract): ?stri $concreteClass = $concrete; } elseif (is_object($concrete)) { // normally we have an object resolved - $concreteClass = get_class($concrete); + $concreteClass = $concrete::class; } else { // not sure how to handle this yet return null; @@ -66,7 +65,7 @@ private static function resolveFromApplicationContainer(string $abstract): ?stri */ public static function resolvePsalmTypeFromApplicationContainerViaArgs(NodeTypeProvider $nodeTypeProvider, array $call_args): ?Union { - if (! count($call_args)) { + if ($call_args === []) { return null; } diff --git a/tests/Application/app/Models/AbstractUuidModel.php b/tests/Application/app/Models/AbstractUuidModel.php index 08b10058..49831c77 100644 --- a/tests/Application/app/Models/AbstractUuidModel.php +++ b/tests/Application/app/Models/AbstractUuidModel.php @@ -15,7 +15,7 @@ protected static function boot() { parent::boot(); - static::creating(function (Model $model) { + static::creating(function (Model $model): void { $model->setAttribute('uuid', Str::uuid()); }); } diff --git a/tests/Unit/Handlers/Eloquent/Schema/AbstractSchemaAggregatorTestCase.php b/tests/Unit/Handlers/Eloquent/Schema/AbstractSchemaAggregatorTestCase.php index ae4531a7..ffe48325 100644 --- a/tests/Unit/Handlers/Eloquent/Schema/AbstractSchemaAggregatorTestCase.php +++ b/tests/Unit/Handlers/Eloquent/Schema/AbstractSchemaAggregatorTestCase.php @@ -44,7 +44,7 @@ final protected function instantiateSchemaAggregator(string $filepath): SchemaAg foreach ($migrationFiles as $migrationFile) { $fileContents = file_get_contents($migrationFile); if ($fileContents === false) { - $this->fail("Could not read $migrationFile file. Please make sure it exists and readable."); + $this->fail("Could not read {$migrationFile} file. Please make sure it exists and readable."); } $statements = StatementsProvider::parseStatements($fileContents, PHP_VERSION_ID, $hasErrors); @@ -119,7 +119,7 @@ protected function assertSchemaHasTableAndNullableColumnOfType(string $tableWith [$tableName, $columnName] = self::parseTableWithColumn($tableWithColumn); - self::assertTrue($schemaAggregator->tables[$tableName]->columns[$columnName]->nullable, "Column $tableWithColumn is not nullable"); + self::assertTrue($schemaAggregator->tables[$tableName]->columns[$columnName]->nullable, "Column {$tableWithColumn} is not nullable"); } protected function assertSchemaHasTableAndNotNullableColumnOfType(string $tableWithColumn, string $type, SchemaAggregator $schemaAggregator): void @@ -128,11 +128,10 @@ protected function assertSchemaHasTableAndNotNullableColumnOfType(string $tableW [$tableName, $columnName] = self::parseTableWithColumn($tableWithColumn); - self::assertFalse($schemaAggregator->tables[$tableName]->columns[$columnName]->nullable, "Column $tableWithColumn is nullable"); + self::assertFalse($schemaAggregator->tables[$tableName]->columns[$columnName]->nullable, "Column {$tableWithColumn} is nullable"); } /** - * @param string $tableWithColumn * @return array{0: non-empty-string, 1: non-empty-string} */ private function parseTableWithColumn(string $tableWithColumn): array diff --git a/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_anon/2014_10_12_000000_create_users_table.php b/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_anon/2014_10_12_000000_create_users_table.php index beb06a36..33949925 100644 --- a/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_anon/2014_10_12_000000_create_users_table.php +++ b/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_anon/2014_10_12_000000_create_users_table.php @@ -7,12 +7,10 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { - Schema::create('users', function (Blueprint $table) { + Schema::create('users', function (Blueprint $table): void { $table->id(); $table->string('name'); $table->string('email')->unique(); @@ -25,10 +23,8 @@ public function up() /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('users'); } diff --git a/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_named/2014_10_12_000000_create_users_table.php b/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_named/2014_10_12_000000_create_users_table.php index 16e0768e..3abad593 100644 --- a/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_named/2014_10_12_000000_create_users_table.php +++ b/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_named/2014_10_12_000000_create_users_table.php @@ -8,12 +8,10 @@ class CreateUsersTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { - Schema::create('users', function (Blueprint $table) { + Schema::create('users', function (Blueprint $table): void { $table->id(); $table->string('name'); $table->string('email')->unique(); @@ -23,12 +21,11 @@ public function up() $table->timestamps(); }); } + /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('users'); } diff --git a/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_root_ns_facade/2014_10_12_000000_create_users_table.php b/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_root_ns_facade/2014_10_12_000000_create_users_table.php index f1110f10..470a9670 100644 --- a/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_root_ns_facade/2014_10_12_000000_create_users_table.php +++ b/tests/Unit/Handlers/Eloquent/Schema/migrations/default_users_table_root_ns_facade/2014_10_12_000000_create_users_table.php @@ -6,12 +6,10 @@ return new class extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { - Schema::create('users', function (Blueprint $table) { + Schema::create('users', function (Blueprint $table): void { $table->id(); $table->string('name'); $table->string('email')->unique(); @@ -24,10 +22,8 @@ public function up() /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('users'); }