diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index dc753dc..5209c60 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -39,8 +39,8 @@ jobs: - name: Execute Unit Tests run: composer test - check-style: - name: Check Code Style + fix-style: + name: Fix Code Style timeout-minutes: 15 runs-on: ubuntu-latest env: @@ -55,10 +55,20 @@ jobs: with: php-version: 7.4 coverage: none - + tools: composer:v2 + - name: Install dependencies run: | composer remove phpro/grumphp vimeo/psalm --no-update --dev composer update --prefer-dist --no-suggest --no-progress - - run: composer check-style + - run: composer fix-style + continue-on-error: true + + # Revert modifications so they don't get commited 💥 + - run: git checkout -- composer.json + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: composer fix-style + commit_author: laravel-ide-helper diff --git a/composer.json b/composer.json index 57ad7dd..9787c2c 100644 --- a/composer.json +++ b/composer.json @@ -64,8 +64,8 @@ }, "scripts": { "analyze": "psalm", - "check-style": "phpcs -p --standard=PSR12 src/", - "fix-style": "phpcbf -p --standard=PSR12 src/", + "check-style": "phpcs -p --standard=PSR12 config/ resources/ src/ tests/ '--ignore=*__snapshots_*'", + "fix-style": "phpcbf -p --standard=PSR12 config/ resources/ src/ tests/ '--ignore=*__snapshots_*'", "test": "phpunit", "test-regenerate": "phpunit -d --update-snapshots" } diff --git a/config/ide-helper.php b/config/ide-helper.php index bec4fc9..c0b252a 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -99,7 +99,7 @@ return array( 'include_helpers' => false, 'helper_files' => array( - base_path().'/vendor/laravel/framework/src/Illuminate/Support/helpers.php', + base_path() . '/vendor/laravel/framework/src/Illuminate/Support/helpers.php', ), /* diff --git a/resources/views/helper.php b/resources/views/helper.php index 40dfecc..d4d2fb8 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -20,66 +20,63 @@ * @see https://github.com/barryvdh/laravel-ide-helper */ - $aliases): ?> - + $aliases) : ?> + namespace { - - - getDocComment(' ')) ?> - getClassType() ?> getExtendsClass() ?> { - getMethods() as $method): ?> - - getDocComment(' ')) ?> + + getDocComment(' ')) ?> + getClassType() ?> getExtendsClass() ?> { + getMethods() as $method) : ?> + getDocComment(' ')) ?> public static function getName() ?>(getParamsWithDefault() ?>) - {getDeclaringClass() !== $method->getRoot()): ?> - + {getDeclaringClass() !== $method->getRoot()) : ?> //Method inherited from getDeclaringClass() ?> - + - isInstanceCall()):?> + isInstanceCall()) :?> /** @var getRoot()?> $instance */ - shouldReturn() ? 'return ': '' ?>getRootMethodCall() ?>; + shouldReturn() ? 'return ' : '' ?>getRootMethodCall() ?>; } } - + } - $aliases): ?> + $aliases) : ?> namespace { - - - getClassType() ?> getShortName() ?> extends getExtends() ?> {getExtendsNamespace() == '\Illuminate\Database\Eloquent'): ?> - getMethods() as $method): ?> - getDocComment(' ')) ?> + + getClassType() ?> getShortName() ?> extends getExtends() ?> {getExtendsNamespace() == '\Illuminate\Database\Eloquent') : ?> + getMethods() as $method) : ?> + getDocComment(' ')) ?> public static function getName() ?>(getParamsWithDefault() ?>) - {getDeclaringClass() !== $method->getRoot()): ?> - + {getDeclaringClass() !== $method->getRoot()) : ?> //Method inherited from getDeclaringClass() ?> - + - isInstanceCall()):?> + isInstanceCall()) :?> /** @var getRoot()?> $instance */ - shouldReturn() ? 'return ': '' ?>getRootMethodCall() ?>; + shouldReturn() ? 'return ' : '' ?>getRootMethodCall() ?>; } - -} - + + } + } - + namespace { - + } - + namespace Illuminate\Support { /** * Methods commonly used in migrations @@ -106,7 +103,7 @@ namespace Illuminate\Support { } - + namespace getNamespaceName()?> { /** * @method \Illuminate\Database\Eloquent\Collection|getShortName()?>[]|getShortName()?> create($attributes = []) diff --git a/resources/views/meta.php b/resources/views/meta.php index bcac7d6..51d87da 100644 --- a/resources/views/meta.php +++ b/resources/views/meta.php @@ -10,22 +10,22 @@ namespace PHPSTORM_META { * @author Barry vd. Heuvel * @see https://github.com/barryvdh/laravel-ide-helper */ - + override(, map([ '' => '@', - $class): ?> + $class) : ?> '' => \::class, - + ])); - - override(\factory(0), map([ + + override(\factory(0), map([ '' => '@FactoryBuilder', - + 'getName() ?>' => \getName() ?>FactoryBuilder::class, - - ])); + + ])); override(\Illuminate\Support\Arr::add(0), type(0)); diff --git a/tests/Console/ModelsCommand/AbstractModelsCommand.php b/tests/Console/ModelsCommand/AbstractModelsCommand.php index 4ea52ef..d2fce45 100644 --- a/tests/Console/ModelsCommand/AbstractModelsCommand.php +++ b/tests/Console/ModelsCommand/AbstractModelsCommand.php @@ -1,4 +1,6 @@ -shouldReceive('get') - ->andReturn(file_get_contents(__DIR__.'/Models/CustomCast.php')) + ->andReturn(file_get_contents(__DIR__ . '/Models/CustomCast.php')) ->once(); $mockFilesystem ->shouldReceive('put') diff --git a/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test_it_parses_casted_properties_correctly__1.php b/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test_it_parses_casted_properties_correctly__1.php index ec49d7b..a431f81 100644 --- a/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test_it_parses_casted_properties_correctly__1.php +++ b/tests/Console/ModelsCommand/LaravelCustomCasts/__snapshots__/Test__test_it_parses_casted_properties_correctly__1.php @@ -1,4 +1,6 @@ -assertSame($output, $method->getDocComment('')); $this->assertSame('setName', $method->getName()); - $this->assertSame('\\'.ExampleClass::class, $method->getDeclaringClass()); + $this->assertSame('\\' . ExampleClass::class, $method->getDeclaringClass()); $this->assertSame('$last, $first, ...$middle', $method->getParams(true)); $this->assertSame(['$last', '$first', '...$middle'], $method->getParams(false)); $this->assertSame('$last, $first = \'Barry\', ...$middle', $method->getParamsWithDefault(true)); @@ -68,7 +68,7 @@ class ExampleTest extends TestCase */'; $this->assertSame($output, $method->getDocComment('')); $this->assertSame('with', $method->getName()); - $this->assertSame('\\'.Builder::class, $method->getDeclaringClass()); + $this->assertSame('\\' . Builder::class, $method->getDeclaringClass()); $this->assertSame('$relations', $method->getParams(true)); $this->assertSame(['$relations'], $method->getParams(false)); $this->assertSame('$relations', $method->getParamsWithDefault(true)); diff --git a/tests/TestCase.php b/tests/TestCase.php index 0c7f82a..05f2caf 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,4 +1,6 @@ -