diff --git a/.github/workflows/symfony.yml b/.github/workflows/symfony.yml index 87c15de..864a318 100644 --- a/.github/workflows/symfony.yml +++ b/.github/workflows/symfony.yml @@ -18,7 +18,6 @@ jobs: strategy: matrix: php-version: - - '7.4' - '8.1' steps: @@ -56,8 +55,6 @@ jobs: strategy: matrix: php-version: - - '7.4' - - '8.0' - '8.1' steps: diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 313b756..4eadc6e 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -17,6 +17,8 @@ file that was distributed with this source code.', 'location' => 'after_declare_strict', ], + 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], ]) ->setRiskyAllowed(true) ->setFinder($finder) diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..72e4d88 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ +Version 1.0.1 +============= +15 September 2023 + + - Allow newer versions of Twig (@Guite) + - Correct symfony/contracts to be more specific and fix Symfony v6 compatibility (@craigh) + - Fix small issue in unit tests (@On5-Repos) + - Fix dev dependencies at specific version (@mbabker) + - Reduce github actions matrix to only php 8.1 for QA related tools (@mbabker) + - Correct new QA issues from upgrades to tools (@craigh) + +Version 1.0.0 +============= +21 June 2022 + + - Initial release \ No newline at end of file diff --git a/composer.json b/composer.json index d5ca3b3..891b002 100644 --- a/composer.json +++ b/composer.json @@ -29,11 +29,11 @@ "symfony/validator": "^5.4 || ^6.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.8", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.6", - "phpstan/phpstan-symfony": "^1.1", - "phpunit/phpunit": "^9.5", + "friendsofphp/php-cs-fixer": "3.26.1", + "phpstan/extension-installer": "1.3.1", + "phpstan/phpstan": "1.10.34", + "phpstan/phpstan-symfony": "1.3.2", + "phpunit/phpunit": "9.6.12", "roave/security-advisories": "dev-latest" }, "suggest": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index d5534cc..3be855a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,4 @@ parameters: paths: - src - - tests level: 8 diff --git a/src/Container/AbstractSpecificationContainer.php b/src/Container/AbstractSpecificationContainer.php index 5881179..08dd9ca 100644 --- a/src/Container/AbstractSpecificationContainer.php +++ b/src/Container/AbstractSpecificationContainer.php @@ -15,14 +15,8 @@ abstract class AbstractSpecificationContainer implements SpecificationContainerInterface { - /** - * {@inheritDoc} - */ abstract public function getFormSpecifications(array $params = []): array; - /** - * {@inheritDoc} - */ public function getLabels(string $locale = ''): array { $labels = []; @@ -33,9 +27,6 @@ public function getLabels(string $locale = ''): array return $labels; } - /** - * {@inheritDoc} - */ public function getGroupedLabels(string $locale = ''): array { $labels = []; diff --git a/src/Entity/AbstractResponseData.php b/src/Entity/AbstractResponseData.php index b6018ac..69ba38d 100644 --- a/src/Entity/AbstractResponseData.php +++ b/src/Entity/AbstractResponseData.php @@ -22,17 +22,11 @@ abstract class AbstractResponseData implements ResponseDataInterface */ protected ?array $data = []; - /** - * {@inheritDoc} - */ public function getData(): ?array { return $this->data; } - /** - * {@inheritDoc} - */ public function setData(?array $data): void { $this->data = $data; diff --git a/src/Form/Data/FormTypesChoices.php b/src/Form/Data/FormTypesChoices.php index 7fce088..3d86345 100644 --- a/src/Form/Data/FormTypesChoices.php +++ b/src/Form/Data/FormTypesChoices.php @@ -14,7 +14,6 @@ namespace Zikula\Bundle\DynamicFormBundle\Form\Data; use ArrayAccess; -use Exception; use Iterator; /** @@ -23,7 +22,7 @@ * @implements Iterator|false> * @implements ArrayAccess> */ -class FormTypesChoices implements ArrayAccess, Iterator +class FormTypesChoices implements \ArrayAccess, \Iterator { /** * @var array> @@ -43,9 +42,6 @@ public function offsetExists($offset): bool return isset($this->choices[$offset]); } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function offsetGet($offset) { @@ -59,7 +55,7 @@ public function offsetSet($offset, $value): void public function offsetUnset($offset): void { - throw new Exception('Not allowed to unset!'); + throw new \Exception('Not allowed to unset!'); } public function rewind(): void @@ -67,18 +63,12 @@ public function rewind(): void reset($this->choices); } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function current() { return current($this->choices); } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function key() { diff --git a/src/Form/DataMapper/ChoiceWithOtherDataMapper.php b/src/Form/DataMapper/ChoiceWithOtherDataMapper.php index 599e5ab..10e7b93 100644 --- a/src/Form/DataMapper/ChoiceWithOtherDataMapper.php +++ b/src/Form/DataMapper/ChoiceWithOtherDataMapper.php @@ -19,9 +19,6 @@ class ChoiceWithOtherDataMapper implements DataMapperInterface { - /** - * {@inheritDoc} - */ public function mapDataToForms($viewData, \Traversable $forms): void { /** @var FormInterface[] $forms */ @@ -58,9 +55,6 @@ public function mapDataToForms($viewData, \Traversable $forms): void $forms['other']->setData($other); } - /** - * {@inheritDoc} - */ public function mapFormsToData(\Traversable $forms, &$viewData): void { /** @var FormInterface[] $forms */ @@ -87,7 +81,7 @@ public function mapFormsToData(\Traversable $forms, &$viewData): void $choicesData = array_merge($choicesData, $otherValue); } - $viewData = is_array($choicesData) ? implode(',', $choicesData) : $choicesData; + $viewData = implode(',', $choicesData); } } } diff --git a/src/Form/Type/ChoiceWithOtherType.php b/src/Form/Type/ChoiceWithOtherType.php index cc56932..38fe5bc 100644 --- a/src/Form/Type/ChoiceWithOtherType.php +++ b/src/Form/Type/ChoiceWithOtherType.php @@ -28,9 +28,6 @@ class ChoiceWithOtherType extends AbstractType { public const OTHER_VALUE = 'other'; - /** - * {@inheritdoc} - */ public function buildForm(FormBuilderInterface $builder, array $options): void { $builder @@ -54,9 +51,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void }); } - /** - * {@inheritdoc} - */ public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ diff --git a/src/Form/Type/FormSpecificationCollectionType.php b/src/Form/Type/FormSpecificationCollectionType.php index 046f21d..7420a41 100644 --- a/src/Form/Type/FormSpecificationCollectionType.php +++ b/src/Form/Type/FormSpecificationCollectionType.php @@ -31,7 +31,7 @@ public function configureOptions(OptionsResolver $resolver): void 'entry_type' => FormSpecificationType::class, 'allow_add' => true, 'allow_delete' => true, - 'delete_empty' => function (AbstractFormSpecification $property = null) { + 'delete_empty' => function (?AbstractFormSpecification $property = null) { return null === $property || empty($property->getName()); }, 'prototype' => true, // required for javascript to work diff --git a/src/Provider/LocaleProvider.php b/src/Provider/LocaleProvider.php index 81b6203..7dd9edf 100644 --- a/src/Provider/LocaleProvider.php +++ b/src/Provider/LocaleProvider.php @@ -28,9 +28,6 @@ public function __construct(EventDispatcherInterface $eventDispatcher, bool $tra $this->translate = $translate; } - /** - * {@inheritDoc} - */ public function getSupportedLocales(): array { if (!$this->translate) { @@ -41,10 +38,7 @@ public function getSupportedLocales(): array return $event->getSupportedLocales(); } - /** - * {@inheritDoc} - */ - public function getSupportedLocaleNames(string $displayLocale = null): array + public function getSupportedLocaleNames(?string $displayLocale = null): array { if (!$this->translate) { return ['Default' => 'default']; diff --git a/src/Provider/LocaleProviderInterface.php b/src/Provider/LocaleProviderInterface.php index 56250f0..c9d526a 100644 --- a/src/Provider/LocaleProviderInterface.php +++ b/src/Provider/LocaleProviderInterface.php @@ -27,5 +27,5 @@ public function getSupportedLocales(): array; * * @return array */ - public function getSupportedLocaleNames(string $displayLocale = null): array; + public function getSupportedLocaleNames(?string $displayLocale = null): array; } diff --git a/tests/Form/Data/FormTypesChoicesTest.php b/tests/Form/Data/FormTypesChoicesTest.php index 39e166b..a8f332c 100644 --- a/tests/Form/Data/FormTypesChoicesTest.php +++ b/tests/Form/Data/FormTypesChoicesTest.php @@ -13,10 +13,7 @@ namespace Zikula\Bundle\DynamicFormBundle\Tests\Form\Data; -use ArrayAccess; -use Iterator; use PHPUnit\Framework\TestCase; -use Traversable; use Zikula\Bundle\DynamicFormBundle\Form\Data\FormTypesChoices; class FormTypesChoicesTest extends TestCase @@ -27,9 +24,9 @@ class FormTypesChoicesTest extends TestCase public function testEmptyInstantiation(): void { $foo = new FormTypesChoices(); - $this->assertInstanceOf(ArrayAccess::class, $foo); - $this->assertInstanceOf(Iterator::class, $foo); - $this->assertInstanceOf(Traversable::class, $foo); + $this->assertInstanceOf(\ArrayAccess::class, $foo); + $this->assertInstanceOf(\Iterator::class, $foo); + $this->assertInstanceOf(\Traversable::class, $foo); } /** @@ -41,9 +38,9 @@ public function testInstantiationWithArg(): void 'foo' => ['bar' => 'bar'], 'three' => ['nine' => 'nine'], ]); - $this->assertInstanceOf(ArrayAccess::class, $foo); - $this->assertInstanceOf(Iterator::class, $foo); - $this->assertInstanceOf(Traversable::class, $foo); + $this->assertInstanceOf(\ArrayAccess::class, $foo); + $this->assertInstanceOf(\Iterator::class, $foo); + $this->assertInstanceOf(\Traversable::class, $foo); $this->assertArrayHasKey('foo', $foo); $this->assertArrayHasKey('three', $foo); } diff --git a/tests/Form/DataTransformer/ArrayToStringTransformerTest.php b/tests/Form/DataTransformer/ArrayToStringTransformerTest.php index e722b44..3a55b4a 100644 --- a/tests/Form/DataTransformer/ArrayToStringTransformerTest.php +++ b/tests/Form/DataTransformer/ArrayToStringTransformerTest.php @@ -23,6 +23,7 @@ class ArrayToStringTransformerTest extends TestCase { /** * @covers \Zikula\Bundle\DynamicFormBundle\Form\DataTransformer\ArrayToStringTransformer::transform + * * @dataProvider data */ public function testTransform(string $storedAs, string $submitted, string $restored): void @@ -33,6 +34,7 @@ public function testTransform(string $storedAs, string $submitted, string $resto /** * @covers \Zikula\Bundle\DynamicFormBundle\Form\DataTransformer\ArrayToStringTransformer::reverseTransform + * * @dataProvider data */ public function testReverseTransform(string $storedAs, string $submitted, string $restored): void @@ -52,6 +54,7 @@ public function data(): \Iterator * @param string[] $restored * * @covers \Zikula\Bundle\DynamicFormBundle\Form\DataTransformer\ArrayToStringTransformer::transform + * * @dataProvider dataMultiple */ public function testTransformMultiple(string $storedAs, array $submitted, array $restored): void @@ -65,6 +68,7 @@ public function testTransformMultiple(string $storedAs, array $submitted, array * @param string[] $restored * * @covers \Zikula\Bundle\DynamicFormBundle\Form\DataTransformer\ArrayToStringTransformer::reverseTransform + * * @dataProvider dataMultiple */ public function testReverseTransformMultiple(string $storedAs, array $submitted, array $restored): void diff --git a/tests/Form/DataTransformer/ChoiceValuesTransformerTest.php b/tests/Form/DataTransformer/ChoiceValuesTransformerTest.php index 34dd715..21c4b70 100644 --- a/tests/Form/DataTransformer/ChoiceValuesTransformerTest.php +++ b/tests/Form/DataTransformer/ChoiceValuesTransformerTest.php @@ -22,6 +22,7 @@ class ChoiceValuesTransformerTest extends TestCase * @param array $storedAs * * @covers \Zikula\Bundle\DynamicFormBundle\Form\DataTransformer\ChoiceValuesTransformer::transform + * * @dataProvider data */ public function testTransform(array $storedAs, string $submitted, string $restored): void @@ -34,6 +35,7 @@ public function testTransform(array $storedAs, string $submitted, string $restor * @param array $storedAs * * @covers \Zikula\Bundle\DynamicFormBundle\Form\DataTransformer\ChoiceValuesTransformer::reverseTransform + * * @dataProvider data */ public function testReverseTransform(array $storedAs, string $submitted, string $restored): void diff --git a/tests/Form/DataTransformer/DefaultLabelToLabelsTransformerTest.php b/tests/Form/DataTransformer/DefaultLabelToLabelsTransformerTest.php index 409e605..3210dd1 100644 --- a/tests/Form/DataTransformer/DefaultLabelToLabelsTransformerTest.php +++ b/tests/Form/DataTransformer/DefaultLabelToLabelsTransformerTest.php @@ -22,6 +22,7 @@ class DefaultLabelToLabelsTransformerTest extends TestCase * @param array $storedAs * * @covers \Zikula\Bundle\DynamicFormBundle\Form\DataTransformer\DefaultLabelToLabelsTransformer::transform + * * @dataProvider data */ public function testTransform(array $storedAs, string $submitted, string $restored): void @@ -34,6 +35,7 @@ public function testTransform(array $storedAs, string $submitted, string $restor * @param array $storedAs * * @covers \Zikula\Bundle\DynamicFormBundle\Form\DataTransformer\DefaultLabelToLabelsTransformer::reverseTransform + * * @dataProvider data */ public function testReverseTransform(array $storedAs, string $submitted, string $restored): void diff --git a/tests/Form/DataTransformer/RegexConstraintTransformerTest.php b/tests/Form/DataTransformer/RegexConstraintTransformerTest.php index 6d3709e..95e0619 100644 --- a/tests/Form/DataTransformer/RegexConstraintTransformerTest.php +++ b/tests/Form/DataTransformer/RegexConstraintTransformerTest.php @@ -24,6 +24,7 @@ class RegexConstraintTransformerTest extends TestCase * @param mixed $submitted * * @covers \Zikula\Bundle\DynamicFormBundle\Form\DataTransformer\RegexConstraintTransformer::transform + * * @dataProvider data */ public function testTransform(array $storedAs, $submitted, string $restored): void @@ -37,6 +38,7 @@ public function testTransform(array $storedAs, $submitted, string $restored): vo * @param mixed $submitted * * @covers \Zikula\Bundle\DynamicFormBundle\Form\DataTransformer\RegexConstraintTransformer::reverseTransform + * * @dataProvider data */ public function testReverseTransform(array $storedAs, $submitted, string $restored): void diff --git a/tests/Form/Type/DynamicFieldsTypeTest.php b/tests/Form/Type/DynamicFieldsTypeTest.php index 23f117e..154ca8e 100644 --- a/tests/Form/Type/DynamicFieldsTypeTest.php +++ b/tests/Form/Type/DynamicFieldsTypeTest.php @@ -41,7 +41,7 @@ protected function setUp(): void /** * @param string[] $parameters this is for phpstan */ - public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string + public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string { return $id; } diff --git a/tests/Form/Type/FormSpecificationTypeTest.php b/tests/Form/Type/FormSpecificationTypeTest.php index 3cff5c2..863988e 100644 --- a/tests/Form/Type/FormSpecificationTypeTest.php +++ b/tests/Form/Type/FormSpecificationTypeTest.php @@ -91,6 +91,7 @@ public function testBasicFormSubmission(): void /** * @param string[] $expectedOptions + * * @covers \Zikula\Bundle\DynamicFormBundle\Entity\AbstractFormSpecification * @covers \Zikula\Bundle\DynamicFormBundle\Form\Type\ChoiceTypeTransformed * @covers \Zikula\Bundle\DynamicFormBundle\Form\Type\ChoiceWithOtherType @@ -104,6 +105,7 @@ public function testBasicFormSubmission(): void * @covers \Zikula\Bundle\DynamicFormBundle\Form\Type\DynamicOptions\MoneyFormOptionsArrayType * @covers \Zikula\Bundle\DynamicFormBundle\Form\Type\DynamicOptions\RangeFormOptionsArrayType * @covers \Zikula\Bundle\DynamicFormBundle\Form\Type\DynamicOptions\RegexibleFormOptionsArrayType + * * @dataProvider data */ public function testProperFormCreation(string $type, array $expectedOptions): void diff --git a/tests/Form/Type/FormSpecificationTypeTranslatedTest.php b/tests/Form/Type/FormSpecificationTypeTranslatedTest.php index 8af6154..badbb2f 100644 --- a/tests/Form/Type/FormSpecificationTypeTranslatedTest.php +++ b/tests/Form/Type/FormSpecificationTypeTranslatedTest.php @@ -39,7 +39,7 @@ public function getSupportedLocales(): array return ['en', 'de']; } - public function getSupportedLocaleNames(string $displayLocale = null): array + public function getSupportedLocaleNames(?string $displayLocale = null): array { return ['English' => 'en', 'German' => 'de']; } diff --git a/tests/Form/Type/TranslationCollectionTypeTest.php b/tests/Form/Type/TranslationCollectionTypeTest.php index 3347087..bfd9516 100644 --- a/tests/Form/Type/TranslationCollectionTypeTest.php +++ b/tests/Form/Type/TranslationCollectionTypeTest.php @@ -30,7 +30,7 @@ public function getSupportedLocales(): array return ['en']; } - public function getSupportedLocaleNames(string $displayLocale = null): array + public function getSupportedLocaleNames(?string $displayLocale = null): array { return ['English' => 'en']; }