diff --git a/.gitignore b/.gitignore index df3f117..7f4b781 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /phpunit.xml /composer.lock +.php_cs.cache *.phar /vendor/ /bin/ diff --git a/.php_cs b/.php_cs index b851ebc..6b5bddd 100644 --- a/.php_cs +++ b/.php_cs @@ -1,5 +1,7 @@ setUsingCache(true) + ->setRiskyAllowed(true) +; -return Symfony\CS\Config\Config::create() - ->setUsingLinter(false) - // use SYMFONY_LEVEL: - ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) - // and extra fixers: - ->fixers(array( - 'ordered_use', - //'strict', - 'strict_param', - 'short_array_syntax', - 'phpdoc_order', - 'header_comment', - '-psr0', - )) - ->finder( - Symfony\CS\Finder\DefaultFinder::create() - ->exclude(array('bin', 'doc')) - ->in(__DIR__) +$config->setRules( + array_merge( + $config->getRules(), + ['header_comment' => ['header' => $header]] ) -; +); + +return $config; diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 0000000..08cbe17 --- /dev/null +++ b/.styleci.yml @@ -0,0 +1,20 @@ +preset: symfony + +risky: true + +linting: false + +enabled: + #- ordered_class_elements + - ordered_imports + - phpdoc_order + - short_array_syntax + - strict_param + #- declare_strict_types + +finder: + path: + - 'src/' + - 'tests/' + not-path: + - 'Fixtures' diff --git a/composer.json b/composer.json index bd7ef68..2c2a308 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ "symfony/intl": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^5.5" + "phpunit/phpunit": "^5.5", + "sllh/php-cs-fixer-styleci-bridge": "^2.1" }, "autoload": { "psr-4": { diff --git a/src/AbstractDatagridExtension.php b/src/AbstractDatagridExtension.php index bb88e40..22cdce4 100644 --- a/src/AbstractDatagridExtension.php +++ b/src/AbstractDatagridExtension.php @@ -1,4 +1,4 @@ -types) { $this->initColumnTypes(); @@ -54,7 +54,7 @@ public function getType($type) /** * {@inheritdoc} */ - public function hasType($type) + public function hasType($type): bool { if (null === $this->types) { $this->initColumnTypes(); @@ -66,7 +66,7 @@ public function hasType($type) /** * {@inheritdoc} */ - public function hasTypeExtensions($type) + public function hasTypeExtensions($type): bool { if (null === $this->typesExtensions) { $this->initTypesExtensions(); @@ -78,7 +78,7 @@ public function hasTypeExtensions($type) /** * {@inheritdoc} */ - public function getTypeExtensions($type) + public function getTypeExtensions($type): array { if (null === $this->typesExtensions) { $this->initTypesExtensions(); @@ -96,7 +96,7 @@ public function getTypeExtensions($type) * * @codeCoverageIgnore */ - protected function loadTypes() + protected function loadTypes(): array { return []; } @@ -110,7 +110,7 @@ protected function loadTypes() * * @codeCoverageIgnore */ - protected function loadTypesExtensions() + protected function loadTypesExtensions(): array { return []; } diff --git a/src/Column/AbstractType.php b/src/Column/AbstractType.php index 5c73886..11f6e6b 100644 --- a/src/Column/AbstractType.php +++ b/src/Column/AbstractType.php @@ -1,4 +1,4 @@ -name; } @@ -91,7 +91,7 @@ public function getName() /** * {@inheritdoc} */ - public function getType() + public function getType(): ResolvedColumnTypeInterface { return $this->type; } @@ -131,7 +131,7 @@ public function resetViewTransformers() /** * {@inheritdoc} */ - public function getViewTransformers() + public function getViewTransformers(): array { return $this->viewTransformers; } @@ -139,7 +139,7 @@ public function getViewTransformers() /** * {@inheritdoc} */ - public function getOptions() + public function getOptions(): array { return $this->options; } @@ -159,7 +159,7 @@ public function getOption($name, $default = null) /** * {@inheritdoc} */ - public function hasOption($name) + public function hasOption($name): bool { return array_key_exists($name, $this->options); } @@ -167,7 +167,7 @@ public function hasOption($name) /** * {@inheritdoc} */ - public function createHeaderView(DatagridView $datagrid) + public function createHeaderView(DatagridView $datagrid): HeaderView { // The methods createHeaderView(), buildHeaderView() are called // explicitly here in order to be able to override either of them @@ -182,7 +182,7 @@ public function createHeaderView(DatagridView $datagrid) /** * {@inheritdoc} */ - public function createCellView(DatagridView $datagrid, $object, $index) + public function createCellView(DatagridView $datagrid, $object, $index): CellView { // The methods createCellView(), buildCellView() are called // explicitly here in order to be able to override either of them @@ -214,7 +214,7 @@ public function setDataProvider(callable $dataProvider) * * @return callable */ - public function getDataProvider() + public function getDataProvider(): callable { return $this->dataProvider; } diff --git a/src/Column/ColumnInterface.php b/src/Column/ColumnInterface.php index 0e0db4c..9fe2b6b 100644 --- a/src/Column/ColumnInterface.php +++ b/src/Column/ColumnInterface.php @@ -1,4 +1,4 @@ -types[$name])) { $type = null; @@ -92,7 +92,7 @@ public function getType($name) /** * {@inheritdoc} */ - public function hasType($name) + public function hasType($name): bool { if (isset($this->types[$name])) { return true; @@ -110,20 +110,12 @@ public function hasType($name) /** * {@inheritdoc} */ - public function getExtensions() + public function getExtensions(): array { return $this->extensions; } - /** - * Wraps a type into a ResolvedFormTypeInterface implementation and connects - * it with its parent type. - * - * @param ColumnTypeInterface $type The type to resolve - * - * @return ResolvedColumnTypeInterface The resolved type - */ - private function resolveType(ColumnTypeInterface $type) + private function resolveType(ColumnTypeInterface $type): ResolvedColumnTypeInterface { $parentType = $type->getParent(); $fqcn = get_class($type); diff --git a/src/Column/ColumnTypeRegistryInterface.php b/src/Column/ColumnTypeRegistryInterface.php index 35fd322..a887c50 100644 --- a/src/Column/ColumnTypeRegistryInterface.php +++ b/src/Column/ColumnTypeRegistryInterface.php @@ -1,4 +1,4 @@ -innerType->getBlockPrefix(); } @@ -87,7 +87,7 @@ public function getParent() * * @return ColumnTypeInterface The wrapped column type */ - public function getInnerType() + public function getInnerType(): ColumnTypeInterface { return $this->innerType; } @@ -97,7 +97,7 @@ public function getInnerType() * * @return ColumnTypeExtensionInterface[] An array of {@link ColumnTypeExtensionInterface} instances */ - public function getTypeExtensions() + public function getTypeExtensions(): array { return $this->typeExtensions; } @@ -132,7 +132,7 @@ public function buildType(ColumnInterface $config, array $options) * * @return ColumnInterface */ - public function createColumn($name, array $options = []) + public function createColumn(string $name, array $options = []): ColumnInterface { $options = $this->getOptionsResolver()->resolve($options); $builder = $this->newColumn($name, $options); @@ -143,7 +143,7 @@ public function createColumn($name, array $options = []) /** * {inheritdoc}. */ - public function createHeaderView(ColumnInterface $column, DatagridView $datagrid) + public function createHeaderView(ColumnInterface $column, DatagridView $datagrid): HeaderView { $view = new HeaderView($column, $datagrid, $column->getOption('label')); @@ -153,7 +153,7 @@ public function createHeaderView(ColumnInterface $column, DatagridView $datagrid /** * {inheritdoc}. */ - public function createCellView(ColumnInterface $column, DatagridView $datagrid) + public function createCellView(ColumnInterface $column, DatagridView $datagrid): CellView { $view = new CellView($column, $datagrid); @@ -220,7 +220,7 @@ public function getValue(ColumnInterface $column, $object, $useTransformers = tr * * @return OptionsResolver The options resolver */ - public function getOptionsResolver() + public function getOptionsResolver(): OptionsResolver { if (null === $this->optionsResolver) { if (null !== $this->parent) { @@ -247,9 +247,9 @@ public function getOptionsResolver() * @param string $name The name of the column * @param array $options The builder options * - * @return Column The new field instance + * @return ColumnInterface The new field instance */ - protected function newColumn($name, array $options) + protected function newColumn($name, array $options): ColumnInterface { return new Column($name, $this, $options); } diff --git a/src/Column/ResolvedColumnTypeFactory.php b/src/Column/ResolvedColumnTypeFactory.php index 01e03ac..dfc3f25 100644 --- a/src/Column/ResolvedColumnTypeFactory.php +++ b/src/Column/ResolvedColumnTypeFactory.php @@ -1,4 +1,4 @@ -name; } @@ -90,7 +90,7 @@ public function getName() /** * {@inheritdoc} */ - public function getColumn($name) + public function getColumn($name): ColumnInterface { if (!isset($this->columns[$name])) { throw new UnknownColumnException($name, $this); @@ -102,7 +102,7 @@ public function getColumn($name) /** * {@inheritdoc} */ - public function getColumns() + public function getColumns(): array { return $this->columns; } @@ -110,7 +110,7 @@ public function getColumns() /** * {@inheritdoc} */ - public function hasColumn($name) + public function hasColumn($name): bool { return isset($this->columns[$name]); } @@ -118,7 +118,7 @@ public function hasColumn($name) /** * {@inheritdoc} */ - public function hasColumnType($type) + public function hasColumnType($type): bool { foreach ($this->columns as $column) { if ($column->getType()->getInnerType() instanceof $type) { @@ -158,7 +158,7 @@ public function getData() /** * {@inheritdoc} */ - public function createView() + public function createView(): DatagridView { if (!isset($this->data)) { throw new BadMethodCallException( diff --git a/src/DatagridBuilder.php b/src/DatagridBuilder.php index 65e6056..c2d992e 100644 --- a/src/DatagridBuilder.php +++ b/src/DatagridBuilder.php @@ -1,4 +1,4 @@ - @@ -35,7 +35,7 @@ public function __construct(ColumnTypeRegistryInterface $registry) /** * {@inheritdoc} */ - public function createDatagrid($name, array $columns) + public function createDatagrid(string $name, array $columns): DatagridInterface { return new Datagrid($name, $columns); } @@ -43,7 +43,7 @@ public function createDatagrid($name, array $columns) /** * {@inheritdoc} */ - public function createDatagridBuilder($name) + public function createDatagridBuilder(string $name): DatagridBuilderInterface { return new DatagridBuilder($this, $name); } @@ -51,18 +51,14 @@ public function createDatagridBuilder($name) /** * {@inheritdoc} */ - public function createColumn($name, $type, array $options = []) + public function createColumn(string $name, string $type, array $options = []): ColumnInterface { - if (!is_string($type)) { - throw new UnexpectedTypeException($type, 'string'); - } - $type = $this->typeRegistry->getType($type); $column = $type->createColumn($name, $options); // Explicitly call buildType() in order to be able to override either - // createColumn() or buildType() in the resolved column type + // createColumn() or buildType() in the resolved column type. $type->buildType($column, $column->getOptions()); return $column; diff --git a/src/DatagridFactoryInterface.php b/src/DatagridFactoryInterface.php index 2f459da..29a2586 100644 --- a/src/DatagridFactoryInterface.php +++ b/src/DatagridFactoryInterface.php @@ -1,4 +1,4 @@ -datagrid = $datagridView; $this->source = $source; diff --git a/src/DatagridView.php b/src/DatagridView.php index cf6f498..7e48b48 100644 --- a/src/DatagridView.php +++ b/src/DatagridView.php @@ -1,4 +1,4 @@ -name = $datagrid->getName(); @@ -77,18 +72,12 @@ public function __construct(DatagridInterface $datagrid) } } - /** - * {@inheritdoc} - */ - public function hasColumn($name) + public function hasColumn(string $name): bool { return isset($this->columns[$name]); } - /** - * {@inheritdoc} - */ - public function getColumn($name) + public function getColumn(string $name): HeaderView { if (isset($this->columns[$name])) { return $this->columns[$name]; @@ -108,7 +97,7 @@ public function getColumn($name) * * @return mixed */ - public function getVar($key, $default = null) + public function getVar(string $key, $default = null) { if (array_key_exists($key, $this->vars)) { return $this->vars[$key]; diff --git a/src/Exception/BadMethodCallException.php b/src/Exception/BadMethodCallException.php index d8299f8..dbc88c7 100644 --- a/src/Exception/BadMethodCallException.php +++ b/src/Exception/BadMethodCallException.php @@ -1,4 +1,4 @@ - + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ namespace Rollerworks\Component\Datagrid\Exception; final class DataProviderException extends \RuntimeException implements ExceptionInterface { - public static function autoAccessorUnableToGetValue($columnName, \Exception $previous = null) + public static function autoAccessorUnableToGetValue(string $columnName, \Exception $previous = null) { return new self( sprintf('Unable to get value for column "%s". Consider setting the "data_provider" option.', $columnName), diff --git a/src/Exception/DatagridColumnException.php b/src/Exception/DatagridColumnException.php index 1bf6156..da60453 100644 --- a/src/Exception/DatagridColumnException.php +++ b/src/Exception/DatagridColumnException.php @@ -1,4 +1,4 @@ -datagrid; } @@ -53,7 +53,7 @@ public function getDatagrid() /** * @return string */ - public function getColumnName() + public function getColumnName(): string { return $this->columnName; } diff --git a/src/Extension/Core/CoreExtension.php b/src/Extension/Core/CoreExtension.php index e8b9f8b..c7fe4e6 100644 --- a/src/Extension/Core/CoreExtension.php +++ b/src/Extension/Core/CoreExtension.php @@ -1,4 +1,4 @@ -timeFormat; $timezone = $this->outputTimezone; $calendar = $this->calendar; - $pattern = $this->pattern; + $pattern = $this->pattern ?? ''; $intlDateFormatter = new \IntlDateFormatter(\Locale::getDefault(), $dateFormat, $timeFormat, $timezone, $calendar, $pattern); $intlDateFormatter->setLenient(false); diff --git a/src/Extension/Core/DataTransformer/EmptyValueTransformer.php b/src/Extension/Core/DataTransformer/EmptyValueTransformer.php index 55b4d2f..5085a21 100644 --- a/src/Extension/Core/DataTransformer/EmptyValueTransformer.php +++ b/src/Extension/Core/DataTransformer/EmptyValueTransformer.php @@ -1,4 +1,4 @@ -inputTimezone !== $this->outputTimezone) { - $dateTime->setTimeZone(new \DateTimeZone($this->inputTimezone)); + $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone)); } } catch (TransformationFailedException $e) { throw $e; diff --git a/src/Extension/Core/DataTransformer/TimestampToDateTimeTransformer.php b/src/Extension/Core/DataTransformer/TimestampToDateTimeTransformer.php index 8bc6499..76681bd 100644 --- a/src/Extension/Core/DataTransformer/TimestampToDateTimeTransformer.php +++ b/src/Extension/Core/DataTransformer/TimestampToDateTimeTransformer.php @@ -1,4 +1,4 @@ -setTimezone(new \DateTimeZone($this->outputTimezone)); - $dateTime->setTimestamp($value); + $dateTime->setTimestamp((int) $value); if ($this->inputTimezone !== $this->outputTimezone) { $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone)); diff --git a/src/Extension/Core/DataTransformer/ValueFormatTransformer.php b/src/Extension/Core/DataTransformer/ValueFormatTransformer.php index b9b318a..e0992d2 100644 --- a/src/Extension/Core/DataTransformer/ValueFormatTransformer.php +++ b/src/Extension/Core/DataTransformer/ValueFormatTransformer.php @@ -1,4 +1,4 @@ -formatValue($value, $this->format, $this->glue); } - private function formatValue($value, $format, $glue) + private function formatValue($value, $format, $glue): string { $formatCallable = is_callable($format); diff --git a/src/Extension/Core/Type/ActionType.php b/src/Extension/Core/Type/ActionType.php index ff7c526..bcca1c7 100644 --- a/src/Extension/Core/Type/ActionType.php +++ b/src/Extension/Core/Type/ActionType.php @@ -1,4 +1,4 @@ -assertNotEquals($expectedValue, $view->value); } - abstract protected function getTestedType(); + abstract protected function getTestedType(): string; } diff --git a/src/Test/DatagridIntegrationTestCase.php b/src/Test/DatagridIntegrationTestCase.php index a65c90f..52333d3 100644 --- a/src/Test/DatagridIntegrationTestCase.php +++ b/src/Test/DatagridIntegrationTestCase.php @@ -1,4 +1,4 @@ -factory = new DatagridFactory($typesRegistry); } - protected function getExtensions() + protected function getExtensions(): array { return []; } diff --git a/src/Test/DatagridPerformanceTestCase.php b/src/Test/DatagridPerformanceTestCase.php index c679125..13c83a9 100644 --- a/src/Test/DatagridPerformanceTestCase.php +++ b/src/Test/DatagridPerformanceTestCase.php @@ -1,4 +1,4 @@ -= 0) { $this->maxRunningTime = $maxRunningTime; @@ -64,7 +64,7 @@ public function setMaxRunningTime($maxRunningTime) /** * @return int */ - public function getMaxRunningTime() + public function getMaxRunningTime(): int { return $this->maxRunningTime; } diff --git a/src/Util/StringUtil.php b/src/Util/StringUtil.php index bb6fea7..9f1e5ff 100644 --- a/src/Util/StringUtil.php +++ b/src/Util/StringUtil.php @@ -1,4 +1,4 @@ - '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'month' => 2, + 'day' => 3, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]; $output = new \DateTime('2010-02-03 04:05:06 UTC'); @@ -50,12 +50,12 @@ public function testTransformWithSomeZero() $transformer = new ArrayToDateTimeTransformer('UTC', 'UTC'); $input = [ - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '0', - 'second' => '0', + 'year' => 2010, + 'month' => 2, + 'day' => 3, + 'hour' => 4, + 'minute' => 0, + 'second' => 0, ]; $output = new \DateTime('2010-02-03 04:00:00 UTC'); @@ -99,11 +99,11 @@ public function testTransformPartiallyEmptyYear() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'month' => 2, + 'day' => 3, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } @@ -114,11 +114,11 @@ public function testTransformPartiallyEmptyMonth() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'day' => 3, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } @@ -129,11 +129,11 @@ public function testTransformPartiallyEmptyDay() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '2', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'month' => 2, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } @@ -144,11 +144,11 @@ public function testTransformPartiallyEmptyHour() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'month' => 2, + 'day' => 3, + 'minute' => 5, + 'second' => 6, ]); } @@ -159,11 +159,11 @@ public function testTransformPartiallyEmptyMinute() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'second' => '6', + 'year' => 2010, + 'month' => 2, + 'day' => 3, + 'hour' => 4, + 'second' => 6, ]); } @@ -174,11 +174,11 @@ public function testTransformPartiallyEmptySecond() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', + 'year' => 2010, + 'month' => 2, + 'day' => 3, + 'hour' => 4, + 'minute' => 5, ]); } @@ -194,12 +194,12 @@ public function testTransformDifferentTimezones() $transformer = new ArrayToDateTimeTransformer('America/New_York', 'Asia/Hong_Kong'); $input = [ - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'month' => 2, + 'day' => 3, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]; $output = new \DateTime('2010-02-03 04:05:06 Asia/Hong_Kong'); @@ -213,12 +213,12 @@ public function testTransformToDifferentTimezone() $transformer = new ArrayToDateTimeTransformer('Asia/Hong_Kong', 'UTC'); $input = [ - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'month' => 2, + 'day' => 3, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]; $output = new \DateTime('2010-02-03 04:05:06 UTC'); @@ -243,12 +243,12 @@ public function testTransformWithNegativeYear() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '-1', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'year' => -1, + 'month' => 2, + 'day' => 3, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } @@ -259,12 +259,12 @@ public function testTransformWithNegativeMonth() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '-1', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'month' => -1, + 'day' => 3, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } @@ -275,12 +275,12 @@ public function testTransformWithNegativeDay() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '2', - 'day' => '-1', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'month' => 2, + 'day' => -1, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } @@ -291,12 +291,12 @@ public function testTransformWithNegativeHour() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '-1', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'month' => 2, + 'day' => 3, + 'hour' => -1, + 'minute' => 5, + 'second' => 6, ]); } @@ -307,12 +307,12 @@ public function testTransformWithNegativeMinute() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '-1', - 'second' => '6', + 'year' => 2010, + 'month' => 2, + 'day' => 3, + 'hour' => 4, + 'minute' => -1, + 'second' => 6, ]); } @@ -323,12 +323,12 @@ public function testTransformWithNegativeSecond() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '-1', + 'year' => 2010, + 'month' => 2, + 'day' => 3, + 'hour' => 4, + 'minute' => 5, + 'second' => -1, ]); } @@ -339,12 +339,12 @@ public function testTransformWithInvalidMonth() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '13', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'month' => 13, + 'day' => 3, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } @@ -355,12 +355,12 @@ public function testTransformWithInvalidDay() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '2', - 'day' => '31', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'year' => 2010, + 'month' => 2, + 'day' => 31, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } @@ -371,12 +371,12 @@ public function testTransformWithStringDay() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', - 'month' => '2', + 'year' => 2010, + 'month' => 2, 'day' => 'bazinga', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } @@ -387,12 +387,12 @@ public function testTransformWithStringMonth() { $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ - 'year' => '2010', + 'year' => 2010, 'month' => 'bazinga', - 'day' => '31', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'day' => 31, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } @@ -404,11 +404,11 @@ public function testTransformWithStringYear() $transformer = new ArrayToDateTimeTransformer(); $transformer->transform([ 'year' => 'bazinga', - 'month' => '2', - 'day' => '31', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', + 'month' => 2, + 'day' => 31, + 'hour' => 4, + 'minute' => 5, + 'second' => 6, ]); } } diff --git a/tests/Extension/Core/DataTransformer/DateTimeTestCase.php b/tests/Extension/Core/DataTransformer/DateTimeTestCase.php index 392e0a7..afaa5be 100644 --- a/tests/Extension/Core/DataTransformer/DateTimeTestCase.php +++ b/tests/Extension/Core/DataTransformer/DateTimeTestCase.php @@ -1,4 +1,4 @@ -createView(); } - protected function getTestedType() + protected function getTestedType(): string { return ColumnType::class; } diff --git a/tests/Extension/Core/Type/CompoundColumnTypeTest.php b/tests/Extension/Core/Type/CompoundColumnTypeTest.php index 9ecd5d1..70c724e 100644 --- a/tests/Extension/Core/Type/CompoundColumnTypeTest.php +++ b/tests/Extension/Core/Type/CompoundColumnTypeTest.php @@ -1,4 +1,4 @@ -assertSame('My label', $view->label); } - protected function getTestedType() + protected function getTestedType(): string { return DateTimeType::class; } diff --git a/tests/Extension/Core/Type/MoneyTypeTest.php b/tests/Extension/Core/Type/MoneyTypeTest.php index ff5c9fb..b26765e 100644 --- a/tests/Extension/Core/Type/MoneyTypeTest.php +++ b/tests/Extension/Core/Type/MoneyTypeTest.php @@ -1,4 +1,4 @@ -assertCellValueEquals(' - foo - , - ?2 - ', $data, $options); } - protected function getTestedType() + protected function getTestedType(): string { return TextType::class; } diff --git a/tests/Fixtures/Entity.php b/tests/Fixtures/Entity.php index 4acc301..e18fee9 100644 --- a/tests/Fixtures/Entity.php +++ b/tests/Fixtures/Entity.php @@ -1,4 +1,4 @@ -