8000 Merge branch '4.4' into 5.0 · symfony/symfony@08a233b · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 08a233b

Browse files
Merge branch '4.4' into 5.0
* 4.4: (25 commits) [DoctrineBridge] Use new Types::* constants and support new json type [Debug][ErrorHandler] improved deprecation notices for methods new args and return type [BrowserKit] Nested file array prevents uploading file [ExpressionLanguage] Fixed collisions of character operators with object properties [Validator] Remove specific check for Valid targets [PhpUnitBridge] Use trait instead of extending deprecated class Fix versioned namespace clears fix remember me Use strict assertion in asset tests [DoctrineBridge][DoctrineExtractor] Fix indexBy with custom and some core types Do not rely on the current locale when dumping a Graphviz object fix typo [Ldap] force default network timeout [Config] don't throw on missing excluded paths Docs: Typo, grammar [Validator] Add the missing translations for the Polish ("pl") locale [PhpUnitBridge] Add compatibility to PHPUnit 9 #35662 [Routing] Add locale requirement for localized routes [Console] Inline exact-match handling with 4.4 Set previous exception when rethrown from controller resolver ...
2 parents d29865e + 1024f5f commit 08a233b

File tree

57 files changed

+576
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+576
-127
lines changed

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,5 @@ public function reset()
277277
$this->choiceLoaders = [];
278278
}
279279
}
280+
281+
interface_exists(ObjectManager::class);

src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,5 @@ private function parameterToArray(Parameter $parameter): array
9696
return [$parameter->getName(), $parameter->getType(), $parameter->getValue()];
9797
}
9898
}
99+
100+
interface_exists(ObjectManager::class);

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ public function getTypes(string $class, string $property, array $context = [])
103103
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
104104
}
105105

106-
$collectionKeyType = $this->getPhpType($typeOfField);
106+
if (!$collectionKeyType = $this->getPhpType($typeOfField)) {
107+
return null;
108+
}
107109
}
108110
}
109111

@@ -123,39 +125,46 @@ public function getTypes(string $class, string $property, array $context = [])
123125

124126
if ($metadata->hasField($property)) {
125127
$typeOfField = $metadata->getTypeOfField($property);
126-
$nullable = $metadata instanceof ClassMetadataInfo && $metadata->isNullable($property);
127-
128-
switch ($typeOfField) {
129-
case DBALType::DATE:
130-
case DBALType::DATETIME:
131-
case DBALType::DATETIMETZ:
132-
case 'vardatetime':
133-
case DBALType::TIME:
134-
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime')];
135128

136-
case 'date_immutable':
137-
case 'datetime_immutable':
138-
case 'datetimetz_immutable':
139-
case 'time_immutable':
140-
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable')];
141-
142-
case 'dateinterval':
143-
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval')];
144-
145-
case DBALType::TARRAY:
146-
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)];
129+
if (!$builtinType = $this->getPhpType($typeOfField)) {
130+
return null;
131+
}
147132

148-
case DBALType::SIMPLE_ARRAY:
149-
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))];
133+
$nullable = $metadata instanceof ClassMetadataInfo && $metadata->isNullable($property);
150134

151-
case DBALType::JSON_ARRAY:
152-
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)];
135+
switch ($builtinType) {
136+
case Type::BUILTIN_TYPE_OBJECT:
137+
switch ($typeOfField) {
138+
case DBALType::DATE:
139+
case DBALType::DATETIME:
140+
case DBALType::DATETIMETZ:
141+
case 'vardatetime':
142+
case DBALType::TIME:
143+
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime')];
144+
145+
case 'date_immutable':
146+
case 'datetime_immutable':
147+
case 'datetimetz_immutable':
148+
case 'time_immutable':
149+
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable')];
150+
151+
case 'dateinterval':
152+
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval')];
153+
}
153154

154-
default:
155-
$builtinType = $this->getPhpType($typeOfField);
155+
break;
156+
case Type::BUILTIN_TYPE_ARRAY:
157+
switch ($typeOfField) {
158+
case DBALType::TARRAY:
159+
case DBALType::JSON_ARRAY:
160+
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)];
156161

157-
return $builtinType ? [new Type($builtinType, $nullable)] : null;
162+
case DBALType::SIMPLE_ARRAY:
163+
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))];
164+
}
158165
}
166+
167+
return [new Type($builtinType, $nullable)];
159168
}
160169

161170
return null;
@@ -247,7 +256,22 @@ private function getPhpType(string $doctrineType): ?string
247256
return Type::BUILTIN_TYPE_RESOURCE;
248257

