Skip to content

Commit 0632ab1

Browse files
mbabkerfranmomu
andauthored
Standardize runtime deprecation handling to the doctrine/deprecations library (#2754)
* Standardize runtime deprecation handling to the doctrine/deprecations library * Update src/Sortable/SortableListener.php --------- Co-authored-by: Fran Moreno <[email protected]>
1 parent 8ac6b0b commit 0632ab1

34 files changed

+201
-92
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
"behat/transliterator": "^1.2",
4545
"doctrine/collections": "^1.2 || ^2.0",
4646
"doctrine/common": "^2.13 || ^3.0",
47+
"doctrine/deprecations": "^1.0",
4748
"doctrine/event-manager": "^1.2 || ^2.0",
4849
"doctrine/persistence": "^2.2 || ^3.0",
4950
"psr/cache": "^1 || ^2 || ^3",
50-
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
51-
"symfony/deprecation-contracts": "^2.1 || ^3.0"
51+
"symfony/cache": "^5.4 || ^6.0 || ^7.0"
5252
},
5353
"require-dev": {
5454
"doctrine/annotations": "^1.13 || ^2.0",

src/DoctrineExtensions.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Doctrine\Common\Annotations\AnnotationReader;
1313
use Doctrine\Common\Annotations\PsrCachedReader;
1414
use Doctrine\Common\Annotations\Reader;
15+
use Doctrine\Deprecations\Deprecation;
1516
use Doctrine\ODM\MongoDB\Mapping\Driver as DriverMongodbODM;
1617
use Doctrine\ORM\Mapping\Driver as DriverORM;
1718
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
@@ -120,10 +121,12 @@ public static function registerAbstractMappingIntoDriverChainMongodbODM(MappingD
120121
*/
121122
public static function registerAnnotations(): void
122123
{
123-
@trigger_error(sprintf(
124+
Deprecation::trigger(
125+
'gedmo/doctrine-extensions',
126+
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2558',
124127
'"%s()" is deprecated since gedmo/doctrine-extensions 3.11 and will be removed in version 4.0.',
125128
__METHOD__
126-
), E_USER_DEPRECATED);
129+
);
127130

128131
// Purposefully no-op'd, all supported versions of `doctrine/annotations` support autoloading
129132
}

src/Mapping/Annotation/All.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
* file that was distributed with this source code.
88
*/
99

10-
@trigger_error(sprintf(
10+
use Doctrine\Deprecations\Deprecation;
11+
12+
Deprecation::trigger(
13+
'gedmo/doctrine-extensions',
14+
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2558',
1115
'Requiring the file at "%s" is deprecated since gedmo/doctrine-extensions 3.11, this file will be removed in version 4.0.',
1216
__FILE__
13-
), E_USER_DEPRECATED);
17+
);
1418

1519
// Contains all annotations for extensions
1620
// NOTE: should be included with require_once

src/Mapping/Annotation/Blameable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Gedmo\Mapping\Annotation;
1111

1212
use Doctrine\Common\Annotations\Annotation;
13+
use Doctrine\Deprecations\Deprecation;
1314
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;
1415

1516
/**
@@ -42,10 +43,12 @@ final class Blameable implements GedmoAnnotation
4243
public function __construct(array $data = [], string $on = 'update', $field = null, $value = null)
4344
{
4445
if ([] !== $data) {
45-
@trigger_error(sprintf(
46+
Deprecation::trigger(
47+
'gedmo/doctrine-extensions',
48+
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2375',
4649
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
4750
__METHOD__
48-
), E_USER_DEPRECATED);
51+
);
4952

5053
$args = func_get_args();
5154

src/Mapping/Annotation/IpTraceable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Gedmo\Mapping\Annotation;
1111

1212
use Doctrine\Common\Annotations\Annotation;
13+
use Doctrine\Deprecations\Deprecation;
1314
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;
1415

1516
/**
@@ -43,10 +44,12 @@ final class IpTraceable implements GedmoAnnotation
4344
public function __construct(array $data = [], string $on = 'update', $field = null, $value = null)
4445
{
4546
if ([] !== $data) {
46-
@trigger_error(sprintf(
47+
Deprecation::trigger(
48+
'gedmo/doctrine-extensions',
49+
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2377',
4750
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
4851
__METHOD__
49-
), E_USER_DEPRECATED);
52+
);
5053

5154
$args = func_get_args();
5255

src/Mapping/Annotation/Loggable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Gedmo\Mapping\Annotation;
1111

1212
use Doctrine\Common\Annotations\Annotation;
13+
use Doctrine\Deprecations\Deprecation;
1314
use Gedmo\Loggable\LogEntryInterface;
1415
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;
1516

@@ -46,10 +47,12 @@ final class Loggable implements GedmoAnnotation
4647
public function __construct(array $data = [], ?string $logEntryClass = null)
4748
{
4849
if ([] !== $data) {
49-
@trigger_error(sprintf(
50+
Deprecation::trigger(
51+
'gedmo/doctrine-extensions',
52+
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2357',
5053
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
5154
__METHOD__
52-
), E_USER_DEPRECATED);
55+
);
5356

5457
$args = func_get_args();
5558

src/Mapping/Annotation/Reference.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Gedmo\Mapping\Annotation;
1111

1212
use Doctrine\Common\Annotations\Annotation;
13+
use Doctrine\Deprecations\Deprecation;
1314
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;
1415

1516
/**
@@ -67,10 +68,12 @@ public function __construct(
6768
?string $inversedBy = null
6869
) {
6970
if ([] !== $data) {
70-
@trigger_error(sprintf(
71+
Deprecation::trigger(
72+
'gedmo/doctrine-extensions',
73+
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2389',
7174
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
7275
__METHOD__
73-
), E_USER_DEPRECATED);
76+
);
7477

7578
$args = func_get_args();
7679

src/Mapping/Annotation/ReferenceIntegrity.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Gedmo\Mapping\Annotation;
1111

1212
use Doctrine\Common\Annotations\Annotation;
13+
use Doctrine\Deprecations\Deprecation;
1314
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;
1415

1516
/**
@@ -39,10 +40,12 @@ public function __construct($data = [], ?string $value = null)
3940
if (is_string($data)) {
4041
$value = $data;
4142
} elseif ([] !== $data) {
42-
@trigger_error(sprintf(
43+
Deprecation::trigger(
44+
'gedmo/doctrine-extensions',
45+
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2389',
4346
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
4447
__METHOD__
45-
), E_USER_DEPRECATED);
48+
);
4649

4750
$args = func_get_args();
4851

src/Mapping/Annotation/Slug.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Gedmo\Mapping\Annotation;
1111

1212
use Doctrine\Common\Annotations\Annotation;
13+
use Doctrine\Deprecations\Deprecation;
1314
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;
1415

1516
/**
@@ -65,10 +66,12 @@ public function __construct(
6566
string $dateFormat = 'Y-m-d-H:i'
6667
) {
6768
if ([] !== $data) {
68-
@trigger_error(sprintf(
69+
Deprecation::trigger(
70+
'gedmo/doctrine-extensions',
71+
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2379',
6972
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
7073
__METHOD__
71-
), E_USER_DEPRECATED);
74+
);
7275

7376
$args = func_get_args();
7477

src/Mapping/Annotation/SlugHandler.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Gedmo\Mapping\Annotation;
1111

1212
use Doctrine\Common\Annotations\Annotation;
13+
use Doctrine\Deprecations\Deprecation;
1314
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;
1415
use Gedmo\Sluggable\Handler\SlugHandlerInterface;
1516

@@ -49,10 +50,12 @@ public function __construct(
4950
array $options = []
5051
) {
5152
if ([] !== $data) {
52-
@trigger_error(sprintf(
53+
Deprecation::trigger(
54+
'gedmo/doctrine-extensions',
55+
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2379',
5356
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
5457
__METHOD__
55-
), E_USER_DEPRECATED);
58+
);
5659

5760
$args = func_get_args();
5861

0 commit comments

Comments
 (0)