Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove calls to AnnotationRegistry::registerLoader() #48725

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

Merged
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"doctrine/collections": "^1.0|^2.0",
"doctrine/data-fixtures": "^1.1",
"doctrine/dbal": "^2.13.1|^3.0",
"doctrine/orm": "^2.7.4",
"doctrine/orm": "^2.12",
"egulias/email-validator": "^2.1.10|^3.1",
"guzzlehttp/promises": "^1.4",
"league/html-to-markdown": "^5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\ORMSetup;
use Doctrine\ORM\Tools\Setup;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor;
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy;
Expand All @@ -34,9 +33,7 @@ class DoctrineExtractorTest extends TestCase
{
private function createExtractor()
{
$config = class_exists(ORMSetup::class)
? ORMSetup::createAnnotationMetadataConfiguration([__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'], true)
: Setup::createAnnotationMetadataConfiguration([__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'], true);
$config = ORMSetup::createAnnotationMetadataConfiguration([__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'], true);
$entityManager = EntityManager::create(['driver' => 'pdo_sqlite'], $config);

if (!DBALType::hasType('foo')) {
Expand Down
7 changes: 4 additions & 3 deletions src/Symfony/Bridge/Doctrine/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@
"symfony/validator": "^5.4|^6.0",
"symfony/translation": "^5.4|^6.0",
"symfony/var-dumper": "^5.4|^6.0",
"doctrine/annotations": "^1.10.4|^2",
"doctrine/annotations": "^1.13.1|^2",
"doctrine/collections": "^1.0|^2.0",
"doctrine/data-fixtures": "^1.1",
"doctrine/dbal": "^2.13.1|^3.0",
"doctrine/orm": "^2.7.4",
"doctrine/orm": "^2.12",
"psr/log": "^1|^2|^3"
},
"conflict": {
"doctrine/annotations": "<1.13.1",
"doctrine/dbal": "<2.13.1",
"doctrine/lexer": "<1.1",
"doctrine/orm": "<2.7.4",
"doctrine/orm": "<2.12",
"phpunit/phpunit": "<5.4.3",
"symfony/cache": "<5.4",
"symfony/dependency-injection": "<6.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Bridge\PhpUnit\Legacy;

use Doctrine\Common\Annotations\AnnotationRegistry;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\RiskyTestError;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -130,14 +129,6 @@ public function startTestSuite($suite)
echo "Testing $suiteName\n";
$this->state = 0;

if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) {
if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
AnnotationRegistry::registerUniqueLoader('class_exists');
} elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader('class_exists');
}
}

if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) {
$this->state = 1;

Expand Down
9 changes: 0 additions & 9 deletions src/Symfony/Bridge/PhpUnit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* file that was distributed with this source code.
*/

use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;

// Detect if we need to serialize deprecations to a file.
Expand All @@ -27,14 +26,6 @@
// Enforce a consistent locale
setlocale(\LC_ALL, 'C');

if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) {
if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
AnnotationRegistry::registerUniqueLoader('class_exists');
} elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader('class_exists');
}
}

if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
}
1 change: 1 addition & 0 deletions src/Symfony/Bridge/PhpUnit/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader"
},
"conflict": {
"doctrine/annotations": "<1.10",
"phpunit/phpunit": "<7.5|9.1.2"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;

use Composer\InstalledVersions;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Annotations\Reader;
use Http\Client\HttpClient;
use phpDocumentor\Reflection\DocBlockFactoryInterface;
Expand Down Expand Up @@ -1643,15 +1642,6 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde

$loader->load('annotations.php');

if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
$container->getDefinition('annotations.dummy_registry')
->setMethodCalls([['registerLoader', ['class_exists']]]);
} else {
$container->removeDefinition('annotations.dummy_registry');
}
}

if ('none' === $config['cache']) {
$container->removeDefinition('annotations.cached_reader');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Annotations\PsrCachedReader;
use Doctrine\Common\Annotations\Reader;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
Expand All @@ -23,13 +22,7 @@
return static function (ContainerConfigurator $container) {
$container->services()
->set('annotations.reader', AnnotationReader::class)
->call('addGlobalIgnoredName', [
'required',
service('annotations.dummy_registry')->ignoreOnInvalid(), // dummy arg to register class_exists as annotation loader only when required
])

->set('annotations.dummy_registry', AnnotationRegistry::class)
->call('registerUniqueLoader', ['class_exists'])
->call('addGlobalIgnoredName', ['required'])

->set('annotations.cached_reader', PsrCachedReader::class)
->args([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Routing\Tests\Loader;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Component\Routing\Loader\AnnotationClassLoader;
use Symfony\Component\Routing\Route;

Expand All @@ -26,9 +25,6 @@ protected function configureRoute(Route $route, \ReflectionClass $class, \Reflec
{
}
};
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader('class_exists');
}
}

public function testDefaultRouteName()
Expand Down