249258
case DBALType::OBJECT:
259+
case DBALType::DATE:
260+
case DBALType::DATETIME:
261+
case DBALType::DATETIMETZ:
262+
case 'vardatetime':
263+
case DBALType::TIME:
264+
case 'date_immutable':
265+
case 'datetime_immutable':
266+
case 'datetimetz_immutable':
267+
case 'time_immutable':
268+
case 'dateinterval':
250269
return Type::BUILTIN_TYPE_OBJECT;
270+
271+
case DBALType::TARRAY:
272+
case DBALType::SIMPLE_ARRAY:
273+
case DBALType::JSON_ARRAY:
274+
return Type::BUILTIN_TYPE_ARRAY;
251275
}
252276

253277
return null;

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,6 @@ private function getClassMetadata(): ClassMetadata
153153
return $this->getObjectManager()->getClassMetadata($this->classOrAlias);
154154
}
155155
}
156+
157+
interface_exists(ObjectManager::class);
158+
interface_exists(ObjectRepository::class);

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo;
1313

14+
use Doctrine\Common\Collections\Collection;
1415
use Doctrine\DBAL\Types\Type as DBALType;
1516
use Doctrine\ORM\EntityManager;
1617
use Doctrine\ORM\Tools\Setup;
1718
use PHPUnit\Framework\TestCase;
1819
use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor;
1920
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineGeneratedValue;
21+
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation;
2022
use Symfony\Component\PropertyInfo\Type;
2123

2224
/**
@@ -58,6 +60,8 @@ public function testGetProperties()
5860
'bar',
5961
'indexedBar',
6062
'indexedFoo',
63+
'indexedByDt',
64+
'indexedByCustomType',
6165
],
6266
$this->createExtractor()->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy')
6367
);
@@ -149,6 +153,15 @@ public function typesProvider()
149153
['simpleArray', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))]],
150154
['customFoo', null],
151155
['notMapped', null],
156+
['indexedByDt', [new Type(
157+
Type::BUILTIN_TYPE_OBJECT,
158+
false,
159+
Collection::class,
160+
true,
161+
new Type(Type::BUILTIN_TYPE_OBJECT),
162+
new Type(Type::BUILTIN_TYPE_OBJECT, false, DoctrineRelation::class)
163+
)]],
164+
['indexedByCustomType', null],
152165
];
153166
}
154167

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,14 @@ class DoctrineDummy
112112
private $bigint;
113113

114114
public $notMapped;
115+
116+
/**
117+
* @OneToMany(targetEntity="DoctrineRelation", mappedBy="dt", indexBy="dt")
118+
*/
119+
protected $indexedByDt;
120+
121+
/**
122+
* @OneToMany(targetEntity="DoctrineRelation", mappedBy="customType", indexBy="customType")
123+
*/
124+
private $indexedByCustomType;
115125
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
13+
14+
use Doctrine\ORM\Mapping\Column;
15+
use Doctrine\ORM\Mapping\Entity;
16+
use Doctrine\ORM\Mapping\Id;
17+
use Doctrine\ORM\Mapping\ManyToMany;
18+
use Doctrine\ORM\Mapping\ManyToOne;
19+
use Doctrine\ORM\Mapping\OneToMany;
20+
21+
/**
22+
* @Entity
23+
*/
24+
final class DoctrineDummy210 extends DoctrineDummy
25+
{
26+
/**
27+
* @Column(type="json", nullable=true)
28+
*/
29+
private $json;
30+
}

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineRelation.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@ class DoctrineRelation
3939
* @ManyToOne(targetEntity="DoctrineDummy", inversedBy="indexedFoo")
4040
*/
4141
protected $foo;
42+
43+
/**
44+
* @Column(type="datetime")
45+
*/
46+
private $dt;
47+
48+
/**
49+
* @Column(type="foo")
50+
*/
51+
private $customType;
4252
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Legacy;
13+
14+
use PHPUnit\TextUI\Command as BaseCommand;
15+
use PHPUnit\TextUI\Configuration\Configuration;
16+
use PHPUnit\TextUI\Configuration\Registry;
17+
use PHPUnit\TextUI\TestRunner as BaseRunner;
18+
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
19+
20+
/**
21+
* {@inheritdoc}
22+
*
23+
* @internal
24+
*/
25+
class CommandForV9 extends BaseCommand
26+
{
27+
/**
28+
* {@inheritdoc}
29+
*/
30+
protected function createRunner(): BaseRunner
31+
{
32+
$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : [];
33+
34+
$registeredLocally = false;
35+
36+
foreach ($this->arguments['listeners'] as $registeredListener) {
37+
if ($registeredListener instanceof SymfonyTestsListener) {
38+
$registeredListener->globalListenerDisabled();
39+
$registeredLocally = true;
40+
break;
41+
}
42+
}
43+
44+
if (isset($this->arguments['configuration'])) {
45+
$configuration = $this->arguments['configuration'];
46+
if (!$configuration instanceof Configuration) {
47+
$configuration = Registry::getInstance()->get($this->arguments['configuration']);
48+
}
49+
foreach ($configuration->listeners() as $registeredListener) {
50+
if ('Symfony\Bridge\PhpUnit\SymfonyTestsListener' === ltrim($registeredListener->className(), '\\')) {
51+
$registeredLocally = true;
52+
break;
53+
}
54+
}
55+
}
56+
57+
if (!$registeredLocally) {
58+
$this->arguments['listeners'][] = new SymfonyTestsListener();
59+
}
60+
61+
return parent::createRunner();
62+
}
63+
}

