diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e613bbe..ddda1ec 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -38,7 +38,7 @@ jobs: - name: "Validate composer" run: "composer validate --strict" - + - name: "Check composer normalized" run: "composer normalize --dry-run" @@ -55,6 +55,7 @@ jobs: php-version: - "8.1" - "8.2" + - "8.3" dependencies: - "highest" @@ -96,10 +97,9 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - "8.1" - "8.2" + - "8.3" dependencies: - "highest" @@ -108,10 +108,6 @@ jobs: - "^5.4" - "^6.0" - exclude: - - php-version: "7.4" - symfony: "^6.0" - steps: - name: "Checkout" uses: "actions/checkout@v3" @@ -142,10 +138,9 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - "8.1" - "8.2" + - "8.3" dependencies: - "lowest" diff --git a/composer.json b/composer.json index 2eb0d8a..b58a451 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "php": ">=7.4", + "php": ">=8.1", "doctrine/dbal": "^3.4 || ^4.0", "doctrine/doctrine-bundle": "^1.9 || ^2.0", "dragonmantank/cron-expression": "^2.2 || ^3.0", @@ -24,12 +24,15 @@ "webmozart/assert": "^1.10" }, "require-dev": { + "ergebnis/composer-normalize": "^2.42", "matthiasnoback/symfony-dependency-injection-test": "^4.3", "phpdocumentor/reflection-docblock": "^5.3", "phpunit/phpunit": "^9.5", - "psalm/plugin-phpunit": "^0.16.1", + "psalm/plugin-phpunit": "^0.19", "roave/security-advisories": "dev-latest", - "setono/code-quality-pack": "^2.1.3" + "sylius-labs/coding-standard": "^4.1.1", + "symplify/easy-coding-standard": "^12.3.6", + "vimeo/psalm": "^5.24" }, "prefer-stable": true, "autoload": { diff --git a/ecs.php b/ecs.php index cd1db6b..d463917 100644 --- a/ecs.php +++ b/ecs.php @@ -3,11 +3,10 @@ declare(strict_types=1); use Symplify\EasyCodingStandard\Config\ECSConfig; -use Symplify\EasyCodingStandard\ValueObject\Option; return static function (ECSConfig $config): void { $config->import('vendor/sylius-labs/coding-standard/ecs.php'); - $config->parameters()->set(Option::PATHS, [ + $config->paths([ 'src', 'tests' ]); }; diff --git a/src/Doctrine/DBAL/Types/CronExpressionType.php b/src/Doctrine/DBAL/Types/CronExpressionType.php index 04458ee..ac15893 100644 --- a/src/Doctrine/DBAL/Types/CronExpressionType.php +++ b/src/Doctrine/DBAL/Types/CronExpressionType.php @@ -22,6 +22,8 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st /** * @param mixed $value + * + * @throws InvalidType|ValueNotConvertible */ public function convertToPHPValue($value, AbstractPlatform $platform): ?CronExpression { @@ -32,12 +34,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?CronExpr if (!is_string($value)) { if (class_exists(InvalidType::class)) { throw InvalidType::new($value, CronExpression::class, ['string']); - } else { - /** - * @psalm-suppress UndefinedMethod - */ - throw ConversionException::conversionFailedInvalidType($value, CronExpression::class, ['string']); } + + /** + * @psalm-suppress UndefinedMethod + */ + throw ConversionException::conversionFailedInvalidType($value, CronExpression::class, ['string']); } if ('' === $value) { @@ -49,12 +51,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?CronExpr } catch (\Throwable $e) { if (class_exists(ValueNotConvertible::class)) { throw ValueNotConvertible::new($value, CronExpression::class, null, $e); - } else { - /** - * @psalm-suppress UndefinedMethod - */ - throw ConversionException::conversionFailed($value, CronExpression::class, $e); } + + /** + * @psalm-suppress UndefinedMethod + */ + throw ConversionException::conversionFailed($value, CronExpression::class, $e); } } diff --git a/src/Form/DataTransformer/CronExpressionToPartsTransformer.php b/src/Form/DataTransformer/CronExpressionToPartsTransformer.php index 546a336..dc0db25 100644 --- a/src/Form/DataTransformer/CronExpressionToPartsTransformer.php +++ b/src/Form/DataTransformer/CronExpressionToPartsTransformer.php @@ -9,10 +9,17 @@ use Symfony\Component\Form\Exception\TransformationFailedException; use Webmozart\Assert\Assert; +/** + * @template-implements DataTransformerInterface>> + * + * @psalm-suppress TooManyTemplateParams + */ final class CronExpressionToPartsTransformer implements DataTransformerInterface { /** * @param mixed $value + * + * @return array> */ public function transform($value): array { @@ -92,6 +99,9 @@ private function convertCronParts(array $cronArray): string return implode(',', $cronArray); } + /** + * @return array + */ private function convertCronString(string $cronString): array { if ('*' === $cronString) { diff --git a/src/Form/DataTransformer/CronExpressionToStringPartsTransformer.php b/src/Form/DataTransformer/CronExpressionToStringPartsTransformer.php index 1e9d7c2..161025a 100644 --- a/src/Form/DataTransformer/CronExpressionToStringPartsTransformer.php +++ b/src/Form/DataTransformer/CronExpressionToStringPartsTransformer.php @@ -9,10 +9,17 @@ use Symfony\Component\Form\Exception\TransformationFailedException; use Webmozart\Assert\Assert; +/** + * @template-implements DataTransformerInterface> + * + * @psalm-suppress TooManyTemplateParams + */ final class CronExpressionToStringPartsTransformer implements DataTransformerInterface { /** * @param mixed $value + * + * @return array */ public function transform($value): array { diff --git a/src/Form/DataTransformer/CronExpressionToStringTransformer.php b/src/Form/DataTransformer/CronExpressionToStringTransformer.php index a5bdbc1..f2ad557 100644 --- a/src/Form/DataTransformer/CronExpressionToStringTransformer.php +++ b/src/Form/DataTransformer/CronExpressionToStringTransformer.php @@ -8,6 +8,11 @@ use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; +/** + * @template-implements DataTransformerInterface + * + * @psalm-suppress TooManyTemplateParams + */ final class CronExpressionToStringTransformer implements DataTransformerInterface { /** diff --git a/src/Form/TypeGuesser/CronExpressionTypeGuesser.php b/src/Form/TypeGuesser/CronExpressionTypeGuesser.php index 558e17c..912ad37 100644 --- a/src/Form/TypeGuesser/CronExpressionTypeGuesser.php +++ b/src/Form/TypeGuesser/CronExpressionTypeGuesser.php @@ -24,6 +24,7 @@ public function __construct(?PropertyTypeExtractorInterface $extractor = null) { $this->extractor = $extractor ?? $this->createExtractor(); } + /** * @param string $class * @param string $property @@ -34,9 +35,8 @@ public function guessType($class, $property): ?TypeGuess return null; } - $types = $this->extractor->getTypes($class, $property); - if (!$types) { + if (null === $types) { return null; } foreach ($types as $type) { @@ -45,6 +45,7 @@ public function guessType($class, $property): ?TypeGuess return new TypeGuess(CronExpressionType::class, [], Guess::VERY_HIGH_CONFIDENCE); } } + return null; } diff --git a/src/Validator/CronExpression.php b/src/Validator/CronExpression.php index 8f4defc..3533ea8 100644 --- a/src/Validator/CronExpression.php +++ b/src/Validator/CronExpression.php @@ -9,6 +9,7 @@ /** * @Annotation + * * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] @@ -17,16 +18,13 @@ class CronExpression extends Constraint public string $message = '{{ value }} is not a valid cron expression.'; /** - * @param string|null $message * @param string[]|null $groups - * @param mixed $payload - * @param array $options */ public function __construct( string $message = null, ?array $groups = null, mixed $payload = null, - array $options = [] + array $options = [], ) { parent::__construct($options, $groups, $payload); diff --git a/tests/Validator/CronExpressionTest.php b/tests/Validator/CronExpressionTest.php index 3fcec75..30075b9 100644 --- a/tests/Validator/CronExpressionTest.php +++ b/tests/Validator/CronExpressionTest.php @@ -13,6 +13,11 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; +/** + * @template-extends ConstraintValidatorTestCase + * + * @psalm-suppress TooManyTemplateParams + */ class CronExpressionTest extends ConstraintValidatorTestCase { protected function createValidator(): CronExpressionValidator diff --git a/tests/Validator/FormCallbackTest.php b/tests/Validator/FormCallbackTest.php index 8c5d9db..9133b24 100644 --- a/tests/Validator/FormCallbackTest.php +++ b/tests/Validator/FormCallbackTest.php @@ -10,6 +10,11 @@ use Symfony\Component\Validator\Constraints\CallbackValidator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; +/** + * @template-extends ConstraintValidatorTestCase + * + * @psalm-suppress TooManyTemplateParams + */ class FormCallbackTest extends ConstraintValidatorTestCase { protected function createValidator(): CallbackValidator