Skip to content

Commit

Permalink
Change php-cs-fixer to laravel pint (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
ucan-lab authored Dec 31, 2022
1 parent 7663028 commit 8c5642d
Show file tree
Hide file tree
Showing 235 changed files with 836 additions and 2,973 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/php-cs-fixer.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Laravel Pint

on: [pull_request]

jobs:
pint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --prefer-dist --working-dir=tools/pint

- name: Laravel Pint Dry Run
run: ./tools/pint/vendor/bin/pint -v --test
49 changes: 0 additions & 49 deletions .php-cs-fixer.dist.php

This file was deleted.

14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
composer-install-tools:
composer install --working-dir=tools/php-cs-fixer
composer install --working-dir=tools/pint
composer install --working-dir=tools/phpstan
php-cs-version:
./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --version
php-cs-dry:
./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --verbose --dry-run
php-cs-dry-diff:
./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --verbose --diff --dry-run
php-cs-fix:
./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --verbose
phpstan:
pint:
./tools/pint/vendor/bin/pint -v
stan:
./tools/phpstan/vendor/bin/phpstan analyse -c phpstan.neon
test:
./vendor/bin/phpunit
30 changes: 30 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"preset": "laravel",
"exclude": [
"tests/Console/DacapoCommandTest"
],
"rules": {
"concat_space": false,
"date_time_immutable": true,
"declare_parentheses": true,
"declare_strict_types": true,
"final_class": true,
"global_namespace_import": {
"import_classes": true,
"import_constants": true,
"import_functions": true
},
"mb_str_functions": true,
"no_superfluous_phpdoc_tags": true,
"not_operator_with_successor_space": true,
"phpdoc_align": {
"align": "left"
},
"phpdoc_separation": false,
"php_unit_test_case_static_method_calls": {
"call_type": "this"
},
"simplified_if_return": true,
"simplified_null_return": true
}
}
17 changes: 3 additions & 14 deletions src/Dacapo/Application/UseCase/DacapoCommandUseCase.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Application\UseCase;

Expand All @@ -13,13 +15,6 @@

final class DacapoCommandUseCase
{
/**
* @param DatabaseSchemasStorage $databaseSchemasStorage
* @param DatabaseMigrationsStorage $databaseMigrationsStorage
* @param DatabaseDriver $databaseBuilder
* @param MigrationCreateStub $migrationCreateStub
* @param MigrationUpdateStub $migrationUpdateStub
*/
public function __construct(
private DatabaseSchemasStorage $databaseSchemasStorage,
private DatabaseMigrationsStorage $databaseMigrationsStorage,
Expand All @@ -29,9 +24,6 @@ public function __construct(
) {
}

/**
* @return DacapoCommandUseCaseOutput
*/
public function handle(): DacapoCommandUseCaseOutput
{
$schemaList = $this->databaseSchemasStorage->getSchemaList();
Expand All @@ -46,7 +38,6 @@ public function handle(): DacapoCommandUseCaseOutput
}

/**
* @param SchemaList $schemaList
* @return array<int, string>
*/
private function generateCreateTableMigrationFile(SchemaList $schemaList): array
Expand All @@ -64,7 +55,6 @@ private function generateCreateTableMigrationFile(SchemaList $schemaList): array
}

/**
* @param SchemaList $schemaList
* @return array<int, string>
*/
private function generateCreateIndexMigrationFile(SchemaList $schemaList): array
Expand All @@ -84,7 +74,6 @@ private function generateCreateIndexMigrationFile(SchemaList $schemaList): array
}

/**
* @param SchemaList $schemaList
* @return array<int, string>
*/
private function generateConstraintForeignKeyMigrationFile(SchemaList $schemaList): array
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Application\UseCase\Input;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Application\UseCase\Output;

Expand Down
7 changes: 3 additions & 4 deletions src/Dacapo/Console/DacapoClearCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Console;

