Skip to content

Commit 7190ac5

Browse files
authored
[GH-9277] deprecate php driver (#9309)
* [GH-9277] Deprecate PHPDriver * Update UPGRADE.md, fix wrong parameter * Copy docblock to appease confused Psalm * Talk about alternatives more
1 parent ceaefcb commit 7190ac5

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

UPGRADE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Upgrade to 2.11
22

3+
## Deprecated: `Doctrine\ORM\Mapping\Driver\PHPDriver`
4+
5+
Use `StaticPHPDriver` instead when you want to programmatically configure
6+
entity metadata.
7+
8+
You can convert mappings with the `orm:convert-mapping` command or more simply
9+
in this case, `include` the metadata file from the `loadMetadata` static method
10+
used by the `StaticPHPDriver`.
11+
312
## Deprecated: `Setup::registerAutoloadDirectory()`
413

514
Use Composer's autoloader instead.

docs/en/reference/php-mapping.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ the code in PHP files or inside of a static function named
99
PHP Files
1010
---------
1111

12+
.. note::
13+
14+
PHPDriver is deprecated and will be removed in 3.0, use StaticPHPDriver
15+
instead.
16+
1217
If you wish to write your mapping information inside PHP files that
1318
are named after the entity and included to populate the metadata
1419
for an entity you can do so by using the ``PHPDriver``:

lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,28 @@
44

55
namespace Doctrine\ORM\Mapping\Driver;
66

7+
use Doctrine\Deprecations\Deprecation;
8+
use Doctrine\Persistence\Mapping\Driver\FileLocator;
79
use Doctrine\Persistence\Mapping\Driver\PHPDriver as CommonPHPDriver;
810

911
/**
1012
* {@inheritDoc}
1113
*
12-
* @deprecated this driver will be removed. Use Doctrine\Persistence\Mapping\Driver\PHPDriver instead
14+
* @deprecated this driver will be removed, use StaticPHPDriver or other mapping drivers instead.
1315
*/
1416
class PHPDriver extends CommonPHPDriver
1517
{
18+
/**
19+
* @param string|string[]|FileLocator $locator
20+
*/
21+
public function __construct($locator)
22+
{
23+
Deprecation::trigger(
24+
'doctrine/orm',
25+
'https://github.com/doctrine/orm/issues/9277',
26+
'PHPDriver is deprecated, use StaticPHPDriver or other mapping drivers instead.'
27+
);
28+
29+
parent::__construct($locator);
30+
}
1631
}

0 commit comments

Comments
 (0)