Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
jiripudil committed Dec 30, 2023
1 parent 1039f15 commit 4864779
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 35 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

strategy:
matrix:
php-version: [ "8.0" ]
php-version: [ "8.3" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false

Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:

strategy:
matrix:
php-version: [ "8.0" ]
php-version: [ "8.3" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false

Expand Down Expand Up @@ -138,11 +138,11 @@ jobs:

strategy:
matrix:
php-version: [ "7.4", "8.0", "8.1" ]
php-version: [ "8.1", "8.2", "8.3" ]
operating-system: [ "ubuntu-latest" ]
composer-args: [ "" ]
include:
- php-version: "7.4"
- php-version: "8.1"
operating-system: "ubuntu-latest"
composer-args: "--prefer-lowest"
fail-fast: false
Expand Down Expand Up @@ -206,7 +206,7 @@ jobs:

strategy:
matrix:
php-version: [ "8.0" ]
php-version: [ "8.3" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ For details on how to use this package, check out our [documentation](.docs).

| State | Version | Branch | Nette | PHP |
|-------------|--------------|----------|----------|----------|
| stable | `^1.0` | `master` | `3.0+` | `>= 7.2` |
| development | `dev-master` | `master` | `3.0+` | `>= 7.2` |
| stable | `^2.0` | `master` | `3.0+` | `>= 8.1` |
| development | `dev-master` | `master` | `3.0+` | `>= 8.1` |


## Development
Expand Down
17 changes: 8 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@
}
],
"require": {
"php": ">=7.4",
"php": ">=8.1",
"nette/di": "^3.0.1",
"symfony/cache": "^5.0 || ^6.0",
"symfony/config": "^5.0 || ^6.0",
"symfony/validator": "^5.2 || ^6.0"
"symfony/cache": "^6.0 || ^7.0",
"symfony/config": "^6.0 || ^7.0",
"symfony/validator": "^6.4 || ^7.0"
},
"require-dev": {
"doctrine/annotations": "^1.8",
"doctrine/cache": "^1.10",
"doctrine/cache": "^2.2",
"nette/bootstrap": "^3.0",
"nette/tester": "^2.4",
"ninjify/nunjuck": "^0.3.0",
"ninjify/qa": "^0.12",
"ninjify/nunjuck": "^0.4.0",
"ninjify/qa": "^0.13.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-nette": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"symfony/translation": "^5.0"
"symfony/translation": "^7.0"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 3 additions & 4 deletions src/ContainerConstraintValidatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
final class ContainerConstraintValidatorFactory implements ConstraintValidatorFactoryInterface
{

private Container $container;

/** @var ConstraintValidatorInterface[] */
private array $validators;

public function __construct(Container $container)
public function __construct(
private readonly Container $container,
)
{
$this->container = $container;
$this->validators = [];
}

Expand Down
14 changes: 3 additions & 11 deletions src/DI/ValidatorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Contributte\Validator\DI;

use Contributte\Validator\ContainerConstraintValidatorFactory;
use Doctrine\Common\Annotations\Reader;
use Nette\DI\CompilerExtension;
use Nette\DI\Definitions\ServiceDefinition;
use Nette\DI\Definitions\Statement;
Expand All @@ -16,7 +15,6 @@
use Symfony\Component\Validator\ValidatorBuilder;
use Symfony\Contracts\Translation\TranslatorInterface;
use function assert;
use function interface_exists;
use function is_string;

/**
Expand All @@ -29,7 +27,7 @@ public function getConfigSchema(): Schema
{
return Expect::structure([
'mapping' => Expect::structure([
'annotations' => Expect::bool(interface_exists(Reader::class)),
'attributes' => Expect::bool(true),
'xml' => Expect::listOf(Expect::string()->dynamic()),
'yaml' => Expect::listOf(Expect::string()->dynamic()),
'methods' => Expect::listOf(Expect::string()->dynamic()),
Expand Down Expand Up @@ -77,14 +75,8 @@ public function beforeCompile(): void

private function setupMapping(ServiceDefinition $validatorBuilder): void
{
$validatorBuilder->addSetup('enableAnnotationMapping', [true]);

if ($this->config->mapping->annotations) {
if ((bool) $this->getContainerBuilder()->findByType(Reader::class)) {
$validatorBuilder->addSetup('setDoctrineAnnotationReader');
} else {
$validatorBuilder->addSetup('addDefaultDoctrineAnnotationReader');
}
if ($this->config->mapping->attributes) {
$validatorBuilder->addSetup('enableAttributeMapping');
}

$validatorBuilder->addSetup('addXmlMappings', [$this->config->mapping->xml]);
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/ValidatorExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ public function testCreateValidator(): void
Assert::type(ValidatorInterface::class, $validator);
}

public function testAnnotationMapping(): void
public function testAttributesMapping(): void
{
$container = $this->createContainer([
'mapping' => [
'annotations' => true,
'attributes' => true,
],
], __METHOD__);

$this->assertValidatorBuilderProperty($container, 'annotationReader', static function ($value): void {
Assert::type(Reader::class, $value);
$this->assertValidatorBuilderProperty($container, 'enableAttributeMapping', static function ($value): void {
Assert::true($value);
});
}

Expand Down

0 comments on commit 4864779

Please sign in to comment.