diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 95a9a9060b3f74d552ce29e1c6018db0196150c0..9a83221861d498daf7898b7436de9f0361368629 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,3 +22,7 @@ test.verify.php73: <<: *test-verify-template image: grifart/php7.3-with-gulp-and-all-php-modules + +test.verify.php74: + <<: *test-verify-template + image: grifart/php7.4-with-gulp-and-all-php-modules diff --git a/composer.json b/composer.json index c25422e13f0567b0bcf2150c7ed283567364d644..57d9ddb0874079eba22fbb306420ec10d59c7e3e 100644 --- a/composer.json +++ b/composer.json @@ -22,10 +22,9 @@ "require": { - "php": "~7.2.0 | ~7.3.0", + "php": "^7.2", "nette/utils": "^3.0.1", - "dibi/dibi": "^4.0.2", - "grifart/assert-function-signature": "^0.1.0" + "dibi/dibi": "^4.0.2" }, "require-dev": { "nette/tester": "^2.3", diff --git a/src/TypeMapper.php b/src/TypeMapper.php index f2dfdd5438bec5673f33c6af2897755fcb1c6282..7c484c10701c9a70458ce627b16d8cb7c3c9347c 100644 --- a/src/TypeMapper.php +++ b/src/TypeMapper.php @@ -1,30 +1,28 @@ <?php declare(strict_types=1); - namespace Grifart\Tables; - -use function Grifart\AssertFunction\assertSignature; -use function Grifart\AssertFunction\nullable; - final class TypeMapper { - private $matchers; - private $mappings; - - public function __construct() - { - $this->mappings = []; - $this->matchers = []; - } + /** + * @var (callable(string $typeName, string $location): ?string)[] + */ + private $matchers = []; - // TODO: isn't it too general? Or just map db-type name to php type and back? - public function addMapping(callable $typeMatcher, callable $mapper) { + /** + * @var (callable(mixed $value, string $typeName): mixed)[] + */ + private $mappings = []; - assertSignature($typeMatcher, ['string', 'string'], nullable('string')); - assertSignature($mapper, ['any'], 'mixed'); + /** + * @param (callable(string $typeName, string $location): ?string) $typeMatcher + * @param (callable(mixed $value, string $typeName): mixed) $mapper + * + * TODO: isn't it too general? Or just map db-type name to php type and back? + */ + public function addMapping(callable $typeMatcher, callable $mapper) { $this->matchers[] = $typeMatcher; $this->mappings[] = $mapper; } @@ -38,12 +36,6 @@ final class TypeMapper $translatingType = $matcher($typeName, $location); if ($translatingType !== NULL) { $mapper = $this->mappings[$idx]; -// assertSignature( -// $mapper, [ -// $this->getTypeForValue($value) -// ], -// 'mixed' // todo: $translatingType does not work for reverse mapping -// ); return $mapper($value, $typeName); } }