diff --git a/ecs.php b/ecs.php index 62958f6..081fb12 100644 --- a/ecs.php +++ b/ecs.php @@ -2,27 +2,8 @@ declare(strict_types=1); -use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer; use Symplify\EasyCodingStandard\Config\ECSConfig; return ECSConfig::configure() - ->withPaths([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - - // add a single rule - ->withRules([ - NoUnusedImportsFixer::class, - ]) - - // add sets - group of rules - // ->withPreparedSets( - // arrays: true, - // namespaces: true, - // spaces: true, - // docblocks: true, - // comments: true, - // ) - - ; + ->withPaths([__DIR__ . '/src', __DIR__ . '/tests']) + ->withPreparedSets(psr12: true); diff --git a/src/CakePHP/PortedInflector.php b/src/CakePHP/PortedInflector.php index 17be922..90d0bdb 100644 --- a/src/CakePHP/PortedInflector.php +++ b/src/CakePHP/PortedInflector.php @@ -229,13 +229,13 @@ public static function pluralize($word) if (!isset(static::$_plural['cacheUninflected']) || !isset(static::$_plural['cacheIrregular'])) { static::$_plural['cacheUninflected'] = '(?:' . implode( - '|', - static::$_plural['merged']['uninflected'] - ) . ')'; + '|', + static::$_plural['merged']['uninflected'] + ) . ')'; static::$_plural['cacheIrregular'] = '(?:' . implode( - '|', - array_keys(static::$_plural['merged']['irregular']) - ) . ')'; + '|', + array_keys(static::$_plural['merged']['irregular']) + ) . ')'; } if (preg_match('/(.*?(?:\\b|_))(' . static::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { @@ -272,6 +272,6 @@ public static function pluralize($word) private static function underscore($camelCasedWord) { $underscoredWord = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', (string) $camelCasedWord); - return mb_strtolower($underscoredWord); + return mb_strtolower($underscoredWord); } } diff --git a/src/ClassMethodExtension/ModelMethodExtension.php b/src/ClassMethodExtension/ModelMethodExtension.php index 727bf5b..c2d833e 100644 --- a/src/ClassMethodExtension/ModelMethodExtension.php +++ b/src/ClassMethodExtension/ModelMethodExtension.php @@ -70,7 +70,7 @@ static function ( return $methodReflection->getName() === $methodName; } ); - if (! $methodReflections) { + if (!$methodReflections) { throw new Exception('Method not found'); } return reset($methodReflections); diff --git a/src/ClassPropertyExtension/ClassComponentPropertyExtension.php b/src/ClassPropertyExtension/ClassComponentPropertyExtension.php index 216b59e..18f6471 100644 --- a/src/ClassPropertyExtension/ClassComponentPropertyExtension.php +++ b/src/ClassPropertyExtension/ClassComponentPropertyExtension.php @@ -80,7 +80,7 @@ private function getDefinedComponentsAsList(ClassReflection $classReflection): a $definedComponents = []; foreach (array_merge([$classReflection], $classReflection->getParents()) as $class) { - if (! $class->hasProperty('components')) { + if (!$class->hasProperty('components')) { continue; } @@ -89,7 +89,7 @@ private function getDefinedComponentsAsList(ClassReflection $classReflection): a ->getDefaultValueExpression(); if (!$defaultValue instanceof Array_) { - continue; + continue; } foreach ($defaultValue->items as $item) { diff --git a/src/ClassPropertyExtension/ShellClassPropertyExtension.php b/src/ClassPropertyExtension/ShellClassPropertyExtension.php index c371689..d567292 100644 --- a/src/ClassPropertyExtension/ShellClassPropertyExtension.php +++ b/src/ClassPropertyExtension/ShellClassPropertyExtension.php @@ -4,7 +4,6 @@ namespace PHPStanCakePHP2\ClassPropertyExtension; - /** * Adds {@link Model}s as properties to {@link Shell}s. * diff --git a/src/ModelBehaviorMethodExtractor.php b/src/ModelBehaviorMethodExtractor.php index 4e6bbc7..70cc1cb 100644 --- a/src/ModelBehaviorMethodExtractor.php +++ b/src/ModelBehaviorMethodExtractor.php @@ -69,7 +69,7 @@ private function filterBehaviorMethods( ExtendedMethodReflection $methodReflection ): bool { return $methodReflection->isPublic() - && ! $methodReflection->isStatic() + && !$methodReflection->isStatic() && array_filter( $methodReflection->getVariants(), [$this, 'filterBehaviorMethodVariants'] @@ -87,7 +87,7 @@ private function filterBehaviorMethodVariants( /** @var ParameterReflection|null $firstParameter */ $firstParameter = array_shift($parameters); - if (! $firstParameter) { + if (!$firstParameter) { return false; } diff --git a/src/Reflection/ClassReflectionFinder.php b/src/Reflection/ClassReflectionFinder.php index 3c321aa..fa873b2 100644 --- a/src/Reflection/ClassReflectionFinder.php +++ b/src/Reflection/ClassReflectionFinder.php @@ -61,7 +61,7 @@ private function getClassNamesFromPaths( $classPaths = []; foreach ($paths as $path) { $filePaths = glob($path); - if (! is_array($filePaths)) { + if (!is_array($filePaths)) { throw new Exception(sprintf('glob(%s) caused an error', $path)); } $classPaths = array_merge($classPaths, $filePaths); diff --git a/tests/ClassPropertyExtension/ClassComponentPropertyExtension/Fixture/existing_component_component.php b/tests/ClassPropertyExtension/ClassComponentPropertyExtension/Fixture/existing_component_component.php index c5a317d..2c6ff4f 100644 --- a/tests/ClassPropertyExtension/ClassComponentPropertyExtension/Fixture/existing_component_component.php +++ b/tests/ClassPropertyExtension/ClassComponentPropertyExtension/Fixture/existing_component_component.php @@ -1,6 +1,6 @@