From 4f42af1fa1f6265174ef97c36e0ae7beb2596c29 Mon Sep 17 00:00:00 2001 From: yaegassy Date: Fri, 5 Feb 2021 21:57:35 +0900 Subject: [PATCH] Apply "@PSR12" in php-cs-fixer (#1150) * Apply "@PSR12" in php-cs-fixer * Run fix-style --- .php_cs.common.php | 6 ++---- src/Alias.php | 1 - src/Console/ModelsCommand.php | 24 ++++++++++-------------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.php_cs.common.php b/.php_cs.common.php index a7aad6375..aebd5441d 100644 --- a/.php_cs.common.php +++ b/.php_cs.common.php @@ -2,12 +2,10 @@ // Share common rules between non-test and test files return [ - // PSR12 from https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4943 - '@PSR2' => true, + '@PSR12' => true, 'blank_line_after_opening_tag' => true, 'braces' => [ - // Not-yet-implemented - // 'allow_single_line_anonymous_class_with_empty_body' => true, + 'allow_single_line_anonymous_class_with_empty_body' => true, ], 'compact_nullable_typehint' => true, 'declare_equal_normalize' => true, diff --git a/src/Alias.php b/src/Alias.php index 26193e7f7..eb5b30932 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -344,7 +344,6 @@ protected function addMagicMethods() */ protected function detectMethods() { - foreach ($this->classes as $class) { $reflection = new \ReflectionClass($class); diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 4366f0ece..2a23059be 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -212,8 +212,6 @@ protected function getOptions() protected function generateDocs($loadModels, $ignore = '') { - - $output = "error("Cannot locate directory '{'$dir}'"); continue; @@ -757,7 +754,6 @@ protected function setMethod($name, $type = '', $arguments = []) */ protected function createPhpDocs($class) { - $reflection = new ReflectionClass($class); $namespace = $reflection->getNamespaceName(); $classname = $reflection->getShortName(); @@ -1019,7 +1015,7 @@ protected function getReturnTypeFromReflection(\ReflectionMethod $reflection): ? $type = implode('|', $types); - if($returnType->allowsNull()){ + if ($returnType->allowsNull()) { $type .='|null'; } @@ -1050,7 +1046,7 @@ protected function getSoftDeleteMethods($model) */ protected function getFactoryMethods($model) { - if(!class_exists(Factory::class)) { + if (!class_exists(Factory::class)) { return; } @@ -1128,7 +1124,7 @@ protected function checkForCustomLaravelCasts(string $type): ?string $reflectionType = $this->getReturnTypeFromDocBlock($methodReflection); } - if($reflectionType === 'static' || $reflectionType === '$this') { + if ($reflectionType === 'static' || $reflectionType === '$this') { $reflectionType = $type; } @@ -1217,10 +1213,10 @@ protected function getParamType(\ReflectionMethod $method, \ReflectionParameter $type = implode('|', $types); - if($paramType->allowsNull()){ - if(count($types)==1){ + if ($paramType->allowsNull()) { + if (count($types)==1) { $type = '?' . $type; - }else{ + } else { $type .='|null'; } } @@ -1293,12 +1289,12 @@ protected function getParamType(\ReflectionMethod $method, \ReflectionParameter protected function extractReflectionTypes(ReflectionType $reflection_type) { - if($reflection_type instanceof ReflectionNamedType){ + if ($reflection_type instanceof ReflectionNamedType) { $types[] = $this->getReflectionNamedType($reflection_type); - }else{ + } else { $types = []; - foreach ($reflection_type->getTypes() as $named_type){ - if($named_type->getName()==='null'){ + foreach ($reflection_type->getTypes() as $named_type) { + if ($named_type->getName()==='null') { continue; }