diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 631dd64..4141201 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -32,7 +32,7 @@ jobs: run: composer run-script phpinsights-github - name: Run static type analysis - run: composer run-script phpstan + run: composer run-script phpstan-github - name: Run test suite run: composer run-script phpunit diff --git a/composer.json b/composer.json index 1d3c7b1..cd4f700 100644 --- a/composer.json +++ b/composer.json @@ -46,6 +46,7 @@ "phpinsights": "phpinsights analyse --no-interaction --ansi --config-path=phpinsights.php --summary src", "phpinsights-github": "phpinsights analyse --no-interaction --ansi --config-path=phpinsights.php --format=github-action src", "phpstan": "phpstan", + "phpstan-github": "phpstan --error-format=github", "phpunit": "phpunit", "test": [ "@phpunit", diff --git a/src/ClassReflectionFinder.php b/src/ClassReflectionFinder.php index a4be4ef..d32e96c 100644 --- a/src/ClassReflectionFinder.php +++ b/src/ClassReflectionFinder.php @@ -66,7 +66,10 @@ private function getClassNamesFromPaths( } $classPaths = array_merge($classPaths, $filePaths); } - $classNames = array_map($pathToClassName ?? [$this, 'getClassNameFromFileName'], $classPaths); + $classNames = array_map( + $pathToClassName ?? [$this, 'getClassNameFromFileName'], + $classPaths + ); return array_filter( $classNames, [$this->reflectionProvider, 'hasClass'] diff --git a/src/ClassRegistryInitExtension.php b/src/ClassRegistryInitExtension.php index baf120d..d206f11 100644 --- a/src/ClassRegistryInitExtension.php +++ b/src/ClassRegistryInitExtension.php @@ -1,5 +1,7 @@ reflectionProvider = $reflectionProvider; $this->schemaService = $schemaService; } @@ -35,13 +37,17 @@ public function getClass(): string return 'ClassRegistry'; } - public function isStaticMethodSupported(MethodReflection $methodReflection): bool - { + public function isStaticMethodSupported( + MethodReflection $methodReflection + ): bool { return $methodReflection->getName() === 'init'; } - public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): ?Type - { + public function getTypeFromStaticMethodCall( + MethodReflection $methodReflection, + StaticCall $methodCall, + Scope $scope + ): ?Type { $arg1 = $methodCall->getArgs()[0]->value; $evaluator = new ConstExprEvaluator(); $arg1 = $evaluator->evaluateSilently($arg1); @@ -61,7 +67,7 @@ private function getDefaultType(): Type { return new UnionType([ new BooleanType(), - new ObjectWithoutClassType() + new ObjectWithoutClassType(), ]); } } diff --git a/src/Service/SchemaService.php b/src/Service/SchemaService.php index f9890aa..c410903 100644 --- a/src/Service/SchemaService.php +++ b/src/Service/SchemaService.php @@ -1,5 +1,7 @@ $schemaPaths */ public function __construct( @@ -50,8 +51,8 @@ public function hasTable(string $table): bool } /** - * @param string $table * @return table_schema|null + * * @throws Exception */ public function getTableSchema(string $table) @@ -73,10 +74,12 @@ private function getTableSchemas(): array return $this->tableSchemas; } $cakeSchemaPropertyNames = array_map( - function (ReflectionProperty $reflectionProperty) { + static function (ReflectionProperty $reflectionProperty) { return $reflectionProperty->getName(); }, - $this->reflectionProvider->getClass('CakeSchema')->getNativeReflection()->getProperties() + $this->reflectionProvider->getClass('CakeSchema') + ->getNativeReflection() + ->getProperties() ); $this->tableSchemas = []; $classReflectionFinder = new ClassReflectionFinder( @@ -91,15 +94,19 @@ function (string $fileName) { ); foreach ($schemaReflections as $schemaReflection) { $propertyNames = array_map( - function (ReflectionProperty $reflectionProperty) { + static function (ReflectionProperty $reflectionProperty) { return $reflectionProperty->getName(); }, $schemaReflection->getNativeReflection() ->getProperties(CoreReflectionProperty::IS_PUBLIC) ); - $tableProperties = array_diff($propertyNames, $cakeSchemaPropertyNames); + $tableProperties = array_diff( + $propertyNames, + $cakeSchemaPropertyNames + ); $this->tableSchemas += array_intersect_key( - $schemaReflection->getNativeReflection()->getDefaultProperties(), + $schemaReflection->getNativeReflection() + ->getDefaultProperties(), array_fill_keys($tableProperties, null) ); }