Expand Down Expand Up @@ -30,9 +32,6 @@ final class DacapoClearCommand extends Command
*/
protected $description = 'Clear migration directory.';

/**
* @param Filesystem $filesystem
*/
public function handle(Filesystem $filesystem): void
{
$this->newLine();
Expand Down
9 changes: 4 additions & 5 deletions src/Dacapo/Console/DacapoCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Console;

Expand Down Expand Up @@ -32,16 +34,13 @@ final class DacapoCommand extends Command
*/
protected $description = 'Generate migrations from schemas and migrate:fresh command.';

/**
* @param DacapoCommandUseCase $useCase
*/
public function handle(
DacapoCommandUseCase $useCase,
): void {
$this->call('dacapo:clear', ['--force' => true]);

$this->newLine();
$this->components->info( 'Generating migration files.');
$this->components->info('Generating migration files.');

$output = $useCase->handle();

Expand Down
4 changes: 3 additions & 1 deletion src/Dacapo/Console/DacapoConfigPublishCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Console;

Expand Down
7 changes: 3 additions & 4 deletions src/Dacapo/Console/DacapoInitCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Console;

Expand Down Expand Up @@ -29,9 +31,6 @@ final class DacapoInitCommand extends Command
*/
protected $description = 'Init dacapo default schema.';

/**
* @param Filesystem $filesystem
*/
public function handle(Filesystem $filesystem): void
{
if (! is_dir($schemasPath = $this->laravel->databasePath('schemas'))) {
Expand Down
7 changes: 3 additions & 4 deletions src/Dacapo/Console/DacapoStubPublishCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Console;

Expand Down Expand Up @@ -27,9 +29,6 @@ final class DacapoStubPublishCommand extends Command
*/
protected $description = 'Publish dacapo stubs that are available for customization.';

/**
* @param Filesystem $filesystem
*/
public function handle(Filesystem $filesystem): void
{
if (! is_dir($stubsPath = $this->laravel->basePath('stubs'))) {
Expand Down
7 changes: 3 additions & 4 deletions src/Dacapo/Console/DacapoUninstallCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Console;

Expand Down Expand Up @@ -27,9 +29,6 @@ final class DacapoUninstallCommand extends Command
*/
protected $description = 'Uninstall dacapo.';

/**
* @param Filesystem $filesystem
*/
public function handle(Filesystem $filesystem): void
{
$this->newLine();
Expand Down
4 changes: 3 additions & 1 deletion src/Dacapo/Domain/MigrationFile/Driver/DatabaseDriver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Domain\MigrationFile\Driver;

Expand Down
16 changes: 3 additions & 13 deletions src/Dacapo/Domain/MigrationFile/MigrationFile.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Domain\MigrationFile;

Expand All @@ -8,8 +10,6 @@ final class MigrationFile

/**
* MigrationFile constructor.
* @param string $name
* @param string $contents
*/
private function __construct(
private string $name,
Expand All @@ -18,8 +18,6 @@ private function __construct(
}

/**
* @param string $name
* @param string $contents
* @return $this
*/
public static function factory(string $name, string $contents): self
Expand All @@ -28,8 +26,6 @@ public static function factory(string $name, string $contents): self
}

/**
* @param string $placeholder
* @param string $value
* @return $this
*/
public function replace(string $placeholder, string $value): self
Expand All @@ -39,17 +35,11 @@ public function replace(string $placeholder, string $value): self
return $this;
}

/**
* @return string
*/
public function getName(): string
{
return $this->name;
}

/**
* @return string
*/
public function getContents(): string
{
return $this->contents;
Expand Down
7 changes: 3 additions & 4 deletions src/Dacapo/Domain/MigrationFile/Stub/MigrationCreateStub.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace UcanLab\LaravelDacapo\Dacapo\Domain\MigrationFile\Stub;

interface MigrationCreateStub
{
/**
* @return string
*/
public function getStub(): string;

/**
Expand Down
Loading

0 comments on commit 8c5642d

Please sign in to comment.