diff --git a/composer.json b/composer.json index b8daf2405681a4da028fdb5f15edb882a26fe3af..5676bfc979d8a12f7634b83b14dd84dd6484df0c 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 9b3dd6ca3d5e20296014ac5c4faacb8b1ff29a38..6a810af57002764f38fe56d093ab6deef3f309a3 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 40ac8040000f06986b8c5b029c1b1be997b8c4ef..e90c7da7aa97e90f1be06fe81c2b284b18630acb 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 612691434e73217ad52b3708fa38a4d724d591a6..52088e5b2c5825d0883f6c4e9d0d9eecb8a62672 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 2edb17cbbf80eaaeaa944334a5e45236026ded2f..d83bd9673324b8c73dbd385af1bd1c0a569758d2 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 7436f284e35d5a81a98e73d09f5b912e204da483..f5c412f7a9523f6460b24b2f4440a4172838859f 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 e79ed40b7b535bab5c7c69b395403a2e93aa7b32..1bc71181eab74b280aecdf19a72de700ae23c811 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 17582a06f2ea0413e09807ee8cd8f158db43fba2..3ded68d38960800b33ace8721c4d4895db0fcc53 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 6e10e016ae0c869bdfba1aeaed617b6823febcf4..e1e80ebc4f34b602bfe5c064d9f5f3994bb5b630 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(