diff --git a/composer.json b/composer.json index e8418110..413241dd 100644 --- a/composer.json +++ b/composer.json @@ -39,20 +39,21 @@ "doctrine/orm": "^2.5", "doctrine/phpcr-odm": "^1.3", "jackalope/jackalope-doctrine-dbal": "^1.2", + "lchrusciel/api-test-case": "^4.1", "matthiasnoback/symfony-config-test": "^4.0", "matthiasnoback/symfony-dependency-injection-test": "^3.0", "pagerfanta/pagerfanta": "^1.0|^2.0", "phpspec/phpspec": "^5.0", "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", + "phpstan/phpstan": "^0.11", "phpstan/phpstan-webmozart-assert": "^0.11", "phpunit/phpunit": "^7.0", - "sylius/currency-bundle": "^1.1", "sylius-labs/coding-standard": "^3.0", + "sylius/currency-bundle": "^1.1", "symfony/console": "^3.4|^4.1.1", "symfony/twig-bundle": "^3.4|^4.1.1", "twig/twig": "^2.0", - "lchrusciel/api-test-case": "^4.1" + "vimeo/psalm": "^3.5" }, "conflict": { "twig/twig": "^1.0" @@ -77,7 +78,8 @@ "scripts": { "analyse": [ "@php vendor/bin/ecs check src", - "@php vendor/bin/phpstan analyse --ansi -c phpstan.neon -l max src" + "@php vendor/bin/phpstan analyse --ansi -c phpstan.neon -l max src", + "@php vendor/bin/psalm" ], "fix": [ "@php vendor/bin/ecs check src --fix" diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 00000000..549029d9 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Bundle/DependencyInjection/Configuration.php b/src/Bundle/DependencyInjection/Configuration.php index 4681c52d..7f0fd6b8 100644 --- a/src/Bundle/DependencyInjection/Configuration.php +++ b/src/Bundle/DependencyInjection/Configuration.php @@ -28,10 +28,14 @@ public function getConfigTreeBuilder(): TreeBuilder { if (method_exists(TreeBuilder::class, 'getRootNode')) { $treeBuilder = new TreeBuilder('sylius_grid'); + + /** @var ArrayNodeDefinition $rootNode */ $rootNode = $treeBuilder->getRootNode(); } else { // BC layer for symfony/config 4.1 and older $treeBuilder = new TreeBuilder(); + + /** @var ArrayNodeDefinition $rootNode */ $rootNode = $treeBuilder->root('sylius_grid'); } diff --git a/src/Bundle/Doctrine/DBAL/DataSource.php b/src/Bundle/Doctrine/DBAL/DataSource.php index 073cb2c3..7f37d593 100644 --- a/src/Bundle/Doctrine/DBAL/DataSource.php +++ b/src/Bundle/Doctrine/DBAL/DataSource.php @@ -64,7 +64,7 @@ public function getExpressionBuilder(): ExpressionBuilderInterface */ public function getData(Parameters $parameters) { - $countQueryBuilderModifier = function ($queryBuilder) { + $countQueryBuilderModifier = function (QueryBuilder $queryBuilder): void { $queryBuilder ->select('COUNT(DISTINCT o.id) AS total_results') ->setMaxResults(1) diff --git a/src/Bundle/Doctrine/DBAL/ExpressionBuilder.php b/src/Bundle/Doctrine/DBAL/ExpressionBuilder.php index 7d86a215..9d98a046 100644 --- a/src/Bundle/Doctrine/DBAL/ExpressionBuilder.php +++ b/src/Bundle/Doctrine/DBAL/ExpressionBuilder.php @@ -75,7 +75,9 @@ public function notEquals(string $field, $value) */ public function lessThan(string $field, $value) { - $this->queryBuilder->andWhere($field . ' < :' . $field)->setParameter($field, $value); + $this->queryBuilder->setParameter($field, $value); + + return $this->queryBuilder->expr()->lt($field, ':' . $field); } /** @@ -83,7 +85,9 @@ public function lessThan(string $field, $value) */ public function lessThanOrEqual(string $field, $value) { - $this->queryBuilder->andWhere($field . ' =< :' . $field)->setParameter($field, $value); + $this->queryBuilder->setParameter($field, $value); + + return $this->queryBuilder->expr()->lte($field, ':' . $field); } /** @@ -91,7 +95,9 @@ public function lessThanOrEqual(string $field, $value) */ public function greaterThan(string $field, $value) { - $this->queryBuilder->andWhere($field . ' > :' . $field)->setParameter($field, $value); + $this->queryBuilder->setParameter($field, $value); + + return $this->queryBuilder->expr()->gt($field, ':' . $field); } /** @@ -99,7 +105,9 @@ public function greaterThan(string $field, $value) */ public function greaterThanOrEqual(string $field, $value) { - $this->queryBuilder->andWhere($field . ' => :%s' . $field)->setParameter($field, $value); + $this->queryBuilder->setParameter($field, $value); + + return $this->queryBuilder->expr()->gte($field, ':' . $field); } /** diff --git a/src/Bundle/FieldTypes/TwigFieldType.php b/src/Bundle/FieldTypes/TwigFieldType.php index 8603b810..db3c02cd 100644 --- a/src/Bundle/FieldTypes/TwigFieldType.php +++ b/src/Bundle/FieldTypes/TwigFieldType.php @@ -17,16 +17,17 @@ use Sylius\Component\Grid\Definition\Field; use Sylius\Component\Grid\FieldTypes\FieldTypeInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Twig\Environment; final class TwigFieldType implements FieldTypeInterface { /** @var DataExtractorInterface */ private $dataExtractor; - /** @var \Twig_Environment */ + /** @var Environment */ private $twig; - public function __construct(DataExtractorInterface $dataExtractor, \Twig_Environment $twig) + public function __construct(DataExtractorInterface $dataExtractor, Environment $twig) { $this->dataExtractor = $dataExtractor; $this->twig = $twig; diff --git a/src/Bundle/Form/DataTransformer/DateTimeFilterTransformer.php b/src/Bundle/Form/DataTransformer/DateTimeFilterTransformer.php index fd66a57f..ab462544 100644 --- a/src/Bundle/Form/DataTransformer/DateTimeFilterTransformer.php +++ b/src/Bundle/Form/DataTransformer/DateTimeFilterTransformer.php @@ -18,6 +18,7 @@ final class DateTimeFilterTransformer implements DataTransformerInterface { + /** @var array */ private static $defaultTime = [ 'from' => ['hour' => '00', 'minute' => '00'], 'to' => ['hour' => '23', 'minute' => '59'], @@ -28,6 +29,7 @@ final class DateTimeFilterTransformer implements DataTransformerInterface public function __construct(string $type) { + /** @psalm-suppress RedundantCondition */ Assert::oneOf($type, array_keys(static::$defaultTime)); $this->type = $type; diff --git a/src/Bundle/Renderer/TwigBulkActionGridRenderer.php b/src/Bundle/Renderer/TwigBulkActionGridRenderer.php index a26e442f..92cd599f 100644 --- a/src/Bundle/Renderer/TwigBulkActionGridRenderer.php +++ b/src/Bundle/Renderer/TwigBulkActionGridRenderer.php @@ -16,16 +16,17 @@ use Sylius\Component\Grid\Definition\Action; use Sylius\Component\Grid\Renderer\BulkActionGridRendererInterface; use Sylius\Component\Grid\View\GridViewInterface; +use Twig\Environment; final class TwigBulkActionGridRenderer implements BulkActionGridRendererInterface { - /** @var \Twig_Environment */ + /** @var Environment */ private $twig; /** @var array */ private $bulkActionTemplates; - public function __construct(\Twig_Environment $twig, array $bulkActionTemplates) + public function __construct(Environment $twig, array $bulkActionTemplates) { $this->twig = $twig; $this->bulkActionTemplates = $bulkActionTemplates; diff --git a/src/Bundle/Renderer/TwigGridRenderer.php b/src/Bundle/Renderer/TwigGridRenderer.php index 6f2a37a9..5c47c301 100644 --- a/src/Bundle/Renderer/TwigGridRenderer.php +++ b/src/Bundle/Renderer/TwigGridRenderer.php @@ -24,10 +24,11 @@ use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Twig\Environment; final class TwigGridRenderer implements GridRendererInterface { - /** @var \Twig_Environment */ + /** @var Environment */ private $twig; /** @var ServiceRegistryInterface */ @@ -49,7 +50,7 @@ final class TwigGridRenderer implements GridRendererInterface private $filterTemplates; public function __construct( - \Twig_Environment $twig, + Environment $twig, ServiceRegistryInterface $fieldsRegistry, FormFactoryInterface $formFactory, FormTypeRegistryInterface $formTypeRegistry, diff --git a/src/Bundle/SyliusGridBundle.php b/src/Bundle/SyliusGridBundle.php index b924d38f..97d308d3 100644 --- a/src/Bundle/SyliusGridBundle.php +++ b/src/Bundle/SyliusGridBundle.php @@ -28,7 +28,7 @@ final class SyliusGridBundle extends Bundle /** * {@inheritdoc} */ - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { parent::build($container); @@ -40,7 +40,7 @@ public function build(ContainerBuilder $container) /** * @return string[] */ - public static function getAvailableDrivers() + public static function getAvailableDrivers(): array { return [ self::DRIVER_DOCTRINE_ORM, diff --git a/src/Bundle/Templating/Helper/GridHelper.php b/src/Bundle/Templating/Helper/GridHelper.php index 04526307..d1387eae 100644 --- a/src/Bundle/Templating/Helper/GridHelper.php +++ b/src/Bundle/Templating/Helper/GridHelper.php @@ -30,11 +30,19 @@ public function __construct(GridRendererInterface $gridRenderer) $this->gridRenderer = $gridRenderer; } + /** + * @return string + */ public function renderGrid(GridView $gridView, ?string $template = null) { return $this->gridRenderer->render($gridView, $template); } + /** + * @param mixed $data + * + * @return string + */ public function renderField(GridView $gridView, Field $field, $data) { return $this->gridRenderer->renderField($gridView, $field, $data); @@ -42,12 +50,17 @@ public function renderField(GridView $gridView, Field $field, $data) /** * @param mixed|null $data + * + * @return string */ public function renderAction(GridView $gridView, Action $action, $data = null) { return $this->gridRenderer->renderAction($gridView, $action, $data); } + /** + * @return string + */ public function renderFilter(GridView $gridView, Filter $filter) { return $this->gridRenderer->renderFilter($gridView, $filter); diff --git a/src/Bundle/Twig/BulkActionGridExtension.php b/src/Bundle/Twig/BulkActionGridExtension.php index 3e0e4e51..e636ee81 100644 --- a/src/Bundle/Twig/BulkActionGridExtension.php +++ b/src/Bundle/Twig/BulkActionGridExtension.php @@ -14,8 +14,10 @@ namespace Sylius\Bundle\GridBundle\Twig; use Sylius\Bundle\GridBundle\Templating\Helper\BulkActionGridHelper; +use Twig\Extension\AbstractExtension; +use Twig\TwigFunction; -final class BulkActionGridExtension extends \Twig_Extension +final class BulkActionGridExtension extends AbstractExtension { /** @var BulkActionGridHelper */ private $bulkActionGridHelper; @@ -31,7 +33,7 @@ public function __construct(BulkActionGridHelper $bulkActionGridHelper) public function getFunctions(): array { return [ - new \Twig_Function( + new TwigFunction( 'sylius_grid_render_bulk_action', [$this->bulkActionGridHelper, 'renderBulkAction'], ['is_safe' => ['html']] diff --git a/src/Bundle/Twig/GridExtension.php b/src/Bundle/Twig/GridExtension.php index 0c6f73fb..6e0844ba 100644 --- a/src/Bundle/Twig/GridExtension.php +++ b/src/Bundle/Twig/GridExtension.php @@ -14,8 +14,10 @@ namespace Sylius\Bundle\GridBundle\Twig; use Sylius\Bundle\GridBundle\Templating\Helper\GridHelper; +use Twig\Extension\AbstractExtension; +use Twig\TwigFunction; -final class GridExtension extends \Twig_Extension +final class GridExtension extends AbstractExtension { /** @var GridHelper */ private $gridHelper; @@ -31,10 +33,10 @@ public function __construct(GridHelper $gridHelper) public function getFunctions(): array { return [ - new \Twig_Function('sylius_grid_render', [$this->gridHelper, 'renderGrid'], ['is_safe' => ['html']]), - new \Twig_Function('sylius_grid_render_field', [$this->gridHelper, 'renderField'], ['is_safe' => ['html']]), - new \Twig_Function('sylius_grid_render_action', [$this->gridHelper, 'renderAction'], ['is_safe' => ['html']]), - new \Twig_Function('sylius_grid_render_filter', [$this->gridHelper, 'renderFilter'], ['is_safe' => ['html']]), + new TwigFunction('sylius_grid_render', [$this->gridHelper, 'renderGrid'], ['is_safe' => ['html']]), + new TwigFunction('sylius_grid_render_field', [$this->gridHelper, 'renderField'], ['is_safe' => ['html']]), + new TwigFunction('sylius_grid_render_action', [$this->gridHelper, 'renderAction'], ['is_safe' => ['html']]), + new TwigFunction('sylius_grid_render_filter', [$this->gridHelper, 'renderFilter'], ['is_safe' => ['html']]), ]; } } diff --git a/src/Component/.gitignore b/src/Component/.gitignore index fd1773e7..0b98d799 100644 --- a/src/Component/.gitignore +++ b/src/Component/.gitignore @@ -1,4 +1,5 @@ /vendor/ +!/vendor/.gitignore /bin/ /composer.phar diff --git a/src/Component/Data/DataProviderInterface.php b/src/Component/Data/DataProviderInterface.php index 9ad01941..9ea2a60b 100644 --- a/src/Component/Data/DataProviderInterface.php +++ b/src/Component/Data/DataProviderInterface.php @@ -18,5 +18,8 @@ interface DataProviderInterface { + /** + * @return mixed + */ public function getData(Grid $grid, Parameters $parameters); } diff --git a/src/Component/Data/DataSourceInterface.php b/src/Component/Data/DataSourceInterface.php index 84a0d3e9..fe1316cf 100644 --- a/src/Component/Data/DataSourceInterface.php +++ b/src/Component/Data/DataSourceInterface.php @@ -21,9 +21,15 @@ interface DataSourceInterface public const CONDITION_OR = 'or'; + /** + * @param mixed $expression + */ public function restrict($expression, string $condition = self::CONDITION_AND): void; public function getExpressionBuilder(): ExpressionBuilderInterface; + /** + * @return mixed + */ public function getData(Parameters $parameters); } diff --git a/src/Component/Data/ExpressionBuilderInterface.php b/src/Component/Data/ExpressionBuilderInterface.php index 4cfaa9f0..ef8bc1e3 100644 --- a/src/Component/Data/ExpressionBuilderInterface.php +++ b/src/Component/Data/ExpressionBuilderInterface.php @@ -17,41 +17,104 @@ interface ExpressionBuilderInterface { /** * @param mixed ...$expressions + * + * @return mixed */ public function andX(...$expressions); /** * @param mixed ...$expressions + * + * @return mixed */ public function orX(...$expressions); + /** + * @param mixed $value + * + * @return mixed + */ public function comparison(string $field, string $operator, $value); + /** + * @param mixed $value + * + * @return mixed + */ public function equals(string $field, $value); + /** + * @param mixed $value + * + * @return mixed + */ public function notEquals(string $field, $value); + /** + * @param mixed $value + * + * @return mixed + */ public function lessThan(string $field, $value); + /** + * @param mixed $value + * + * @return mixed + */ public function lessThanOrEqual(string $field, $value); + /** + * @param mixed $value + * + * @return mixed + */ public function greaterThan(string $field, $value); + /** + * @param mixed $value + * + * @return mixed + */ public function greaterThanOrEqual(string $field, $value); + /** + * @return mixed + */ public function in(string $field, array $values); + /** + * @return mixed + */ public function notIn(string $field, array $values); + /** + * @return mixed + */ public function isNull(string $field); + /** + * @return mixed + */ public function isNotNull(string $field); + /** + * @return mixed + */ public function like(string $field, string $pattern); + /** + * @return mixed + */ public function notLike(string $field, string $pattern); + /** + * @return mixed + */ public function orderBy(string $field, string $direction); + /** + * @return mixed + */ public function addOrderBy(string $field, string $direction); } diff --git a/src/Component/DataExtractor/DataExtractorInterface.php b/src/Component/DataExtractor/DataExtractorInterface.php index 63fa3a80..75ba36ea 100644 --- a/src/Component/DataExtractor/DataExtractorInterface.php +++ b/src/Component/DataExtractor/DataExtractorInterface.php @@ -17,5 +17,10 @@ interface DataExtractorInterface { + /** + * @param mixed $data + * + * @return mixed + */ public function get(Field $field, $data); } diff --git a/src/Component/Definition/Action.php b/src/Component/Definition/Action.php index cc6ce835..b6591240 100644 --- a/src/Component/Definition/Action.php +++ b/src/Component/Definition/Action.php @@ -21,13 +21,13 @@ class Action /** @var string */ private $type; - /** @var string */ + /** @var string|null */ private $label; /** @var bool */ private $enabled = true; - /** @var string */ + /** @var string|null */ private $icon; /** @var array */ diff --git a/src/Component/Definition/Filter.php b/src/Component/Definition/Filter.php index daeb64dc..eb9e6098 100644 --- a/src/Component/Definition/Filter.php +++ b/src/Component/Definition/Filter.php @@ -21,13 +21,13 @@ class Filter /** @var string */ private $type; - /** @var string */ + /** @var string|null */ private $label; /** @var bool */ private $enabled = true; - /** @var string */ + /** @var string|null */ private $template; /** @var array */ @@ -70,11 +70,17 @@ public function getType(): string return $this->type; } + /** + * @return string|null + */ public function getLabel() { return $this->label; } + /** + * @param string|null $label + */ public function setLabel($label): void { $this->label = $label; @@ -130,11 +136,19 @@ public function setPosition(int $position): void $this->position = $position; } + /** + * @return mixed + */ public function getCriteria() { return $this->criteria; } + /** + * @param mixed $criteria + * + * @psalm-suppress MissingReturnType + */ public function setCriteria($criteria) { $this->criteria = $criteria; diff --git a/src/Component/Definition/Grid.php b/src/Component/Definition/Grid.php index 946d83cc..5442525a 100644 --- a/src/Component/Definition/Grid.php +++ b/src/Component/Definition/Grid.php @@ -213,6 +213,8 @@ public function getActions(string $groupName): array } /** + * @param string $groupName + * * @return array|Action[] */ public function getEnabledActions($groupName): array diff --git a/src/Component/FieldTypes/DatetimeFieldType.php b/src/Component/FieldTypes/DatetimeFieldType.php index 823cc584..2509cb21 100644 --- a/src/Component/FieldTypes/DatetimeFieldType.php +++ b/src/Component/FieldTypes/DatetimeFieldType.php @@ -37,9 +37,10 @@ public function render(Field $field, $data, array $options) { $value = $this->dataExtractor->get($field, $data); if (null === $value) { - return null; + return ''; } + /** @var \DateTimeInterface $value */ Assert::isInstanceOf($value, \DateTimeInterface::class); return $value->format($options['format']); diff --git a/src/Component/FieldTypes/FieldTypeInterface.php b/src/Component/FieldTypes/FieldTypeInterface.php index 700693d7..6209af0b 100644 --- a/src/Component/FieldTypes/FieldTypeInterface.php +++ b/src/Component/FieldTypes/FieldTypeInterface.php @@ -21,6 +21,10 @@ interface FieldTypeInterface /** * Return a HTML representation of the $field using the given $data and * $options. + * + * @param mixed $data + * + * @return string */ public function render(Field $field, $data, array $options); diff --git a/src/Component/Filter/DateFilter.php b/src/Component/Filter/DateFilter.php index 5fd1d69e..d94f6bbc 100644 --- a/src/Component/Filter/DateFilter.php +++ b/src/Component/Filter/DateFilter.php @@ -54,6 +54,11 @@ public function apply(DataSourceInterface $dataSource, string $name, $data, arra } } + /** + * @param mixed $default + * + * @return mixed + */ private function getOption(array $options, string $name, $default) { return $options[$name] ?? $default; diff --git a/src/Component/Filter/StringFilter.php b/src/Component/Filter/StringFilter.php index 65b3fd2b..ddf293a4 100644 --- a/src/Component/Filter/StringFilter.php +++ b/src/Component/Filter/StringFilter.php @@ -61,7 +61,7 @@ public function apply(DataSourceInterface $dataSource, string $name, $data, arra $type = $data['type']; $value = array_key_exists('value', $data) ? $data['value'] : null; - if (!in_array($type, [self::TYPE_NOT_EMPTY, self::TYPE_EMPTY], true) && '' === trim($value)) { + if (!in_array($type, [self::TYPE_NOT_EMPTY, self::TYPE_EMPTY], true) && '' === trim((string) $value)) { return; } @@ -86,6 +86,10 @@ public function apply(DataSourceInterface $dataSource, string $name, $data, arra } /** + * @param mixed $value + * + * @return mixed + * * @throws \InvalidArgumentException */ private function getExpression( diff --git a/src/Component/Filtering/FilterInterface.php b/src/Component/Filtering/FilterInterface.php index ac3c058d..5845bd01 100644 --- a/src/Component/Filtering/FilterInterface.php +++ b/src/Component/Filtering/FilterInterface.php @@ -17,5 +17,8 @@ interface FilterInterface { + /** + * @param mixed $data + */ public function apply(DataSourceInterface $dataSource, string $name, $data, array $options): void; } diff --git a/src/Component/Filtering/FiltersCriteriaResolver.php b/src/Component/Filtering/FiltersCriteriaResolver.php index c651df71..3dffa4b1 100644 --- a/src/Component/Filtering/FiltersCriteriaResolver.php +++ b/src/Component/Filtering/FiltersCriteriaResolver.php @@ -32,9 +32,13 @@ public function hasCriteria(Grid $grid, Parameters $parameters): bool */ public function getCriteria(Grid $grid, Parameters $parameters): array { - $defaultCriteria = array_map(function (Filter $filter) { - return $filter->getCriteria(); - }, $this->getFiltersDefaultCriteria($grid->getFilters())); + $defaultCriteria = array_map( + /** @return mixed */ + function (Filter $filter) { + return $filter->getCriteria(); + }, + $this->getFiltersDefaultCriteria($grid->getFilters()) + ); return $parameters->get('criteria', $defaultCriteria); } diff --git a/src/Component/Parameters.php b/src/Component/Parameters.php index c2ecc8c6..5c7df939 100644 --- a/src/Component/Parameters.php +++ b/src/Component/Parameters.php @@ -15,9 +15,12 @@ final class Parameters { - /** @var array */ + /** @var array */ private $parameters; + /** + * @param array $parameters + */ public function __construct(array $parameters = []) { $this->parameters = $parameters; @@ -33,6 +36,11 @@ public function keys(): array return array_keys($this->parameters); } + /** + * @param mixed $default + * + * @return mixed + */ public function get(string $key, $default = null) { return $this->has($key) ? $this->parameters[$key] : $default; diff --git a/src/Component/Provider/ArrayGridProvider.php b/src/Component/Provider/ArrayGridProvider.php index a2b36e3d..10166657 100644 --- a/src/Component/Provider/ArrayGridProvider.php +++ b/src/Component/Provider/ArrayGridProvider.php @@ -57,6 +57,6 @@ private function extend(array $gridConfiguration, array $parentGridConfiguration unset($configuration['extends']); - return $configuration ?? []; + return $configuration; } } diff --git a/src/Component/Renderer/GridRendererInterface.php b/src/Component/Renderer/GridRendererInterface.php index 56019a2a..3ae7fb6e 100644 --- a/src/Component/Renderer/GridRendererInterface.php +++ b/src/Component/Renderer/GridRendererInterface.php @@ -20,14 +20,27 @@ interface GridRendererInterface { + /** + * @return string + */ public function render(GridViewInterface $gridView, ?string $template = null); + /** + * @param mixed $data + * + * @return string + */ public function renderField(GridViewInterface $gridView, Field $field, $data); /** * @param mixed|null $data + * + * @return string */ public function renderAction(GridViewInterface $gridView, Action $action, $data = null); + /** + * @return string + */ public function renderFilter(GridViewInterface $gridView, Filter $filter); } diff --git a/src/Component/View/GridView.php b/src/Component/View/GridView.php index 59f1ff13..e0db3420 100644 --- a/src/Component/View/GridView.php +++ b/src/Component/View/GridView.php @@ -28,6 +28,9 @@ class GridView implements GridViewInterface /** @var Parameters */ private $parameters; + /** + * @param mixed $data + */ public function __construct($data, Grid $definition, Parameters $parameters) { $this->data = $data; diff --git a/src/Component/View/GridViewInterface.php b/src/Component/View/GridViewInterface.php index a251c0f5..50ea9ab6 100644 --- a/src/Component/View/GridViewInterface.php +++ b/src/Component/View/GridViewInterface.php @@ -18,6 +18,9 @@ interface GridViewInterface { + /** + * @return mixed + */ public function getData(); public function getDefinition(): Grid; diff --git a/src/Component/spec/FieldTypes/DatetimeFieldTypeSpec.php b/src/Component/spec/FieldTypes/DatetimeFieldTypeSpec.php index c4a1f201..574eb3eb 100644 --- a/src/Component/spec/FieldTypes/DatetimeFieldTypeSpec.php +++ b/src/Component/spec/FieldTypes/DatetimeFieldTypeSpec.php @@ -50,7 +50,7 @@ function it_returns_null_if_property_accessor_returns_null(DataExtractorInterfac $this->render($field, ['foo' => 'bar'], [ 'format' => '', - ])->shouldReturn(null); + ])->shouldReturn(''); } function it_throws_exception_if_returned_value_is_not_datetime(DataExtractorInterface $dataExtractor, Field $field): void