src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV6.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
namespace Symfony\Bridge\PhpUnit\Legacy;
1313

14-
use PHPUnit\Framework\BaseTestListener;
1514
use PHPUnit\Framework\Test;
15+
use PHPUnit\Framework\TestListener;
16+
use PHPUnit\Framework\TestListenerDefaultImplementation;
1617

1718
/**
1819
* CoverageListener adds `@covers <className>` on each test when possible to
@@ -22,8 +23,10 @@
2223
*
2324
* @internal
2425
*/
25-
class CoverageListenerForV6 extends BaseTestListener
26+
class CoverageListenerForV6 implements TestListener
2627
{
28+
use TestListenerDefaultImplementation;
29+
2730
private $trait;
2831

2932
public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFound = false)

src/Symfony/Bridge/PhpUnit/TextUI/Command.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313

1414
if (version_compare(\PHPUnit\Runner\Version::id(), '6.0.0', '<')) {
1515
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV5', 'Symfony\Bridge\PhpUnit\TextUI\Command');
16-
} else {
16+
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '9.0.0', '<')) {
1717
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV6', 'Symfony\Bridge\PhpUnit\TextUI\Command');
18+
} else {
19+
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV9', 'Symfony\Bridge\PhpUnit\TextUI\Command');
1820
}
1921

2022
if (false) {

src/Symfony/Bridge/PhpUnit/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader"
2525
},
2626
"conflict": {
27-
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
27+
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0|<6.4,>=6.0"
2828
},
2929
"autoload": {
3030
"files": [ "bootstrap.php" ],

src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TwigErrorRenderer implements ErrorRendererInterface
3535
public function __construct(Environment $twig, HtmlErrorRenderer $fallbackErrorRenderer = null, $debug = false)
3636
{
3737
if (!\is_bool($debug) && !\is_callable($debug)) {
38-
throw new \TypeError(sprintf('Argument 2 passed to %s() must be a boolean or a callable, %s given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug)));
38+
throw new \TypeError(sprintf('Argument 3 passed to %s() must be a boolean or a callable, %s given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug)));
3939
}
4040

4141
$this->twig = $twig;

src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testGetBasePathSet()
3737

3838
$requestStackContext = new RequestStackContext($requestStack);
3939

40-
$this->assertEquals($testBasePath, $requestStackContext->getBasePath());
40+
$this->assertSame($testBasePath, $requestStackContext->getBasePath());
4141
}
4242

4343
public function testIsSecureFalse()

src/Symfony/Component/Asset/Tests/PackageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class PackageTest extends TestCase
2424
public function testGetUrl($version, $format, $path, $expected)
2525
{
2626
$package = new Package($version ? new StaticVersionStrategy($version, $format) : new EmptyVersionStrategy());
27-
$this->assertEquals($expected, $package->getUrl($path));
27+
$this->assertSame($expected, $package->getUrl($path));
2828
}
2929

3030
public function getConfigs()
@@ -50,6 +50,6 @@ public function getConfigs()
5050
public function testGetVersion()
5151
{
5252
$package = new Package(new StaticVersionStrategy('v1'));
53-
$this->assertEquals('v1', $package->getVersion('/foo'));
53+
$this->assertSame('v1', $package->getVersion('/foo'));
5454
}
5555
}

0 commit comments

Comments
 (0)
0