Skip to content

Commit a192cc6

Browse files
kbondGromNaN
authored andcommitted
feat: Symfony 7 support
1 parent ddf39bb commit a192cc6

File tree

5 files changed

+31
-32
lines changed

5 files changed

+31
-32
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
symfony-version:
3131
- "5.4.*"
3232
- "6.4.*"
33+
- "7.0.x"
3334
driver-version:
3435
- "stable"
3536
dependencies:
@@ -41,6 +42,9 @@ jobs:
4142
driver-version: "1.5.0"
4243
stability: "stable"
4344
symfony-version: "5.4.*"
45+
exclude:
46+
- php-version: "8.1"
47+
symfony-version: "7.0.x"
4448

4549
services:
4650
mongodb:

Form/DoctrineMongoDBExtension.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ public function __construct(ManagerRegistry $registry)
2323
}
2424

2525
/** @return FormTypeInterface[] */
26-
protected function loadTypes()
26+
protected function loadTypes(): array
2727
{
2828
return [
2929
new Type\DocumentType($this->registry),
3030
];
3131
}
3232

33-
/** @return FormTypeGuesserInterface|null */
34-
protected function loadTypeGuesser()
33+
protected function loadTypeGuesser(): ?FormTypeGuesserInterface
3534
{
3635
return new DoctrineMongoDBTypeGuesser($this->registry);
3736
}

Form/DoctrineMongoDBTypeGuesser.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public function __construct(ManagerRegistry $registry)
3838
$this->registry = $registry;
3939
}
4040

41-
/** @return TypeGuess|null */
42-
public function guessType(string $class, string $property)
41+
public function guessType(string $class, string $property): ?TypeGuess
4342
{
4443
$ret = $this->getMetadata($class);
4544
if (! $ret) {
@@ -114,10 +113,11 @@ public function guessType(string $class, string $property)
114113
Guess::MEDIUM_CONFIDENCE,
115114
);
116115
}
116+
117+
return null;
117118
}
118119

119-
/** @return ValueGuess|null */
120-
public function guessRequired(string $class, string $property)
120+
public function guessRequired(string $class, string $property): ?ValueGuess
121121
{
122122
$ret = $this->getMetadata($class);
123123
if ($ret && $ret[0]->hasField($property)) {
@@ -137,8 +137,7 @@ public function guessRequired(string $class, string $property)
137137
return null;
138138
}
139139

140-
/** @return ValueGuess|null */
141-
public function guessMaxLength(string $class, string $property)
140+
public function guessMaxLength(string $class, string $property): ?ValueGuess
142141
{
143142
return null;
144143
}
@@ -150,8 +149,7 @@ public function guessMinLength($class, $property): void
150149
{
151150
}
152151

153-
/** @return ValueGuess|null */
154-
public function guessPattern(string $class, string $property)
152+
public function guessPattern(string $class, string $property): ?ValueGuess
155153
{
156154
$ret = $this->getMetadata($class);
157155
if (! $ret || ! $ret[0]->hasField($property) || $ret[0]->hasAssociation($property)) {

Tests/Validator/Constraints/UniqueTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,25 @@
77
use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique;
88
use PHPUnit\Framework\TestCase;
99
use Symfony\Component\Validator\Mapping\ClassMetadata;
10-
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
11-
12-
use function assert;
10+
use Symfony\Component\Validator\Mapping\Loader\AttributeLoader;
1311

1412
final class UniqueTest extends TestCase
1513
{
1614
public function testWithDefaultProperty(): void
1715
{
1816
$metadata = new ClassMetadata(UniqueDocumentDummyOne::class);
1917

20-
$loader = new AnnotationLoader();
18+
$loader = new AttributeLoader();
2119

2220
self::assertTrue($loader->loadClassMetadata($metadata));
2321

2422
[$constraint] = $metadata->getConstraints();
25-
assert($constraint instanceof Unique);
23+
self::assertInstanceOf(Unique::class, $constraint);
2624
self::assertSame(['email'], $constraint->fields);
2725
self::assertSame('doctrine_odm.mongodb.unique', $constraint->validatedBy());
2826
}
2927
}
3028

31-
/** @Unique(fields={"email"}) */
3229
#[Unique(['email'])]
3330
class UniqueDocumentDummyOne
3431
{

composer.json

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@
3030
"doctrine/persistence": "^2.2 || ^3.0",
3131
"jean85/pretty-package-versions": "^1.3.0 || ^2.0.1",
3232
"psr/log": "^1.0 || ^2.0 || ^3.0",
33-
"symfony/config": "^5.4 || ^6.2",
34-
"symfony/console": "^5.4 || ^6.2",
35-
"symfony/dependency-injection": "^5.4 || ^6.2",
33+
"symfony/config": "^5.4 || ^6.2 || ^7.0",
34+
"symfony/console": "^5.4 || ^6.2 || ^7.0",
35+
"symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0",
3636
"symfony/deprecation-contracts": "^2.1 || ^3.0",
37-
"symfony/doctrine-bridge": "^5.4.19 || ^6.2",
38-
"symfony/framework-bundle": "^5.4 || ^6.2",
39-
"symfony/http-kernel": "^5.4 || ^6.2",
40-
"symfony/options-resolver": "^5.4 || ^6.2"
37+
"symfony/doctrine-bridge": "^5.4.19 || ^6.2 || ^7.0",
38+
"symfony/framework-bundle": "^5.4 || ^6.2 || ^7.0",
39+
"symfony/http-kernel": "^5.4 || ^6.2 || ^7.0",
40+
"symfony/options-resolver": "^5.4 || ^6.2 || ^7.0"
4141
},
4242
"require-dev": {
4343
"doctrine/coding-standard": "^11.0",
4444
"doctrine/data-fixtures": "^1.3",
4545
"phpunit/phpunit": "^9.5.5",
4646
"psalm/plugin-symfony": "^5.0",
47-
"symfony/browser-kit": "^5.4 || ^6.2",
48-
"symfony/form": "^5.4 || ^6.2",
49-
"symfony/phpunit-bridge": "^6.2",
50-
"symfony/security-bundle": "^5.4 || ^6.2",
51-
"symfony/stopwatch": "^5.4 || ^6.2",
52-
"symfony/validator": "^5.4 || ^6.2",
53-
"symfony/yaml": "^5.4 || ^6.2",
47+
"symfony/browser-kit": "^5.4 || ^6.2 || ^7.0",
48+
"symfony/form": "^5.4 || ^6.2 || ^7.0",
49+
"symfony/phpunit-bridge": "^6.2 || ^7.0",
50+
"symfony/security-bundle": "^5.4 || ^6.2 || ^7.0",
51+
"symfony/stopwatch": "^5.4 || ^6.2 || ^7.0",
52+
"symfony/validator": "^5.4 || ^6.2 || ^7.0",
53+
"symfony/yaml": "^5.4 || ^6.2 || ^7.0",
5454
"vimeo/psalm": "^5.12"
5555
},
5656
"conflict": {
@@ -59,7 +59,8 @@
5959
"suggest": {
6060
"doctrine/data-fixtures": "Load data fixtures"
6161
},
62-
"minimum-stability": "stable",
62+
"minimum-stability": "dev",
63+
"prefer-stable": true,
6364
"autoload": {
6465
"psr-4": {
6566
"Doctrine\\Bundle\\MongoDBBundle\\": ""

0 commit comments

Comments
 (0)