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
1 change: 1 addition & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ jobs:
uses: "nucleos/actions/.github/workflows/continuous-integration.yml@main"
with:
PHP_EXTENSIONS: ""
SYMFONY_VERSIONS: "7.4,8.0"
secrets:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@
"php": "^8.1",
"ext-json": "*",
"ext-pcre": "*",
"symfony/form": "^6.4 || ^7.0",
"symfony/http-foundation": "^6.4 || ^7.0",
"symfony/options-resolver": "^6.4 || ^7.0",
"symfony/property-access": "^6.4 || ^7.0",
"symfony/translation": "^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.0"
"symfony/form": "^7.4 || ^8.0",
"symfony/http-foundation": "^7.4 || ^8.0",
"symfony/options-resolver": "^7.4 || ^8.0",
"symfony/property-access": "^7.4 || ^8.0",
"symfony/translation": "^7.4 || ^8.0",
"symfony/validator": "^7.4 || ^8.0"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.18 || ^3.0",
"doctrine/orm": "^2.5 || ^3.0",
"doctrine/persistence": "^3.0 || ^4.0",
"ergebnis/composer-normalize": "^2.0.1",
"symfony/browser-kit": "^6.4 || ^7.0",
"symfony/config": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/expression-language": "^6.4 || ^7.0",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0",
"symfony/twig-bridge": "^6.4 || ^7.0",
"symfony/browser-kit": "^7.4 || ^8.0",
"symfony/config": "^7.4 || ^8.0",
"symfony/dependency-injection": "^7.4 || ^8.0",
"symfony/expression-language": "^7.4 || ^8.0",
"symfony/framework-bundle": "^7.4 || ^8.0",
"symfony/http-kernel": "^7.4 || ^8.0",
"symfony/twig-bridge": "^7.4 || ^8.0",
"twig/intl-extra": "^2.4 || ^3.0"
},
"conflict": {
Expand Down
2 changes: 2 additions & 0 deletions src/Type/TimePickerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ static function ($c) {
$dpKey
);

\assert(null !== $dpKey);

$dpOptions[$dpKey] = $value;
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/Validator/Constraints/BatchTimeAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Attribute;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\InvalidOptionsException;
use Symfony\Component\Validator\Exception\MissingOptionsException;

/**
* @Annotation
Expand Down Expand Up @@ -48,6 +49,8 @@ final class BatchTimeAfter extends Constraint
public $required = true;

/**
* @SuppressWarnings("PHPMD.NPathComplexity")
*
* @param array<string, mixed> $options
*/
public function __construct(
Expand Down Expand Up @@ -75,6 +78,18 @@ public function __construct(
$this->emptyMessage = $emptyMessage ?? $this->emptyMessage;
$this->required = $required ?? $this->required;

if (null === $this->firstField) {
throw new MissingOptionsException('The options "firstField" must be set for constraint "'.__CLASS__.'".', [
'firstField',
]);
}

if (null === $this->secondField) {
throw new MissingOptionsException('The options "secondField" must be set for constraint "'.__CLASS__.'".', [
'secondField',
]);
}

if ($this->firstField === $this->secondField) {
throw new InvalidOptionsException('The options "firstField" and "secondField" can not be the same for constraint '.__CLASS__, [
'firstField',
Expand All @@ -83,6 +98,9 @@ public function __construct(
}
}

/**
* @return string[]
*/
public function getRequiredOptions(): array
{
return [
Expand Down
18 changes: 18 additions & 0 deletions src/Validator/Constraints/DateAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Attribute;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\InvalidOptionsException;
use Symfony\Component\Validator\Exception\MissingOptionsException;

/**
* @Annotation
Expand Down Expand Up @@ -48,6 +49,8 @@ final class DateAfter extends Constraint
public $required = true;

/**
* @SuppressWarnings("PHPMD.NPathComplexity")
*
* @param array<string, mixed> $options
*/
public function __construct(
Expand Down Expand Up @@ -75,6 +78,18 @@ public function __construct(
$this->emptyMessage = $emptyMessage ?? $this->emptyMessage;
$this->required = $required ?? $this->required;

if (null === $this->firstField) {
throw new MissingOptionsException('The options "firstField" must be set for constraint "'.__CLASS__.'".', [
'firstField',
]);
}

if (null === $this->secondField) {
throw new MissingOptionsException('The options "secondField" must be set for constraint "'.__CLASS__.'".', [
'secondField',
]);
}

if ($this->firstField === $this->secondField) {
throw new InvalidOptionsException('The options "firstField" and "secondField" can not be the same for constraint '.__CLASS__, [
'firstField',
Expand All @@ -83,6 +98,9 @@ public function __construct(
}
}

/**
* @return string[]
*/
public function getRequiredOptions(): array
{
return [
Expand Down
36 changes: 18 additions & 18 deletions tests/Validator/Constraints/BatchTimeAfterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,49 @@ public function testItIsNotInstantiableWithMissingFirstField(): void
$this->expectException(MissingOptionsException::class);
$this->expectExceptionMessageMatches(\sprintf('#^%s#', preg_quote('The options "firstField" must be set for constraint', '#')));

new BatchTimeAfter([
'secondField' => 'first',
]);
new BatchTimeAfter(
secondField : 'first',
);
}

public function testItIsNotInstantiableWithMissingSecondField(): void
{
$this->expectException(MissingOptionsException::class);
$this->expectExceptionMessageMatches(\sprintf('#^%s#', preg_quote('The options "secondField" must be set for constraint', '#')));

new BatchTimeAfter([
'firstField' => 'first',
]);
new BatchTimeAfter(
firstField : 'first',
);
}

public function testItIsNotInstantiableWithSameField(): void
{
$this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The options "firstField" and "secondField" can not be the same for constraint '.BatchTimeAfter::class);

new BatchTimeAfter([
'firstField' => 'first',
'secondField' => 'first',
]);
new BatchTimeAfter(
firstField : 'first',
secondField : 'first',
);
}

public function testItIsInstantiable(): void
{
$dateAfter = new BatchTimeAfter([
'firstField' => 'first',
'secondField' => 'second',
]);
$dateAfter = new BatchTimeAfter(
firstField : 'first',
secondField : 'second',
);

self::assertSame('first', $dateAfter->firstField);
self::assertSame('second', $dateAfter->secondField);
}

public function testGetTarget(): void
{
$dateAfter = new BatchTimeAfter([
'firstField' => 'first',
'secondField' => 'second',
]);
$dateAfter = new BatchTimeAfter(
firstField : 'first',
secondField : 'second',
);

self::assertSame('class', $dateAfter->getTargets());
}
Expand Down
Loading
Loading