Skip to content

Commit af84173

Browse files
authored
Fix BC break in DoctrineOrmMappingsPass
1 parent 02f382e commit af84173

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler;
66

7+
use Doctrine\Deprecations\Deprecation;
78
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
89
use Doctrine\ORM\Mapping\Driver\XmlDriver;
910
use Doctrine\Persistence\Mapping\Driver\PHPDriver;
@@ -12,6 +13,14 @@
1213
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass;
1314
use Symfony\Component\DependencyInjection\Definition;
1415
use Symfony\Component\DependencyInjection\Reference;
16+
use TypeError;
17+
18+
use function func_get_arg;
19+
use function func_num_args;
20+
use function gettype;
21+
use function is_array;
22+
use function is_bool;
23+
use function sprintf;
1524

1625
/**
1726
* Class for Symfony bundles to configure mappings for model classes not in the
@@ -47,17 +56,39 @@ public function __construct(Definition|Reference $driver, array $namespaces, arr
4756
}
4857

4958
/**
50-
* @param string[] $namespaces Hashmap of directory path to namespace.
51-
* @param string[] $managerParameters List of parameters that could which object manager name
52-
* your bundle uses. This compiler pass will automatically
53-
* append the parameter name for the default entity manager
54-
* to this list.
55-
* @param string|false $enabledParameter Service container parameter that must be present to
56-
* enable the mapping. Set to false to not do any check,
57-
* optional.
59+
* @param string[] $namespaces Hashmap of directory path to namespace.
60+
* @param string[] $managerParameters List of parameters that could which object manager name
61+
* your bundle uses. This compiler pass will automatically
62+
* append the parameter name for the default entity manager
63+
* to this list.
64+
* @param string|false $enabledParameter Service container parameter that must be present to
65+
* enable the mapping. Set to false to not do any check,
66+
* optional.
67+
* @param bool $enableXsdValidation
68+
*
69+
* @phpstan-ignore missingType.iterableValue
5870
*/
59-
public static function createXmlMappingDriver(array $namespaces, array $managerParameters = [], string|false $enabledParameter = false, bool $enableXsdValidation = false): self
71+
public static function createXmlMappingDriver(array $namespaces, array $managerParameters = [], string|false $enabledParameter = false, bool|array $enableXsdValidation = false): self
6072
{
73+
if (is_array($enableXsdValidation)) {
74+
Deprecation::trigger(
75+
'doctrine/doctrine-bundle',
76+
'https://github.com/doctrine/DoctrineBundle/pull/2190',
77+
'Providing a $aliasMap argument to %s is deprecated and has no effect.',
78+
__METHOD__,
79+
);
80+
$enableXsdValidation = false;
81+
82+
if (func_num_args() === 5) {
83+
$enableXsdValidationArg = func_get_arg(4);
84+
if (! is_bool($enableXsdValidationArg)) {
85+
throw new TypeError(sprintf('$enableXsdValidation is expected to be boolean, %s provided', gettype($enableXsdValidationArg)));
86+
}
87+
88+
$enableXsdValidation = $enableXsdValidationArg;
89+
}
90+
}
91+
6192
$locator = new Definition(SymfonyFileLocator::class, [$namespaces, '.orm.xml']);
6293
$driver = new Definition(XmlDriver::class, [$locator, XmlDriver::DEFAULT_FILE_EXTENSION, $enableXsdValidation]);
6394

0 commit comments

Comments
 (0)