Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: drop support for PHP < 8.1 #52

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a0deca4
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
8401042
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
2df56ac
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
bad0002
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
b491014
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
445d042
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
7da9a15
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
e8c8d19
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
7db59e4
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
6648478
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
65aa009
feat: drop support PHP < 8.1
Chris8934 Oct 23, 2024
bf99626
Update CronExpressionToPartsTransformer.php
Hanmac Oct 23, 2024
505bcf5
Update CronExpressionToStringPartsTransformer.php
Hanmac Oct 23, 2024
b49b553
Update CronExpressionToPartsTransformer.php
Hanmac Oct 23, 2024
33b2d99
Update CronExpressionTypeGuesser.php
Hanmac Oct 23, 2024
1b9098b
Update CronExpressionToPartsTransformer.php
Hanmac Oct 23, 2024
21b8b81
Update CronExpressionToStringPartsTransformer.php
Hanmac Oct 23, 2024
760bff0
Update CronExpressionToPartsTransformer.php
Hanmac Oct 23, 2024
663956b
Update CronExpressionToPartsTransformer.php
Hanmac Oct 23, 2024
c24f250
Update CronExpressionToPartsTransformer.php
Hanmac Oct 23, 2024
bb88180
Update CronExpressionToStringPartsTransformer.php
Hanmac Oct 23, 2024
dcf611e
Update CronExpressionTest.php
Hanmac Oct 23, 2024
4dfb85c
Update FormCallbackTest.php
Hanmac Oct 23, 2024
46c64e5
Update CronExpressionToStringTransformer.php
Hanmac Oct 23, 2024
7971c3a
Update CronExpressionToPartsTransformer.php
Hanmac Oct 23, 2024
376c9af
Update CronExpressionToStringPartsTransformer.php
Hanmac Oct 23, 2024
9af297e
Update CronExpressionToStringTransformer.php
Hanmac Oct 23, 2024
56c1977
Update CronExpressionTest.php
Hanmac Oct 23, 2024
ae3ab3f
Update FormCallbackTest.php
Hanmac Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: "Validate composer"
run: "composer validate --strict"

- name: "Check composer normalized"
run: "composer normalize --dry-run"

Expand All @@ -55,6 +55,7 @@ jobs:
php-version:
- "8.1"
- "8.2"
- "8.3"

dependencies:
- "highest"
Expand Down Expand Up @@ -96,10 +97,9 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"

dependencies:
- "highest"
Expand All @@ -108,10 +108,6 @@ jobs:
- "^5.4"
- "^6.0"

exclude:
- php-version: "7.4"
symfony: "^6.0"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
Expand Down Expand Up @@ -142,10 +138,9 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"

dependencies:
- "lowest"
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
3 changes: 1 addition & 2 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]);
};
22 changes: 12 additions & 10 deletions src/Doctrine/DBAL/Types/CronExpressionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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) {
Expand All @@ -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);
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/Form/DataTransformer/CronExpressionToPartsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
use Symfony\Component\Form\Exception\TransformationFailedException;
use Webmozart\Assert\Assert;

/**
* @template-implements DataTransformerInterface<CronExpression, array<string, array<string>>>
*
* @psalm-suppress TooManyTemplateParams
*/
final class CronExpressionToPartsTransformer implements DataTransformerInterface
{
/**
* @param mixed $value
*
* @return array<string, array<string>>
*/
public function transform($value): array
{
Expand Down Expand Up @@ -92,6 +99,9 @@ private function convertCronParts(array $cronArray): string
return implode(',', $cronArray);
}

/**
* @return array<string>
*/
private function convertCronString(string $cronString): array
{
if ('*' === $cronString) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
use Symfony\Component\Form\Exception\TransformationFailedException;
use Webmozart\Assert\Assert;

/**
* @template-implements DataTransformerInterface<CronExpression, array<string,string>>
*
* @psalm-suppress TooManyTemplateParams
*/
final class CronExpressionToStringPartsTransformer implements DataTransformerInterface
{
/**
* @param mixed $value
*
* @return array<string,string>
*/
public function transform($value): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;

/**
* @template-implements DataTransformerInterface<CronExpression, string>
*
* @psalm-suppress TooManyTemplateParams
*/
final class CronExpressionToStringTransformer implements DataTransformerInterface
{
/**
Expand Down
5 changes: 3 additions & 2 deletions src/Form/TypeGuesser/CronExpressionTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __construct(?PropertyTypeExtractorInterface $extractor = null)
{
$this->extractor = $extractor ?? $this->createExtractor();
}

/**
* @param string $class
* @param string $property
Expand All @@ -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) {
Expand All @@ -45,6 +45,7 @@ public function guessType($class, $property): ?TypeGuess
return new TypeGuess(CronExpressionType::class, [], Guess::VERY_HIGH_CONFIDENCE);
}
}

return null;
}

Expand Down
6 changes: 2 additions & 4 deletions src/Validator/CronExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* @Annotation
*
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*/
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
Expand All @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions tests/Validator/CronExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

/**
* @template-extends ConstraintValidatorTestCase<CronExpressionValidator>
*
* @psalm-suppress TooManyTemplateParams
*/
class CronExpressionTest extends ConstraintValidatorTestCase
{
protected function createValidator(): CronExpressionValidator
Expand Down
5 changes: 5 additions & 0 deletions tests/Validator/FormCallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
use Symfony\Component\Validator\Constraints\CallbackValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

/**
* @template-extends ConstraintValidatorTestCase<CallbackValidator>
*
* @psalm-suppress TooManyTemplateParams
*/
class FormCallbackTest extends ConstraintValidatorTestCase
{
protected function createValidator(): CallbackValidator
Expand Down
Loading