From b1fdbdc0e29de80f4685c907c41b2cdb1ec1874f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Pudil?= <me@jiripudil.cz> Date: Mon, 30 Nov 2020 12:18:07 +0100 Subject: [PATCH] update phpstan to 0.12 --- composer.json | 4 ++-- src/Modifications.php | 5 ++++- src/PrimaryKey.php | 2 +- src/Row.php | 5 ++++- src/Scaffolding/Scaffolding.php | 5 ++++- src/Scaffolding/TableDecorator.php | 4 ++++ src/TableManager.php | 9 ++++++++- src/TypeMapper.php | 9 ++++++++- src/exceptions.php | 3 +++ 9 files changed, 38 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index b8daf24..5676bfc 100644 --- a/composer.json +++ b/composer.json @@ -29,8 +29,8 @@ }, "require-dev": { "nette/tester": "^2.3", - "grifart/phpstan-oneline": "^0.2.2", - "phpstan/phpstan": "^0.11.17" + "grifart/phpstan-oneline": "^0.3", + "phpstan/phpstan": "^0.12" }, diff --git a/src/Modifications.php b/src/Modifications.php index 9b3dd6c..6a810af 100644 --- a/src/Modifications.php +++ b/src/Modifications.php @@ -8,7 +8,10 @@ interface Modifications { - /** @internal used by {@see AccountsTable} */ + /** + * @internal used by {@see AccountsTable} + * @return mixed[] + */ public function getModifications(): array; /** @return null|PrimaryKey if null it means, that row is new (do INSERT) */ diff --git a/src/PrimaryKey.php b/src/PrimaryKey.php index 40ac804..e90c7da 100644 --- a/src/PrimaryKey.php +++ b/src/PrimaryKey.php @@ -7,7 +7,7 @@ interface PrimaryKey { /** - * @return array query used in WHERE to narrow down results into one record + * @return array<string, mixed> query used in WHERE to narrow down results into one record */ public function getQuery(): array; diff --git a/src/Row.php b/src/Row.php index 6126914..52088e5 100644 --- a/src/Row.php +++ b/src/Row.php @@ -7,7 +7,10 @@ namespace Grifart\Tables; interface Row { - /** @return self */ + /** + * @param mixed[] $values + * @return self + */ public static function reconstitute(array $values); } diff --git a/src/Scaffolding/Scaffolding.php b/src/Scaffolding/Scaffolding.php index 2edb17c..d83bd96 100644 --- a/src/Scaffolding/Scaffolding.php +++ b/src/Scaffolding/Scaffolding.php @@ -8,8 +8,8 @@ namespace Grifart\Tables\Scaffolding; use Grifart\ClassScaffolder\Decorators\GettersDecorator; use Grifart\ClassScaffolder\Decorators\InitializingConstructorDecorator; use Grifart\ClassScaffolder\Decorators\PropertiesDecorator; +use Grifart\ClassScaffolder\Definition\ClassDefinition; use Grifart\ClassScaffolder\Definition\ClassDefinitionBuilder; -use Grifart\ClassScaffolder\Definition\Types\Type; use Grifart\Tables\Row; use Grifart\Tables\TypeMapper; use function Grifart\ClassScaffolder\Definition\Types\nullable; @@ -23,6 +23,9 @@ final class Scaffolding return "$schema.$table.$column"; } + /** + * @return ClassDefinition[] + */ public static function definitionsForPgTable( PostgresReflector $pgReflector, TypeMapper $mapper, diff --git a/src/Scaffolding/TableDecorator.php b/src/Scaffolding/TableDecorator.php index 7436f28..f5c412f 100644 --- a/src/Scaffolding/TableDecorator.php +++ b/src/Scaffolding/TableDecorator.php @@ -40,6 +40,7 @@ final class TableDecorator implements ClassDecorator private $columnPhpTypes; /** + * @param array<string, Column> $columnInfo * @param array<string, Type> $columnPhpTypes */ public function __construct(string $schema, string $tableName, string $primaryKeyClass, string $rowClass, string $modificationClass, array $columnInfo, array $columnPhpTypes) @@ -269,6 +270,9 @@ final class TableDecorator implements ClassDecorator $this->implementConfigMethod($classType, $name, new Code\PhpLiteral($namespace->unresolveName($class) . '::class')); } + /** + * @param mixed $value + */ private function implementConfigMethod(Code\ClassType $classType, string $name, $value): void { $classType->addMethod($name) diff --git a/src/TableManager.php b/src/TableManager.php index e79ed40..1bc7118 100644 --- a/src/TableManager.php +++ b/src/TableManager.php @@ -55,7 +55,10 @@ final class TableManager return NULL; } - /** @return Row[] (subclass of row) */ + /** + * @param array<string, mixed> $conditions + * @return Row[] (subclass of row) + */ public function findBy(Table $table, array $conditions): array { $result = $this->connection->query( @@ -114,6 +117,10 @@ final class TableManager } + /** + * @param array<string, mixed> $values + * @return array<string, mixed> + */ private static function mapTypes(TypeMapper $mapper, array $values, Table $table): array { // could not use array_map as it does not preserve indexes diff --git a/src/TypeMapper.php b/src/TypeMapper.php index 17582a0..3ded68d 100644 --- a/src/TypeMapper.php +++ b/src/TypeMapper.php @@ -24,11 +24,15 @@ final class TypeMapper * * TODO: isn't it too general? Or just map db-type name to php type and back? */ - public function addMapping(callable $typeMatcher, callable $mapper) { + public function addMapping(callable $typeMatcher, callable $mapper): void { $this->matchers[] = $typeMatcher; $this->mappings[] = $mapper; } + /** + * @param mixed $value + * @return mixed + */ public function map(string $location, string $typeName, $value) { if ($value === NULL) { return NULL; // todo: really do not translate? @@ -44,6 +48,9 @@ final class TypeMapper throw CouldNotMapTypeException::didYouRegisterTypeMapperFor($typeName, $value); } + /** + * @param mixed $value + */ private function getTypeForValue($value): string { return !\is_object($value) ? \gettype($value) : \get_class($value); } diff --git a/src/exceptions.php b/src/exceptions.php index 6e10e01..e1e80eb 100644 --- a/src/exceptions.php +++ b/src/exceptions.php @@ -21,6 +21,9 @@ final class ProbablyBrokenPrimaryIndexImplementation extends UsageException { final class CouldNotMapTypeException extends UsageException { + /** + * @param mixed $value + */ public static function didYouRegisterTypeMapperFor(string $typeName, $value): self { return new self( -- GitLab