diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9313b3..7b933cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: - name: Run all QA tests run: | ./vendor/bin/phpmd src/ text phpmd-ruleset.xml - ./vendor/bin/phpstan analyse -c phpstan.neon + ./vendor/bin/phpstan analyse -c phpstan.neon.dist ./vendor/bin/testbench migrate:fresh --path=tests/Setup/Database/Migrations --realpath --seed ./vendor/bin/testbench package:test --coverage --min=80 tests env: diff --git a/.gitignore b/.gitignore index ba9b800..fb6d5e6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ ray.php /vendor /*.cache /workbench +phpstan.neon \ No newline at end of file diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..62105e7 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,12 @@ +includes: + - ./vendor/nunomaduro/larastan/extension.neon + +parameters: + level: 8 + checkGenericClassInNonGenericObjectType: false + universalObjectCratesClasses: + - 'Illuminate\Support\Fluent' + paths: + - src + excludePaths: + - src/Schema \ No newline at end of file diff --git a/src/AranguentServiceProvider.php b/src/AranguentServiceProvider.php index 574e306..417ccf9 100644 --- a/src/AranguentServiceProvider.php +++ b/src/AranguentServiceProvider.php @@ -51,12 +51,12 @@ public function register() $this->app->when(MigrationCreator::class) ->needs('$customStubPath') ->give(function () { - return __DIR__.'/../stubs'; + return __DIR__ . '/../stubs'; }); $this->app->when(IlluminateMigrationCreator::class) ->needs('$customStubPath') ->give(function () { - return __DIR__.'/../stubs'; + return __DIR__ . '/../stubs'; }); $this->app->resolving( diff --git a/src/Console/ModelMakeCommand.php b/src/Console/ModelMakeCommand.php index e1f4d82..30644c1 100644 --- a/src/Console/ModelMakeCommand.php +++ b/src/Console/ModelMakeCommand.php @@ -39,6 +39,6 @@ protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) ? $customPath - : __DIR__.$stub; + : __DIR__ . $stub; } } diff --git a/src/Schema/Concerns/Columns.php b/src/Schema/Concerns/Columns.php index 2333e12..621d9d0 100644 --- a/src/Schema/Concerns/Columns.php +++ b/src/Schema/Concerns/Columns.php @@ -19,8 +19,8 @@ public function hasColumn($column) $parameters = []; $parameters['handler'] = 'aql'; $parameters['explanation'] = "Checking if any document within the table has the '" - .implode(', ', (array) $column) - ."' column(s)."; + . implode(', ', (array) $column) + . "' column(s)."; $parameters['column'] = $column; return $this->addCommand('hasAttribute', $parameters); @@ -57,7 +57,7 @@ public function dropColumn($columns) $parameters = []; $parameters['handler'] = 'aql'; $parameters['attributes'] = $columns; - $parameters['explanation'] = 'Drop the following column(s): '.implode(',', $columns).'.'; + $parameters['explanation'] = 'Drop the following column(s): ' . implode(',', $columns) . '.'; return $this->addCommand('dropAttribute', compact('parameters')); } diff --git a/src/Schema/Concerns/Tables.php b/src/Schema/Concerns/Tables.php index efb75b6..db58114 100644 --- a/src/Schema/Concerns/Tables.php +++ b/src/Schema/Concerns/Tables.php @@ -39,7 +39,7 @@ protected function creating() public function executeCreateCommand($command) { if ($this->connection->pretending()) { - $this->connection->logQuery('/* '.$command->explanation." */\n", []); + $this->connection->logQuery('/* ' . $command->explanation . " */\n", []); return; } diff --git a/tests/Console/ConsoleAranguentConvertMigrationsCommandTest.php b/tests/Console/ConsoleAranguentConvertMigrationsCommandTest.php index b16cf1d..5a31ef4 100644 --- a/tests/Console/ConsoleAranguentConvertMigrationsCommandTest.php +++ b/tests/Console/ConsoleAranguentConvertMigrationsCommandTest.php @@ -7,8 +7,8 @@ beforeEach(function () { //Copy a stub with Illuminate usage to migrations directory - $stub = __DIR__.'/../Setup/Database/stubs/test_stub_for_migration_conversion.php'; - $this->conversionMigration = __DIR__.'/../Setup/Database/Migrations/test_migration_conversion.php'; + $stub = __DIR__ . '/../Setup/Database/stubs/test_stub_for_migration_conversion.php'; + $this->conversionMigration = __DIR__ . '/../Setup/Database/Migrations/test_migration_conversion.php'; copy($stub, $this->conversionMigration); }); diff --git a/tests/Database/ConnectionTest.php b/tests/Database/ConnectionTest.php index 97155ef..bf85cd2 100644 --- a/tests/Database/ConnectionTest.php +++ b/tests/Database/ConnectionTest.php @@ -16,7 +16,7 @@ test('change database name', function () { $initialName = $this->connection->getDatabaseName(); - $newName = $initialName.'New'; + $newName = $initialName . 'New'; $this->connection->setDatabaseName($newName); $currentName = $this->connection->getDatabaseName(); diff --git a/tests/Eloquent/ModelTest.php b/tests/Eloquent/ModelTest.php index 681b8b6..41d8a8b 100644 --- a/tests/Eloquent/ModelTest.php +++ b/tests/Eloquent/ModelTest.php @@ -16,7 +16,7 @@ ] )->run(); - $file = __DIR__.'/../../vendor/orchestra/testbench-core/laravel/app/Models/AranguentModelTest.php'; + $file = __DIR__ . '/../../vendor/orchestra/testbench-core/laravel/app/Models/AranguentModelTest.php'; //assert file exists expect($file)->toBeFile(); diff --git a/tests/Schema/GrammarTest.php b/tests/Schema/GrammarTest.php index d1cccd0..3782031 100644 --- a/tests/Schema/GrammarTest.php +++ b/tests/Schema/GrammarTest.php @@ -23,14 +23,14 @@ $parameters['name'] = 'hasAttribute'; $parameters['handler'] = 'aql'; $parameters['explanation'] = "Checking if any document within the collection has the '" - .implode(', ', $attributes)."' attribute(s)."; + . implode(', ', $attributes) . "' attribute(s)."; $parameters['columns'] = $attributes; $command = new Fluent($parameters); $results = $this->grammar->compileHasColumn($collection, $command); $this->assertEquals( 'FOR doc IN GrammarTestCollection FILTER doc.firstAttribute != null AND doc.SecondAttribute != null ' - .'AND doc.@theThirdAttribute != null LIMIT 1 RETURN true', + . 'AND doc.@theThirdAttribute != null LIMIT 1 RETURN true', $results->aqb ); }); @@ -46,14 +46,14 @@ $parameters['name'] = 'dropAttribute'; $parameters['handler'] = 'aql'; $parameters['attributes'] = $attributes; - $parameters['explanation'] = 'Drop the following attribute(s): '.implode(',', $attributes).'.'; + $parameters['explanation'] = 'Drop the following attribute(s): ' . implode(',', $attributes) . '.'; $command = new Fluent($parameters); $results = $this->grammar->compileDropAttribute($collection, $command); $this->assertEquals( 'FOR doc IN GrammarTestCollection FILTER doc.firstAttribute != null OR doc.SecondAttribute != null ' - .'OR doc.@theThirdAttribute != null UPDATE doc WITH ' - .'{"firstAttribute":null,"SecondAttribute":null,"@theThirdAttribute":null} ' - .'IN GrammarTestCollection OPTIONS {"keepNull":false}', + . 'OR doc.@theThirdAttribute != null UPDATE doc WITH ' + . '{"firstAttribute":null,"SecondAttribute":null,"@theThirdAttribute":null} ' + . 'IN GrammarTestCollection OPTIONS {"keepNull":false}', $results->aqb ); expect($results->aqb->collections['write'])->toEqual([$collection]); @@ -73,8 +73,8 @@ $results = $this->grammar->compileRenameAttribute($collection, $command); self::assertEquals( 'FOR doc IN GrammarTestCollection FILTER doc.oldAttributeName != null AND doc.newAttributeName == null' - .' UPDATE doc WITH {"oldAttributeName":null,"newAttributeName":doc.oldAttributeName} ' - .'IN GrammarTestCollection OPTIONS {"keepNull":true}', + . ' UPDATE doc WITH {"oldAttributeName":null,"newAttributeName":doc.oldAttributeName} ' + . 'IN GrammarTestCollection OPTIONS {"keepNull":true}', $results->aqb->query ); expect($results->aqb->collections['write'][0])->toEqual($collection);