diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a83221861d498daf7898b7436de9f0361368629..f3de909c5a15f18d51c236df497c1ce93c227a7b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,17 +12,6 @@ stages: - composer run verify -test.verify.php72: - <<: *test-verify-template - image: grifart/php7.2-with-gulp-and-all-php-modules - - - -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 2d69b6659167988a93d082294528fcf471e526c7..1ea9ebec4f7957b0a595d60a45d6dba489ef50dd 100644 --- a/composer.json +++ b/composer.json @@ -22,20 +22,17 @@ "require": { - "php": "^7.2", - "nette/utils": "^3.0.1", - "dibi/dibi": "^4.0.2" + "php": "^7.4", + "dibi/dibi": "^4.0.2", + "grifart/class-scaffolder": "^0.2.0", + "nette/utils": "^3.0.1" }, "require-dev": { "nette/tester": "^2.3", - "grifart/class-scaffolder": "^0.1.3", "grifart/phpstan-oneline": "^0.2.2", "phpstan/phpstan": "^0.11.17" }, - "suggest": { - "grifart/class-scaffolder": "⚠️ Install grifart/class-scaffolder as your `-dev` dependency to generate table definitions from your DB automatically." - }, "autoload": { diff --git a/src/Scaffolding/ModificationsDecorator.php b/src/Scaffolding/ModificationsDecorator.php index fefb74e521fd207aa112ba2c68d66c575ec9f187..2058f9b3e23f727d0a76cdf93c93d242b2df74e7 100644 --- a/src/Scaffolding/ModificationsDecorator.php +++ b/src/Scaffolding/ModificationsDecorator.php @@ -93,10 +93,10 @@ final class ModificationsDecorator implements ClassDecorator $docCommentType = $type->getDocCommentType($namespace); $modifier->addComment(\sprintf( - '@param $%s %s%s', - $fieldName, + '@param %s $%s%s', $docCommentType, - $type->hasComment() ? ' ' . $type->getComment($namespace) : '' + $fieldName, + $type->hasComment() ? ' ' . $type->getComment($namespace) : '', )); } } diff --git a/src/TypeMapper.php b/src/TypeMapper.php index 7c484c10701c9a70458ce627b16d8cb7c3c9347c..17582a06f2ea0413e09807ee8cd8f158db43fba2 100644 --- a/src/TypeMapper.php +++ b/src/TypeMapper.php @@ -2,11 +2,13 @@ namespace Grifart\Tables; +use Grifart\ClassScaffolder\Definition\Types\Type; + final class TypeMapper { /** - * @var (callable(string $typeName, string $location): ?string)[] + * @var (callable(string $typeName, string $location): (string|Type|null))[] */ private $matchers = []; @@ -17,7 +19,7 @@ final class TypeMapper /** - * @param (callable(string $typeName, string $location): ?string) $typeMatcher + * @param (callable(string $typeName, string $location): (string|Type|null)) $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? @@ -46,7 +48,10 @@ final class TypeMapper return !\is_object($value) ? \gettype($value) : \get_class($value); } - public function mapType(string $location, string $typeName): string + /** + * @return string|Type + */ + public function mapType(string $location, string $typeName) { foreach($this->matchers as $idx => $matcher) { if ( ($translatingType = $matcher($typeName, $location)) !== NULL) {