From 7df9fbeafca29a8186b084d583e710ecdb3c85d9 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 12 Sep 2024 18:59:37 +0200 Subject: [PATCH] tv tools (#1488) * add composer dependency analyser * fixup! add composer dependency analyser * add post --- rector.php | 5 ++++ resources/views/tools.blade.php | 6 +++++ src/Repository/ToolRepository.php | 44 +++++++++++++++++++++++++------ 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/rector.php b/rector.php index 8ed58261918..8976fe668ac 100644 --- a/rector.php +++ b/rector.php @@ -7,6 +7,11 @@ return RectorConfig::configure() ->withPaths([__DIR__ . '/src', __DIR__ . '/bootstrap/app.php', __DIR__ . '/config', __DIR__ . '/tests']) + ->withSkip([ + \Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector::class => [ + __DIR__ . '/src/Repository/ToolRepository.php', + ], + ]) ->withImportNames(removeUnusedImports: true) ->withRules([DeclareStrictTypesRector::class]) ->withPreparedSets( diff --git a/resources/views/tools.blade.php b/resources/views/tools.blade.php index 9ba4490840b..7bd0ac8c094 100644 --- a/resources/views/tools.blade.php +++ b/resources/views/tools.blade.php @@ -33,6 +33,12 @@
GitHub
+ @if ($tool->getPost()) +
+ Read Blog Post +
+ @endif + @if ($tool->isPhpstanExtension())
PHPStan extension
@endif diff --git a/src/Repository/ToolRepository.php b/src/Repository/ToolRepository.php index 595d643d9d4..e5fb6ec08e8 100644 --- a/src/Repository/ToolRepository.php +++ b/src/Repository/ToolRepository.php @@ -13,7 +13,9 @@ final class ToolRepository */ public function fetchAll(): array { - return [new Tool( + $tools = []; + + $tools[] = new Tool( 'Easy Coding Standard', 'First week when you come to a new project', 'Adds advanced coding standard fast', @@ -24,7 +26,9 @@ public function fetchAll(): array 'First run or dry-run' => 'vendor/bin/ecs', 'Fix coding standdard' => 'vendor/bin/ecs --fix', ], - ), new Tool( + ); + + $tools[] = new Tool( 'Type Coverage', 'When you reach PHP 7.0+ with scalar types', 'Helps you add type declarations 1 % at a time', @@ -43,7 +47,9 @@ public function fetchAll(): array # enable on PHP 8.3+ # constant: 5 PHPSTAN - ), new Tool( + ); + + $tools[] = new Tool( 'Class Leak', 'When you reach PHPStan level 2', 'Spots unused classes', @@ -53,7 +59,9 @@ public function fetchAll(): array [ 'Detect unused classes' => 'vendor/bin/class-leak check /src /tests', ] - ), new Tool( + ); + + $tools[] = new Tool( 'Unused public', 'When you reach PHPStan level 3/4', 'Removes unused public code you maintain', @@ -70,7 +78,21 @@ public function fetchAll(): array # properties: true # methods: true PHPSTAN - ), new Tool( + ); + + $tools[] = new Tool( + 'Composer Dependency Analyser', + 'When you reach PHPStan level 2/3', + 'Detect unused dependencies, transitional dependencies, missing classes and more', + 'https://github.com/shipmonk-rnd/composer-dependency-analyser', + '', + 'composer require shipmonk/composer-dependency-analyser --dev', + [ + 'Run' => 'vendor/bin/composer-dependency-analyser', + ] + ); + + $tools[] = new Tool( 'Swiss Knife', 'When you reach PHPStan level 3/4', 'Finalizes classes without children, makes class constants private and more', @@ -81,7 +103,9 @@ public function fetchAll(): array 'Finalize classes without children' => 'vendor/bin/swiss-knife finalize-classes /src /tests', 'Privatize local class constants' => 'vendor/bin/swiss-knife privatize-constants /src /tests', ] - ), new Tool( + ); + + $tools[] = new Tool( 'Type Perfect', 'When you reach PHPStan level 6', 'Help you remove mixed types from obviously known code', @@ -99,7 +123,9 @@ public function fetchAll(): array # narrow_param: true # narrow_return: true PHPSTAN - ), new Tool( + ); + + $tools[] = new Tool( 'Config Transformer', 'When you have Symfony configs in YAML', 'Converts YAML configs to PHP for you', @@ -109,6 +135,8 @@ public function fetchAll(): array [ 'Transform' => 'vendor/bin/config-transformer convert /config', ] - )]; + ); + + return $tools; } }