From 787dcd85cd1802b0e232f85133418b5df7237601 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Tue, 25 Apr 2023 23:40:39 +0700 Subject: [PATCH 1/3] update format style --- .styleci.yml | 2 +- common/helpers.php | 8 +++---- resources/views/layouts/app.blade.php | 23 ++++++++++--------- src/Exceptions/LaravelGeneratorException.php | 6 ++--- src/Helpers/ConfigHelper.php | 8 +++---- .../Controllers/Asset/AssetController.php | 2 +- .../Controllers/Detect/DetectController.php | 22 +++++++++--------- .../Generator/GeneratorController.php | 2 -- .../RepositoryGeneratorController.php | 2 +- .../LaravelGeneratorController.php | 2 +- tests/Unit/DetectTest.php | 2 +- 11 files changed, 39 insertions(+), 40 deletions(-) diff --git a/.styleci.yml b/.styleci.yml index 7dfef79..0285f17 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1 +1 @@ -preset: psr12 \ No newline at end of file +preset: laravel diff --git a/common/helpers.php b/common/helpers.php index de27e15..2cc64d8 100644 --- a/common/helpers.php +++ b/common/helpers.php @@ -6,20 +6,20 @@ /** * Returns laravel-generator composer dist path. * - * @param string|null $asset string + * @param string|null $asset string * * @return string */ function laravel_generator_dist_path(string $asset = null): string { - $defaultPath = config('laravel-generator.defaults.paths.ui_package_path') . '/dist/'; + $defaultPath = config('laravel-generator.defaults.paths.ui_package_path').'/dist/'; $path = base_path(config('laravel-generator.defaults.paths.laravel_generator_assets_path', $defaultPath)); if (!$asset) { return realpath($path); } - return realpath($path . $asset); + return realpath($path.$asset); } } @@ -43,7 +43,7 @@ function laravel_generator_asset(string $asset): string $useAbsolutePath = config('laravel-generator.defaults.paths.use_absolute_path', true); - return route('laravel_generator.asset', ['asset' => $asset], $useAbsolutePath) . '?v=' . filemtime($file); + return route('laravel_generator.asset', ['asset' => $asset], $useAbsolutePath).'?v='.filemtime($file); } } diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index f10a186..79ab0c0 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -10,7 +10,8 @@ @yield('title', config('laravel-generator.app_name', __('laravel-generator::generator.app_name'))) - + @@ -21,17 +22,17 @@ - @include('laravel-generator::shared.left_bar') +@include('laravel-generator::shared.left_bar') -
- - @include('laravel-generator::shared.navbar') - +
+ + @include('laravel-generator::shared.navbar') + - @yield('laravel-generator-content') -
+ @yield('laravel-generator-content') +
- @include('laravel-generator::shared.configurator_settings') +@include('laravel-generator::shared.configurator_settings') - @include('laravel-generator::shared.footer') - \ No newline at end of file +@include('laravel-generator::shared.footer') + diff --git a/src/Exceptions/LaravelGeneratorException.php b/src/Exceptions/LaravelGeneratorException.php index 5292e59..23c7b6a 100644 --- a/src/Exceptions/LaravelGeneratorException.php +++ b/src/Exceptions/LaravelGeneratorException.php @@ -7,9 +7,9 @@ class LaravelGeneratorException extends Exception { /** - * @param string $message - * @param int $code - * @param Exception|null $previous + * @param string $message + * @param int $code + * @param Exception|null $previous */ public function __construct(string $message = '', int $code = 0, Exception $previous = null) { diff --git a/src/Helpers/ConfigHelper.php b/src/Helpers/ConfigHelper.php index 233c220..e073f60 100644 --- a/src/Helpers/ConfigHelper.php +++ b/src/Helpers/ConfigHelper.php @@ -9,7 +9,7 @@ class ConfigHelper /** * Get config * - * @param string|null $generatorName + * @param string|null $generatorName * * @return array * @throws LaravelGeneratorException @@ -33,8 +33,8 @@ public function generatorConfig(?string $generatorName = null): array /** * Merge config * - * @param array $defaults - * @param array $generatorName + * @param array $defaults + * @param array $generatorName * * @return array */ @@ -60,7 +60,7 @@ private function mergeConfig(array $defaults, array $generatorName): array /** * Check is associative key array * - * @param mixed $key + * @param mixed $key * * @return bool */ diff --git a/src/Http/Controllers/Asset/AssetController.php b/src/Http/Controllers/Asset/AssetController.php index b2189d6..3d6cd47 100644 --- a/src/Http/Controllers/Asset/AssetController.php +++ b/src/Http/Controllers/Asset/AssetController.php @@ -12,7 +12,7 @@ class AssetController extends BaseController { /** - * @param Request $request + * @param Request $request * * @return string */ diff --git a/src/Http/Controllers/Detect/DetectController.php b/src/Http/Controllers/Detect/DetectController.php index 05a0be5..ddabfff 100644 --- a/src/Http/Controllers/Detect/DetectController.php +++ b/src/Http/Controllers/Detect/DetectController.php @@ -27,13 +27,13 @@ public function getClassFromFile($file) } $namespace = $matches[1]; - $class = $namespace . '\\' . $matches[2]; + $class = $namespace.'\\'.$matches[2]; return class_exists($class) ? new ReflectionClass($class) : null; } /** - * @param ReflectionClass $class + * @param ReflectionClass $class * * @return bool */ @@ -51,7 +51,7 @@ private function dependsOnModels(ReflectionClass $class) /** * Check if the class implements the CRUD methods * - * @param ReflectionClass $class + * @param ReflectionClass $class * * @return bool */ @@ -80,7 +80,7 @@ protected function implementsCrudMethods(ReflectionClass $class) * and implement the CRUD methods * and have a dependency on a model * - * @param ReflectionClass $class + * @param ReflectionClass $class * * @return bool */ @@ -93,7 +93,7 @@ public function isRepositoryClass(ReflectionClass $class) * Check if the class is a service class * A service class must have a name ending with "Service" or "EloquentService" * - * @param ReflectionClass $class + * @param ReflectionClass $class * * @return bool */ @@ -108,7 +108,7 @@ public function isServiceClass(ReflectionClass $class) * and implement the CRUD methods * and have a dependency on a model * - * @param ReflectionClass $class + * @param ReflectionClass $class * * @return bool */ @@ -121,7 +121,7 @@ public function isControllerClass(ReflectionClass $class) * Check if the class is an action class * An action class must have a name ending with "Action" or "EloquentAction" * - * @param ReflectionClass $class + * @param ReflectionClass $class * * @return bool */ @@ -134,7 +134,7 @@ public function isActionClass(ReflectionClass $class) * Check if the class is a class of the given type * A class of the given type must have a name ending with the given type or "Eloquent" + the given type * - * @param ReflectionClass $class + * @param ReflectionClass $class * @param $type * * @return bool @@ -142,8 +142,8 @@ public function isActionClass(ReflectionClass $class) protected function checkClassType(ReflectionClass $class, $type) { $type = ucfirst($type); - return preg_match('/' . $type . '$/', $class->getName()) === 1 - || preg_match('/Eloquent' . $type . '$/', $class->getName()) === 1 + return preg_match('/'.$type.'$/', $class->getName()) === 1 + || preg_match('/Eloquent'.$type.'$/', $class->getName()) === 1 && $this->implementsCrudMethods($class) && $this->dependsOnModels($class); } @@ -151,7 +151,7 @@ protected function checkClassType(ReflectionClass $class, $type) /** * Get the type of the given class * - * @param ReflectionClass $class + * @param ReflectionClass $class * * @return string */ diff --git a/src/Http/Controllers/Generator/GeneratorController.php b/src/Http/Controllers/Generator/GeneratorController.php index 2e014ac..f74b77a 100644 --- a/src/Http/Controllers/Generator/GeneratorController.php +++ b/src/Http/Controllers/Generator/GeneratorController.php @@ -2,9 +2,7 @@ namespace Lbil\LaravelGenerator\Http\Controllers\Generator; -use Illuminate\Http\Request; use Illuminate\Routing\Controller; -use Illuminate\Support\Facades\DB; class GeneratorController extends Controller { diff --git a/src/Http/Controllers/Generator/RepositoryGeneratorController.php b/src/Http/Controllers/Generator/RepositoryGeneratorController.php index 72ab1b0..612de68 100644 --- a/src/Http/Controllers/Generator/RepositoryGeneratorController.php +++ b/src/Http/Controllers/Generator/RepositoryGeneratorController.php @@ -2,7 +2,7 @@ namespace Lbil\LaravelGenerator\Http\Controllers\Generator; -use Str; +use Illuminate\Support\Str; use Lbil\LaravelGenerator\Http\Controllers\Detect\DetectController; use Lbil\LaravelGenerator\Http\Requests\Generator\RepositoryGeneratorRequest; diff --git a/src/Http/Controllers/LaravelGeneratorController.php b/src/Http/Controllers/LaravelGeneratorController.php index 71d78b3..3998ba9 100644 --- a/src/Http/Controllers/LaravelGeneratorController.php +++ b/src/Http/Controllers/LaravelGeneratorController.php @@ -12,7 +12,7 @@ class LaravelGeneratorController extends Controller { /** - * @param Request $request + * @param Request $request * * @return Application|Factory|View */ diff --git a/tests/Unit/DetectTest.php b/tests/Unit/DetectTest.php index c0944fd..04291da 100644 --- a/tests/Unit/DetectTest.php +++ b/tests/Unit/DetectTest.php @@ -8,7 +8,7 @@ class DetectTest extends TestCase { - protected $detectController; + protected DetectController|Mockery\LegacyMockInterface|Mockery\MockInterface $detectController; /** * @return void From 4d11dbfe3ad4a6eafa4acf60502820337c377911 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Tue, 25 Apr 2023 23:45:39 +0700 Subject: [PATCH 2/3] update the format style with laravel --- common/helpers.php | 15 ++++----- src/Helpers/ConfigHelper.php | 12 +++---- .../Controllers/Asset/AssetController.php | 3 +- .../Controllers/Detect/DetectController.php | 33 ++++++++----------- .../RepositoryGeneratorController.php | 3 +- .../LaravelGeneratorController.php | 5 ++- src/Http/Requests/ApiRequest.php | 5 +-- .../LaravelGeneratorServiceProvider.php | 16 ++++----- tests/Unit/DetectTest.php | 6 ++-- 9 files changed, 40 insertions(+), 58 deletions(-) diff --git a/common/helpers.php b/common/helpers.php index 2cc64d8..b0ea976 100644 --- a/common/helpers.php +++ b/common/helpers.php @@ -2,12 +2,11 @@ use Lbil\LaravelGenerator\Exceptions\LaravelGeneratorException; -if (!function_exists('laravel_generator_dist_path')) { +if (! function_exists('laravel_generator_dist_path')) { /** * Returns laravel-generator composer dist path. * * @param string|null $asset string - * * @return string */ function laravel_generator_dist_path(string $asset = null): string @@ -15,7 +14,7 @@ function laravel_generator_dist_path(string $asset = null): string $defaultPath = config('laravel-generator.defaults.paths.ui_package_path').'/dist/'; $path = base_path(config('laravel-generator.defaults.paths.laravel_generator_assets_path', $defaultPath)); - if (!$asset) { + if (! $asset) { return realpath($path); } @@ -23,12 +22,11 @@ function laravel_generator_dist_path(string $asset = null): string } } -if (!function_exists('laravel_generator_asset')) { +if (! function_exists('laravel_generator_asset')) { /** * Returns asset from laravel-generator composer package. * * @param $asset string - * * @return string * * @throws LaravelGeneratorException @@ -37,7 +35,7 @@ function laravel_generator_asset(string $asset): string { $file = laravel_generator_dist_path($asset); - if (!file_exists($file)) { + if (! file_exists($file)) { throw new LaravelGeneratorException(sprintf('%s - this Laravel Generator asset does not exist', $asset)); } @@ -47,12 +45,11 @@ function laravel_generator_asset(string $asset): string } } -if (!function_exists('laravel_generator_dist_path_allowed')) { +if (! function_exists('laravel_generator_dist_path_allowed')) { /** * Returns asset allowed from laravel-generator composer package. * * @param $asset string - * * @return string * * @throws LaravelGeneratorException @@ -64,7 +61,7 @@ function laravel_generator_asset_allowed(string $asset): string 'favicon-32x32.png', ]; - if (!in_array($asset, $allowed_files)) { + if (! in_array($asset, $allowed_files)) { throw new LaravelGeneratorException(sprintf('%s - this Laravel Generator asset is not allowed', $asset)); } diff --git a/src/Helpers/ConfigHelper.php b/src/Helpers/ConfigHelper.php index e073f60..218e59b 100644 --- a/src/Helpers/ConfigHelper.php +++ b/src/Helpers/ConfigHelper.php @@ -7,11 +7,11 @@ class ConfigHelper { /** - * Get config + * Get config. * * @param string|null $generatorName - * * @return array + * * @throws LaravelGeneratorException */ public function generatorConfig(?string $generatorName = null): array @@ -23,7 +23,7 @@ public function generatorConfig(?string $generatorName = null): array $defaults = config('laravel-generator.defaults', []); $generators = config('laravel-generator.generators', []); - if (!isset($generators[$generatorName])) { + if (! isset($generators[$generatorName])) { throw new LaravelGeneratorException('Generator name not found'); } @@ -31,11 +31,10 @@ public function generatorConfig(?string $generatorName = null): array } /** - * Merge config + * Merge config. * * @param array $defaults * @param array $generatorName - * * @return array */ private function mergeConfig(array $defaults, array $generatorName): array @@ -58,10 +57,9 @@ private function mergeConfig(array $defaults, array $generatorName): array } /** - * Check is associative key array + * Check is associative key array. * * @param mixed $key - * * @return bool */ private function isAssociativeArray(mixed $key): bool diff --git a/src/Http/Controllers/Asset/AssetController.php b/src/Http/Controllers/Asset/AssetController.php index 3d6cd47..61f5f8f 100644 --- a/src/Http/Controllers/Asset/AssetController.php +++ b/src/Http/Controllers/Asset/AssetController.php @@ -13,7 +13,6 @@ class AssetController extends BaseController { /** * @param Request $request - * * @return string */ public function index(Request $request) @@ -28,7 +27,7 @@ public function index(Request $request) $fileSystem->get($path), 200, [ - 'Content-Type' => (pathinfo($asset))['extension'] == 'css' + 'Content-Type' => pathinfo($asset)['extension'] == 'css' ? 'text/css' : 'application/javascript', ] diff --git a/src/Http/Controllers/Detect/DetectController.php b/src/Http/Controllers/Detect/DetectController.php index ddabfff..d379a4b 100644 --- a/src/Http/Controllers/Detect/DetectController.php +++ b/src/Http/Controllers/Detect/DetectController.php @@ -12,7 +12,6 @@ class DetectController extends Controller { /** * @param $file - * * @return ReflectionClass|null */ public function getClassFromFile($file) @@ -22,7 +21,7 @@ public function getClassFromFile($file) // Match namespace and class name preg_match('/namespace\s+(.*?);.*?class\s+(\w+)/s', $content, $matches); - if (!isset($matches[1]) || !isset($matches[2])) { + if (! isset($matches[1]) || ! isset($matches[2])) { return null; } @@ -34,7 +33,6 @@ public function getClassFromFile($file) /** * @param ReflectionClass $class - * * @return bool */ private function dependsOnModels(ReflectionClass $class) @@ -45,14 +43,14 @@ private function dependsOnModels(ReflectionClass $class) return true; } } + return false; } /** - * Check if the class implements the CRUD methods + * Check if the class implements the CRUD methods. * * @param ReflectionClass $class - * * @return bool */ protected function implementsCrudMethods(ReflectionClass $class) @@ -62,7 +60,7 @@ protected function implementsCrudMethods(ReflectionClass $class) 'create', 'read', 'update', - 'delete' + 'delete', ]; foreach ($methods as $method) { @@ -78,10 +76,9 @@ protected function implementsCrudMethods(ReflectionClass $class) * Check if the class is a repository class * A repository class must have a name ending with "Repository" or "EloquentRepository" * and implement the CRUD methods - * and have a dependency on a model + * and have a dependency on a model. * * @param ReflectionClass $class - * * @return bool */ public function isRepositoryClass(ReflectionClass $class) @@ -91,10 +88,9 @@ public function isRepositoryClass(ReflectionClass $class) /** * Check if the class is a service class - * A service class must have a name ending with "Service" or "EloquentService" + * A service class must have a name ending with "Service" or "EloquentService". * * @param ReflectionClass $class - * * @return bool */ public function isServiceClass(ReflectionClass $class) @@ -106,10 +102,9 @@ public function isServiceClass(ReflectionClass $class) * Check if the class is a controller class * A controller class must have a name ending with "Controller" or "EloquentController" * and implement the CRUD methods - * and have a dependency on a model + * and have a dependency on a model. * * @param ReflectionClass $class - * * @return bool */ public function isControllerClass(ReflectionClass $class) @@ -119,10 +114,9 @@ public function isControllerClass(ReflectionClass $class) /** * Check if the class is an action class - * An action class must have a name ending with "Action" or "EloquentAction" + * An action class must have a name ending with "Action" or "EloquentAction". * * @param ReflectionClass $class - * * @return bool */ public function isActionClass(ReflectionClass $class) @@ -132,16 +126,16 @@ public function isActionClass(ReflectionClass $class) /** * Check if the class is a class of the given type - * A class of the given type must have a name ending with the given type or "Eloquent" + the given type + * A class of the given type must have a name ending with the given type or "Eloquent" + the given type. * * @param ReflectionClass $class * @param $type - * * @return bool */ protected function checkClassType(ReflectionClass $class, $type) { $type = ucfirst($type); + return preg_match('/'.$type.'$/', $class->getName()) === 1 || preg_match('/Eloquent'.$type.'$/', $class->getName()) === 1 && $this->implementsCrudMethods($class) @@ -149,10 +143,9 @@ protected function checkClassType(ReflectionClass $class, $type) } /** - * Get the type of the given class + * Get the type of the given class. * * @param ReflectionClass $class - * * @return string */ protected function getClassType(ReflectionClass $class) @@ -178,7 +171,7 @@ protected function getClassType(ReflectionClass $class) } /** - * Get the type of all classes in the app folder + * Get the type of all classes in the app folder. * * @return array[] */ @@ -189,7 +182,7 @@ public function detect() $type = []; foreach ($files as $file) { - if (!$file->isFile() || $file->getExtension() !== 'php') { + if (! $file->isFile() || $file->getExtension() !== 'php') { continue; } diff --git a/src/Http/Controllers/Generator/RepositoryGeneratorController.php b/src/Http/Controllers/Generator/RepositoryGeneratorController.php index 612de68..58e98eb 100644 --- a/src/Http/Controllers/Generator/RepositoryGeneratorController.php +++ b/src/Http/Controllers/Generator/RepositoryGeneratorController.php @@ -4,7 +4,6 @@ use Illuminate\Support\Str; use Lbil\LaravelGenerator\Http\Controllers\Detect\DetectController; -use Lbil\LaravelGenerator\Http\Requests\Generator\RepositoryGeneratorRequest; class RepositoryGeneratorController extends GeneratorController { @@ -44,7 +43,7 @@ public function saveFile($fileName, $fileContent) { $filePath = app_path("Repositories/{$fileName}"); - if (!is_dir(dirname($filePath))) { + if (! is_dir(dirname($filePath))) { mkdir(dirname($filePath), 0777, true); } diff --git a/src/Http/Controllers/LaravelGeneratorController.php b/src/Http/Controllers/LaravelGeneratorController.php index 3998ba9..22f2737 100644 --- a/src/Http/Controllers/LaravelGeneratorController.php +++ b/src/Http/Controllers/LaravelGeneratorController.php @@ -2,18 +2,17 @@ namespace Lbil\LaravelGenerator\Http\Controllers; -use Illuminate\Http\Request; -use Illuminate\Routing\Controller; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; +use Illuminate\Http\Request; +use Illuminate\Routing\Controller; use Lbil\LaravelGenerator\Http\Controllers\Detect\DetectController; class LaravelGeneratorController extends Controller { /** * @param Request $request - * * @return Application|Factory|View */ public function index(Request $request) diff --git a/src/Http/Requests/ApiRequest.php b/src/Http/Requests/ApiRequest.php index 6aef32f..d584040 100644 --- a/src/Http/Requests/ApiRequest.php +++ b/src/Http/Requests/ApiRequest.php @@ -9,14 +9,11 @@ /** * Class ApiRequest. - * @package Lbil\LaravelGenerator\Http\Requests - * - * This class is used to handle the validation error response. It will return the error message in JSON format. */ abstract class ApiRequest extends FormRequest { /** - * @param Validator $validator + * @param Validator $validator * * @return void */ diff --git a/src/Providers/LaravelGeneratorServiceProvider.php b/src/Providers/LaravelGeneratorServiceProvider.php index 0b3ae43..9001707 100755 --- a/src/Providers/LaravelGeneratorServiceProvider.php +++ b/src/Providers/LaravelGeneratorServiceProvider.php @@ -14,38 +14,38 @@ class LaravelGeneratorServiceProvider extends ServiceProvider */ public function boot(): void { - $viewPath = __DIR__ . '/../../resources/views'; + $viewPath = __DIR__.'/../../resources/views'; $this->loadViewsFrom($viewPath, 'laravel-generator'); // Publish a config file - $configPath = __DIR__ . '/../../config/laravel-generator.php'; + $configPath = __DIR__.'/../../config/laravel-generator.php'; $this->publishes([ $configPath => config_path('laravel-generator.php'), ], 'config'); // Publish views $this->publishes([ - __DIR__ . '/../../resources/views' => config('laravel-generator.defaults.paths.views'), + __DIR__.'/../../resources/views' => config('laravel-generator.defaults.paths.views'), ], 'views'); // Include routes - $routePath = __DIR__ . '/../../routes/web.php'; + $routePath = __DIR__.'/../../routes/web.php'; if (file_exists($routePath)) { $this->loadRoutesFrom($routePath); } // Load package helpers file - $helpersPath = __DIR__ . '/../../common/helpers.php'; + $helpersPath = __DIR__.'/../../common/helpers.php'; if (file_exists($helpersPath)) { require_once $helpersPath; } // Load language files - $this->loadTranslationsFrom(__DIR__ . '/../../lang', 'laravel-generator'); + $this->loadTranslationsFrom(__DIR__.'/../../lang', 'laravel-generator'); // Publish language files $this->publishes([ - __DIR__ . '/../../lang' => resource_path('lang/vendor/laravel-generator'), + __DIR__.'/../../lang' => resource_path('lang/vendor/laravel-generator'), ], 'lang'); } @@ -56,7 +56,7 @@ public function boot(): void */ public function register(): void { - $configPath = __DIR__ . '/../../config/laravel-generator.php'; + $configPath = __DIR__.'/../../config/laravel-generator.php'; $this->mergeConfigFrom($configPath, 'laravel-generator'); $this->app->singleton('laravel-generator', function () { diff --git a/tests/Unit/DetectTest.php b/tests/Unit/DetectTest.php index 04291da..509840e 100644 --- a/tests/Unit/DetectTest.php +++ b/tests/Unit/DetectTest.php @@ -2,9 +2,9 @@ namespace Lbil\LaravelGenerator\Tests\Unit; -use PHPUnit\Framework\TestCase; -use Mockery; use Lbil\LaravelGenerator\Http\Controllers\Detect\DetectController; +use Mockery; +use PHPUnit\Framework\TestCase; class DetectTest extends TestCase { @@ -29,7 +29,7 @@ protected function tearDown(): void } /** - * Test detect pattern function is return the correct value + * Test detect pattern function is return the correct value. * * @return void */ From edbfb1f80961477437bf56734576e13142e44e1f Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Tue, 25 Apr 2023 23:50:30 +0700 Subject: [PATCH 3/3] update some code for the format style with laravel --- src/Http/Requests/ApiRequest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Http/Requests/ApiRequest.php b/src/Http/Requests/ApiRequest.php index d584040..f2bc853 100644 --- a/src/Http/Requests/ApiRequest.php +++ b/src/Http/Requests/ApiRequest.php @@ -14,7 +14,6 @@ abstract class ApiRequest extends FormRequest { /** * @param Validator $validator - * * @return void */ public function failedValidation(Validator $validator): void