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: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"require-dev": {
"symfony/contracts": "^2.4",
"symfony/translation": "^4.2|^5.0",
"assoconnect/php-quality-config": "^1.0"
"assoconnect/php-quality-config": "^1.0",
"assoconnect/validator-bundle": "^2.19"
},
"require": {
"ext-intl": "*",
Expand Down
23 changes: 23 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.

AssoConnect\PHPDate\LocalizedStringParser:
class: AssoConnect\PHPDate\LocalizedStringParser

AssoConnect\PHPDateBundle\Normalizer\AbsoluteDateNormalizer:
tags:
- 'serializer.normalizer'

AssoConnect\PHPDateBundle\Twig\Extension\AbsoluteDateExtension:
arguments:
- '@translator'
tags:
- 'twig.extension'

AssoConnect\PHPDateBundle\Validator\:
resource: "../src/Validator/*"
6 changes: 6 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
ignoreErrors:
-
message: "#^Method AssoConnect\\\\PHPDateBundle\\\\Translatable\\\\AbsoluteDateTranslatable\\:\\:trans\\(\\) should return string but returns string\\|true\\.$#"
count: 1
path: src/Translatable/AbsoluteDateTranslatable.php
6 changes: 6 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ parameters:
paths:
- src/
- tests/
exceptions:
uncheckedExceptionClasses:
- 'Symfony\Component\Validator\Exception\ConstraintDefinitionException'
- 'Symfony\Component\Validator\Exception\InvalidOptionsException'
- 'Symfony\Component\Validator\Exception\MissingOptionsException'

includes:
- vendor/assoconnect/php-quality-config/phpstan.extension.neon
- phpstan-baseline.neon
2 changes: 1 addition & 1 deletion src/DependencyInjection/PHPDateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function load(array $configs, ContainerBuilder $container): void
// Loading config.yml file
$loader = new YamlFileLoader(
$container,
new FileLocator(__DIR__ . '/../Resources/config')
new FileLocator(__DIR__ . '/../../config')
);
$loader->load('services.yaml');
}
Expand Down
13 changes: 0 additions & 13 deletions src/Resources/config/services.yaml

This file was deleted.

25 changes: 25 additions & 0 deletions src/Validator/ConstraintsSetFactory/Field/AbsoluteDateProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace AssoConnect\PHPDateBundle\Validator\ConstraintsSetFactory\Field;

use AssoConnect\PHPDate\AbsoluteDate;
use AssoConnect\PHPDateBundle\Doctrine\DBAL\Types\AbsoluteDateType;
use AssoConnect\ValidatorBundle\Validator\ConstraintsSetProvider\Field\FieldConstraintsSetProviderInterface;
use Symfony\Component\Validator\Constraints\Type;

class AbsoluteDateProvider implements FieldConstraintsSetProviderInterface
{
public function supports(string $type): bool
{
return AbsoluteDateType::NAME === $type;
}

public function getConstraints(array $fieldMapping): array
{
return [
new Type(AbsoluteDate::class),
];
}
}
25 changes: 25 additions & 0 deletions src/Validator/ConstraintsSetFactory/Field/DateTimeZoneProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace AssoConnect\PHPDateBundle\Validator\ConstraintsSetFactory\Field;

use AssoConnect\PHPDateBundle\Doctrine\DBAL\Types\DateTimeZoneType;
use AssoConnect\ValidatorBundle\Validator\ConstraintsSetProvider\Field\FieldConstraintsSetProviderInterface;
use DateTimeZone;
use Symfony\Component\Validator\Constraints\Type;

class DateTimeZoneProvider implements FieldConstraintsSetProviderInterface
{
public function supports(string $type): bool
{
return DateTimeZoneType::NAME === $type;
}

public function getConstraints(array $fieldMapping): array
{
return [
new Type(DateTimeZone::class),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace AssoConnect\PHPDateBundle\Tests\Validator\ConstraintsSetFactory\Field;

use AssoConnect\PHPDate\AbsoluteDate;
use AssoConnect\PHPDateBundle\Doctrine\DBAL\Types\AbsoluteDateType;
use AssoConnect\PHPDateBundle\Validator\ConstraintsSetFactory\Field\AbsoluteDateProvider;
use AssoConnect\ValidatorBundle\Test\FieldConstraintsSetProviderTestCase;
use AssoConnect\ValidatorBundle\Validator\ConstraintsSetProvider\Field\FieldConstraintsSetProviderInterface;
use Symfony\Component\Validator\Constraints\Type;

class AbsoluteDateProviderTest extends FieldConstraintsSetProviderTestCase
{
protected function getFactory(): FieldConstraintsSetProviderInterface
{
return new AbsoluteDateProvider();
}

public function getConstraintsForTypeProvider(): iterable
{
yield [
['type' => AbsoluteDateType::NAME],
[new Type(AbsoluteDate::class)],
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace AssoConnect\PHPDateBundle\Tests\Validator\ConstraintsSetFactory\Field;

use AssoConnect\PHPDateBundle\Doctrine\DBAL\Types\DateTimeZoneType;
use AssoConnect\PHPDateBundle\Validator\ConstraintsSetFactory\Field\DateTimeZoneProvider;
use AssoConnect\ValidatorBundle\Test\FieldConstraintsSetProviderTestCase;
use AssoConnect\ValidatorBundle\Validator\ConstraintsSetProvider\Field\FieldConstraintsSetProviderInterface;
use DateTimeZone;
use Symfony\Component\Validator\Constraints\Type;

class DateTimeZoneProviderTest extends FieldConstraintsSetProviderTestCase
{
protected function getFactory(): FieldConstraintsSetProviderInterface
{
return new DateTimeZoneProvider();
}

public function getConstraintsForTypeProvider(): iterable
{
yield [
['type' => DateTimeZoneType::NAME],
[new Type(DateTimeZone::class)],
];
}
}