Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce doctrine/deprecations #8466

Merged
merged 7 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"doctrine/collections": "^1.5",
"doctrine/common": "^3.0.3",
"doctrine/dbal": "^2.10.0",
"doctrine/deprecations": "^0.2.0",
"doctrine/event-manager": "^1.1",
"doctrine/inflector": "^1.4|^2.0",
"doctrine/instantiator": "^1.3",
Expand Down
12 changes: 6 additions & 6 deletions lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\Cache\Logging\CacheLogger;
use Doctrine\ORM\Cache\QueryCacheKey;
use Doctrine\ORM\Cache\TimestampCacheKey;
Expand All @@ -48,9 +49,6 @@
use function reset;
use function serialize;
use function sha1;
use function trigger_error;

use const E_USER_DEPRECATED;

/**
* Base contract for ORM queries. Base class for Query and NativeQuery.
Expand Down Expand Up @@ -957,9 +955,11 @@ public function getHints()
*/
public function iterate($parameters = null, $hydrationMode = null)
{
@trigger_error(
'Method ' . __METHOD__ . '() is deprecated and will be removed in Doctrine ORM 3.0. Use toIterable() instead.',
E_USER_DEPRECATED
Deprecation::trigger(
'doctrine/orm',
beberlei marked this conversation as resolved.
Show resolved Hide resolved
'https://github.com/doctrine/orm/issues/8463',
'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use toIterable() instead.',
__METHOD__
);

if ($hydrationMode !== null) {
Expand Down
38 changes: 23 additions & 15 deletions lib/Doctrine/ORM/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\LockMode;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataFactory;
use Doctrine\ORM\Proxy\ProxyFactory;
Expand All @@ -48,9 +49,6 @@
use function is_string;
use function ltrim;
use function sprintf;
use function trigger_error;

use const E_USER_DEPRECATED;

/**
* The EntityManager is the central access point to ORM functionality.
Expand Down Expand Up @@ -365,9 +363,11 @@ public function createQueryBuilder()
public function flush($entity = null)
{
if ($entity !== null) {
@trigger_error(
'Calling ' . __METHOD__ . '() with any arguments to flush specific entities is deprecated and will not be supported in Doctrine ORM 3.0.',
E_USER_DEPRECATED
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8459',
'Calling %s() with any arguments to flush specific entities is deprecated and will not be supported in Doctrine ORM 3.0.',
__METHOD__
);
}

Expand Down Expand Up @@ -569,9 +569,11 @@ public function clear($entityName = null)
}

if ($entityName !== null) {
@trigger_error(
'Calling ' . __METHOD__ . '() with any arguments to clear specific entities is deprecated and will not be supported in Doctrine ORM 3.0.',
E_USER_DEPRECATED
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8460',
'Calling %s() with any arguments to clear specific entities is deprecated and will not be supported in Doctrine ORM 3.0.',
__METHOD__
);
}

Expand Down Expand Up @@ -672,8 +674,6 @@ public function refresh($entity)
* Entities which previously referenced the detached entity will continue to
* reference it.
*
* @deprecated 2.7 This method is being removed from the ORM and won't have any replacement
*
* @param object $entity The entity to detach.
*
* @return void
Expand All @@ -682,8 +682,6 @@ public function refresh($entity)
*/
public function detach($entity)
{
@trigger_error('Method ' . __METHOD__ . '() is deprecated and will be removed in Doctrine ORM 3.0.', E_USER_DEPRECATED);

if (! is_object($entity)) {
throw ORMInvalidArgumentException::invalidObject('EntityManager#detach()', $entity);
}
Expand All @@ -707,7 +705,12 @@ public function detach($entity)
*/
public function merge($entity)
{
@trigger_error('Method ' . __METHOD__ . '() is deprecated and will be removed in Doctrine ORM 3.0.', E_USER_DEPRECATED);
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8461',
'Method %s() is deprecated and will be removed in Doctrine ORM 3.0.',
__METHOD__
);

if (! is_object($entity)) {
throw ORMInvalidArgumentException::invalidObject('EntityManager#merge()', $entity);
Expand All @@ -723,7 +726,12 @@ public function merge($entity)
*/
public function copy($entity, $deep = false)
{
@trigger_error('Method ' . __METHOD__ . '() is deprecated and will be removed in Doctrine ORM 3.0.', E_USER_DEPRECATED);
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8462',
'Method %s() is deprecated and will be removed in Doctrine ORM 3.0.',
__METHOD__
);

throw new BadMethodCallException('Not implemented.');
}
Expand Down
11 changes: 7 additions & 4 deletions lib/Doctrine/ORM/EntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Selectable;
use Doctrine\Deprecations\Deprecation;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use Doctrine\ORM\Mapping\ClassMetadata;
Expand All @@ -35,9 +36,6 @@
use function sprintf;
use function strpos;
use function substr;
use function trigger_error;

use const E_USER_DEPRECATED;

/**
* An EntityRepository serves as a repository for entities with generic as well as
Expand Down Expand Up @@ -145,7 +143,12 @@ public function createNativeNamedQuery($queryName)
*/
public function clear()
{
@trigger_error('Method ' . __METHOD__ . '() is deprecated and will be removed in Doctrine ORM 3.0.', E_USER_DEPRECATED);
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8460',
'Calling %s() is deprecated and will not be supported in Doctrine ORM 3.0.',
__METHOD__
);

$this->_em->clear($this->_class->rootEntityName);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping\ClassMetadata;
Expand All @@ -37,9 +38,6 @@
use function array_merge;
use function end;
use function in_array;
use function trigger_error;

use const E_USER_DEPRECATED;

/**
* Base class for all hydrators. A hydrator is a class that provides some form
Expand Down Expand Up @@ -128,9 +126,11 @@ public function __construct(EntityManagerInterface $em)
*/
public function iterate($stmt, $resultSetMapping, array $hints = [])
{
@trigger_error(
'Method ' . __METHOD__ . '() is deprecated and will be removed in Doctrine ORM 3.0. Use toIterable() instead.',
E_USER_DEPRECATED
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8463',
'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use toIterable() instead.',
__METHOD__
);

$this->_stmt = $stmt;
Expand Down
11 changes: 5 additions & 6 deletions lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Doctrine\ORM\Mapping\Driver;

use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder;
use Doctrine\ORM\Mapping\ClassMetadata as Metadata;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
Expand All @@ -40,9 +41,6 @@
use function strlen;
use function strtoupper;
use function substr;
use function trigger_error;

use const E_USER_DEPRECATED;

/**
* The YamlDriver reads the mapping metadata from yaml schema files.
Expand All @@ -58,9 +56,10 @@ class YamlDriver extends FileDriver
*/
public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENSION)
{
@trigger_error(
'YAML mapping driver is deprecated and will be removed in Doctrine ORM 3.0, please migrate to annotation or XML driver.',
E_USER_DEPRECATED
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8465',
'YAML mapping driver is deprecated and will be removed in Doctrine ORM 3.0, please migrate to annotation or XML driver.'
);

parent::__construct($locator, $fileExtension);
Expand Down
12 changes: 7 additions & 5 deletions lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Deprecations\Deprecation;

use function preg_replace;
use function strpos;
use function strrpos;
use function strtolower;
use function strtoupper;
use function substr;
use function trigger_error;

use const CASE_LOWER;
use const CASE_UPPER;
use const E_USER_DEPRECATED;

/**
* Naming strategy implementing the underscore naming convention.
Expand All @@ -57,9 +57,11 @@ class UnderscoreNamingStrategy implements NamingStrategy
public function __construct($case = CASE_LOWER, bool $numberAware = false)
{
if (! $numberAware) {
@trigger_error(
'Creating ' . self::class . ' without making it number aware is deprecated and will be removed in Doctrine ORM 3.0.',
E_USER_DEPRECATED
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/7908',
'Creating %s without setting second argument $numberAware=true is deprecated and will be removed in Doctrine ORM 3.0.',
self::class
);
}

Expand Down
10 changes: 7 additions & 3 deletions lib/Doctrine/ORM/Tools/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
Expand Down Expand Up @@ -64,12 +65,10 @@
use function strtolower;
use function substr;
use function token_get_all;
use function trigger_error;
use function ucfirst;
use function var_export;

use const DIRECTORY_SEPARATOR;
use const E_USER_DEPRECATED;
use const PHP_EOL;
use const PHP_VERSION_ID;
use const T_CLASS;
Expand Down Expand Up @@ -372,7 +371,12 @@ public function __construct(<params>)

public function __construct()
{
@trigger_error(self::class . ' is deprecated and will be removed in Doctrine ORM 3.0', E_USER_DEPRECATED);
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8458',
'%s is deprecated with no replacement',
self::class
);

$this->annotationsPrefix = 'ORM\\';
$this->inflector = InflectorFactory::create()->build();
Expand Down
10 changes: 7 additions & 3 deletions lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Doctrine\ORM\Tools;

use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityRepository;

use function array_keys;
Expand All @@ -34,10 +35,8 @@
use function strlen;
use function strrpos;
use function substr;
use function trigger_error;

use const DIRECTORY_SEPARATOR;
use const E_USER_DEPRECATED;

/**
* Class to generate entity repository classes
Expand Down Expand Up @@ -68,7 +67,12 @@ class <className> extends <repositoryName>

public function __construct()
{
@trigger_error(self::class . ' is deprecated and will be removed in Doctrine ORM 3.0', E_USER_DEPRECATED);
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8458',
'%s is deprecated and will be removed in Doctrine ORM 3.0',
self::class
);
}

/**
Expand Down
11 changes: 7 additions & 4 deletions lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

namespace Doctrine\ORM\Tools\Export;

use function trigger_error;

use const E_USER_DEPRECATED;
use Doctrine\Deprecations\Deprecation;

/**
* Class used for converting your mapping information between the
Expand All @@ -45,7 +43,12 @@ class ClassMetadataExporter

public function __construct()
{
@trigger_error(self::class . ' is deprecated and will be removed in Doctrine ORM 3.0', E_USER_DEPRECATED);
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8458',
'%s is deprecated with no replacement',
self::class
);
}

/**
Expand Down
11 changes: 7 additions & 4 deletions lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Doctrine\ORM\Tools\Export\Driver;

use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Tools\Export\ExportException;

Expand All @@ -30,9 +31,6 @@
use function is_dir;
use function mkdir;
use function str_replace;
use function trigger_error;

use const E_USER_DEPRECATED;

/**
* Abstract base class which is to be used for the Exporter drivers
Expand Down Expand Up @@ -61,7 +59,12 @@ abstract class AbstractExporter
*/
public function __construct($dir = null)
{
@trigger_error(static::class . ' is deprecated and will be removed in Doctrine ORM 3.0', E_USER_DEPRECATED);
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8458',
'%s is deprecated with no replacement',
self::class
);

$this->_outputDir = $dir;
}
Expand Down
Loading