Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions composer-dependency-analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
if (version_compare(PHP_VERSION, '8.3.0', '>=')) {
$config->ignoreErrorsOnPackage('symfony/polyfill-php83', [ErrorType::UNUSED_DEPENDENCY]);
}
if (version_compare(PHP_VERSION, '8.4.0', '>=')) {
$config->ignoreErrorsOnPackage('symfony/polyfill-php84', [ErrorType::UNUSED_DEPENDENCY]);
}

if (!class_exists(DataProvider::class)) {
$config->ignoreUnknownClasses([DataProvider::class]);
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"symfony/form": "^5.4 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.0 || ^7.0",
"symfony/polyfill-php83": "^1.27",
"symfony/polyfill-php83": "^1.33",
"symfony/polyfill-php84": "^1.33",
"symfony/property-info": "^5.4 || ^6.0 || ^7.0",
"symfony/validator": "^5.4 || ^6.0 || ^7.0",
"webmozart/assert": "^1.10"
"symfony/validator": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.42",
Expand Down
18 changes: 12 additions & 6 deletions src/Form/DataTransformer/CronExpressionToPartsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Cron\CronExpression;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Webmozart\Assert\Assert;

/**
* @template-implements DataTransformerInterface<CronExpression, array<string, array<string>>>
Expand Down Expand Up @@ -69,9 +68,7 @@ public function reverseTransform($value): CronExpression
throw $exception;
}

try {
Assert::allIsArray($value);
} catch (\InvalidArgumentException $e) {
if (!self::allArrayScalar($value)) {
throw $exception;
}

Expand All @@ -90,14 +87,23 @@ public function reverseTransform($value): CronExpression
}
}

/**
* @psalm-assert array<string, array<scalar>> $value
*/
private static function allArrayScalar(array $value): bool
{
return array_all($value, fn (mixed $s) => is_array($s) && array_all($s, fn (mixed $o) => is_scalar($o)));
}

/**
* @param array<scalar> $cronArray
*/
private function convertCronParts(array $cronArray): string
{
if ([] === $cronArray) {
return '*';
}

Assert::allScalar($cronArray);

return implode(',', $cronArray);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Cron\CronExpression;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Webmozart\Assert\Assert;

/**
* @template-implements DataTransformerInterface<CronExpression, array<string,string>>
Expand Down Expand Up @@ -69,9 +68,7 @@ public function reverseTransform($value): CronExpression
throw $exception;
}

try {
Assert::allString($value);
} catch (\InvalidArgumentException $e) {
if (!self::allString($value)) {
throw $exception;
}

Expand All @@ -89,4 +86,12 @@ public function reverseTransform($value): CronExpression

return $cronExpression;
}

/**
* @psalm-assert iterable<string> $value
*/
private static function allString(array $value): bool
{
return array_all($value, fn (mixed $s) => is_string($s));
}
}