Skip to content

Commit

Permalink
Standardize runtime deprecation handling to the `doctrine/deprecation…
Browse files Browse the repository at this point in the history
…s` library (#2754)

* Standardize runtime deprecation handling to the doctrine/deprecations library

* Update src/Sortable/SortableListener.php

---------

Co-authored-by: Fran Moreno <[email protected]>
  • Loading branch information
mbabker and franmomu authored Feb 11, 2024
1 parent 8ac6b0b commit 0632ab1
Show file tree
Hide file tree
Showing 34 changed files with 201 additions and 92 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"behat/transliterator": "^1.2",
"doctrine/collections": "^1.2 || ^2.0",
"doctrine/common": "^2.13 || ^3.0",
"doctrine/deprecations": "^1.0",
"doctrine/event-manager": "^1.2 || ^2.0",
"doctrine/persistence": "^2.2 || ^3.0",
"psr/cache": "^1 || ^2 || ^3",
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
"symfony/deprecation-contracts": "^2.1 || ^3.0"
"symfony/cache": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"doctrine/annotations": "^1.13 || ^2.0",
Expand Down
7 changes: 5 additions & 2 deletions src/DoctrineExtensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\PsrCachedReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ODM\MongoDB\Mapping\Driver as DriverMongodbODM;
use Doctrine\ORM\Mapping\Driver as DriverORM;
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
Expand Down Expand Up @@ -120,10 +121,12 @@ public static function registerAbstractMappingIntoDriverChainMongodbODM(MappingD
*/
public static function registerAnnotations(): void
{
@trigger_error(sprintf(
Deprecation::trigger(
'gedmo/doctrine-extensions',
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2558',
'"%s()" is deprecated since gedmo/doctrine-extensions 3.11 and will be removed in version 4.0.',
__METHOD__
), E_USER_DEPRECATED);
);

// Purposefully no-op'd, all supported versions of `doctrine/annotations` support autoloading
}
Expand Down
8 changes: 6 additions & 2 deletions src/Mapping/Annotation/All.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
* file that was distributed with this source code.
*/

@trigger_error(sprintf(
use Doctrine\Deprecations\Deprecation;

Deprecation::trigger(
'gedmo/doctrine-extensions',
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2558',
'Requiring the file at "%s" is deprecated since gedmo/doctrine-extensions 3.11, this file will be removed in version 4.0.',
__FILE__
), E_USER_DEPRECATED);
);

// Contains all annotations for extensions
// NOTE: should be included with require_once
Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/Blameable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

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

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/IpTraceable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

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

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/Loggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Loggable\LogEntryInterface;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

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

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

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

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/ReferenceIntegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

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

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/Slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

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

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/SlugHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;
use Gedmo\Sluggable\Handler\SlugHandlerInterface;

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

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/SlugHandlerOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

/**
Expand Down Expand Up @@ -42,10 +43,12 @@ public function __construct(
$value = null
) {
if ([] !== $data) {
@trigger_error(sprintf(
Deprecation::trigger(
'gedmo/doctrine-extensions',
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2379',
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
__METHOD__
), E_USER_DEPRECATED);
);

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/SoftDeleteable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

/**
Expand Down Expand Up @@ -40,10 +41,12 @@ final class SoftDeleteable implements GedmoAnnotation
public function __construct(array $data = [], string $fieldName = 'deletedAt', bool $timeAware = false, bool $hardDelete = true)
{
if ([] !== $data) {
@trigger_error(sprintf(
Deprecation::trigger(
'gedmo/doctrine-extensions',
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2374',
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
__METHOD__
), E_USER_DEPRECATED);
);

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/Timestampable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

/**
Expand Down Expand Up @@ -42,10 +43,12 @@ final class Timestampable implements GedmoAnnotation
public function __construct(array $data = [], string $on = 'update', $field = null, $value = null)
{
if ([] !== $data) {
@trigger_error(sprintf(
Deprecation::trigger(
'gedmo/doctrine-extensions',
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2325',
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
__METHOD__
), E_USER_DEPRECATED);
);

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

/**
Expand Down Expand Up @@ -37,10 +38,12 @@ final class Translatable implements GedmoAnnotation
public function __construct(array $data = [], ?bool $fallback = null)
{
if ([] !== $data) {
@trigger_error(sprintf(
Deprecation::trigger(
'gedmo/doctrine-extensions',
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2253',
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
__METHOD__
), E_USER_DEPRECATED);
);

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/TranslationEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

/**
Expand Down Expand Up @@ -37,10 +38,12 @@ final class TranslationEntity implements GedmoAnnotation
public function __construct(array $data = [], string $class = '')
{
if ([] !== $data) {
@trigger_error(sprintf(
Deprecation::trigger(
'gedmo/doctrine-extensions',
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2253',
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
__METHOD__
), E_USER_DEPRECATED);
);

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

/**
Expand Down Expand Up @@ -60,10 +61,12 @@ public function __construct(
?string $identifierMethod = null
) {
if ([] !== $data) {
@trigger_error(sprintf(
Deprecation::trigger(
'gedmo/doctrine-extensions',
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2388',
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
__METHOD__
), E_USER_DEPRECATED);
);

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/TreeClosure.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;
use Gedmo\Tree\Entity\MappedSuperclass\AbstractClosure;

Expand Down Expand Up @@ -42,10 +43,12 @@ final class TreeClosure implements GedmoAnnotation
public function __construct(array $data = [], string $class = '')
{
if ([] !== $data) {
@trigger_error(sprintf(
Deprecation::trigger(
'gedmo/doctrine-extensions',
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2388',
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
__METHOD__
), E_USER_DEPRECATED);
);

$args = func_get_args();

Expand Down
7 changes: 5 additions & 2 deletions src/Mapping/Annotation/TreeLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Gedmo\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Deprecations\Deprecation;
use Gedmo\Mapping\Annotation\Annotation as GedmoAnnotation;

/**
Expand Down Expand Up @@ -41,10 +42,12 @@ public function __construct(
int $base = 0
) {
if ([] !== $data) {
@trigger_error(sprintf(
Deprecation::trigger(
'gedmo/doctrine-extensions',
'https://github.com/doctrine-extensions/DoctrineExtensions/pull/2388',
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
__METHOD__
), E_USER_DEPRECATED);
);

$args = func_get_args();

Expand Down
Loading

0 comments on commit 0632ab1

Please sign in to comment.