Skip to content
Snippets Groups Projects
Verified Commit b1fdbdc0 authored by Jiří Pudil's avatar Jiří Pudil
Browse files

update phpstan to 0.12

parent fc31b8d8
No related branches found
No related tags found
1 merge request!7PHP 8
......@@ -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"
},
......
......@@ -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) */
......
......@@ -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;
......
......@@ -7,7 +7,10 @@ namespace Grifart\Tables;
interface Row
{
/** @return self */
/**
* @param mixed[] $values
* @return self
*/
public static function reconstitute(array $values);
}
......@@ -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,
......
......@@ -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)
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment