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

Skip to content

Commit f5323aa

Browse files
[7.0] Cleanup legacy code paths
1 parent 950cd70 commit f5323aa

File tree

45 files changed

+41
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+41
-348
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
9191
if (!$mappingConfig) {
9292
continue;
9393
}
94-
} elseif (!$mappingConfig['type']) {
95-
$mappingConfig['type'] = $this->detectMappingType($mappingConfig['dir'], $container);
94+
} else {
95+
$mappingConfig['type'] ??= 'attribute';
9696
}
9797

9898
$this->assertValidMappingConfiguration($mappingConfig, $objectManager['name']);
@@ -154,7 +154,7 @@ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \Re
154154
}
155155

156156
if (!$bundleConfig['dir']) {
157-
if (\in_array($bundleConfig['type'], ['annotation', 'staticphp', 'attribute'])) {
157+
if (\in_array($bundleConfig['type'], ['staticphp', 'attribute'])) {
158158
$bundleConfig['dir'] = $bundleClassDir.'/'.$this->getMappingObjectDefaultName();
159159
} else {
160160
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory($bundleDir);
@@ -187,21 +187,8 @@ protected function registerMappingDrivers(array $objectManager, ContainerBuilder
187187
if ($container->hasDefinition($mappingService)) {
188188
$mappingDriverDef = $container->getDefinition($mappingService);
189189
$args = $mappingDriverDef->getArguments();
190-
if ('annotation' == $driverType) {
191-
$args[1] = array_merge(array_values($driverPaths), $args[1]);
192-
} else {
193-
$args[0] = array_merge(array_values($driverPaths), $args[0]);
194-
}
190+
$args[0] = array_merge(array_values($driverPaths), $args[0]);
195191
$mappingDriverDef->setArguments($args);
196-
} elseif ('attribute' === $driverType) {
197-
$mappingDriverDef = new Definition($this->getMetadataDriverClass($driverType), [
198-
array_values($driverPaths),
199-
]);
200-
} elseif ('annotation' == $driverType) {
201-
$mappingDriverDef = new Definition($this->getMetadataDriverClass($driverType), [
202-
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
203-
array_values($driverPaths),
204-
]);
205192
} else {
206193
$mappingDriverDef = new Definition($this->getMetadataDriverClass($driverType), [
207194
array_values($driverPaths),
@@ -237,8 +224,8 @@ protected function assertValidMappingConfiguration(array $mappingConfig, string
237224
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
238225
}
239226

240-
if (!\in_array($mappingConfig['type'], ['xml', 'yml', 'annotation', 'php', 'staticphp', 'attribute'])) {
241-
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php", "staticphp" or "attribute" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. You can register them by adding a new driver to the "%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver')));
227+
if (!\in_array($mappingConfig['type'], ['xml', 'yml', 'php', 'staticphp', 'attribute'])) {
228+
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "php", "staticphp" or "attribute" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. You can register them by adding a new driver to the "%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver')));
242229
}
243230
}
244231

@@ -264,8 +251,8 @@ protected function detectMetadataDriver(string $dir, ContainerBuilder $container
264251
}
265252
$container->fileExists($resource, false);
266253

267-
if ($container->fileExists($discoveryPath = $dir.'/'.$this->getMappingObjectDefaultName(), false)) {
268-
return $this->detectMappingType($discoveryPath, $container);
254+
if ($container->fileExists($dir.'/'.$this->getMappingObjectDefaultName(), false)) {
255+
return 'attribute';
269256
}
270257

271258
return null;
@@ -275,41 +262,6 @@ protected function detectMetadataDriver(string $dir, ContainerBuilder $container
275262
return $driver;
276263
}
277264

278-
/**
279-
* Detects what mapping type to use for the supplied directory.
280-
*
281-
* @return string A mapping type 'attribute' or 'annotation'
282-
*/
283-
private function detectMappingType(string $directory, ContainerBuilder $container): string
284-
{
285-
$type = 'attribute';
286-
287-
$glob = new GlobResource($directory, '*', true);
288-
$container->addResource($glob);
289-
290-
$quotedMappingObjectName = preg_quote($this->getMappingObjectDefaultName(), '/');
291-
292-
foreach ($glob as $file) {
293-
$content = file_get_contents($file);
294-
295-
if (
296-
preg_match('/^#\[.*'.$quotedMappingObjectName.'\b/m', $content)
297-
|| preg_match('/^#\[.*Embeddable\b/m', $content)
298-
) {
299-
break;
300-
}
301-
if (
302-
preg_match('/^(?: \*|\/\*\*) @.*'.$quotedMappingObjectName.'\b/m', $content)
303-
|| preg_match('/^(?: \*|\/\*\*) @.*Embeddable\b/m', $content)
304-
) {
305-
$type = 'annotation';
306-
break;
307-
}
308-
}
309-
310-
return $type;
311-
}
312-
313265
/**
314266
* Loads a configured object manager metadata, query or result cache driver.
315267
*

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\PhpUnit\Legacy;
1313

14-
use Doctrine\Common\Annotations\AnnotationRegistry;
1514
use PHPUnit\Framework\AssertionFailedError;
1615
use PHPUnit\Framework\RiskyTestError;
1716
use PHPUnit\Framework\TestCase;
@@ -130,14 +129,6 @@ public function startTestSuite($suite): void
130129
echo "Testing $suiteName\n";
131130
$this->state = 0;
132131

133-
if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) {
134-
if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
135-
AnnotationRegistry::registerUniqueLoader('class_exists');
136-
} elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) {
137-
AnnotationRegistry::registerLoader('class_exists');
138-
}
139-
}
140-
141132
if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) {
142133
$this->state = 1;
143134

src/Symfony/Bridge/PhpUnit/bootstrap.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
use Doctrine\Common\Annotations\AnnotationRegistry;
1312
use Doctrine\Deprecations\Deprecation;
1413
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1514

@@ -41,14 +40,6 @@
4140
}
4241
}
4342

44-
if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) {
45-
if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
46-
AnnotationRegistry::registerUniqueLoader('class_exists');
47-
} elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) {
48-
AnnotationRegistry::registerLoader('class_exists');
49-
}
50-
}
51-
5243
if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
5344
DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
5445
}

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
1313

14-
use Doctrine\Common\Annotations\AnnotationException;
1514
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1615
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
1716
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
@@ -51,8 +50,6 @@ protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter, string
5150
foreach ($loader->getMappedClasses() as $mappedClass) {
5251
try {
5352
$metadataFactory->getMetadataFor($mappedClass);
54-
} catch (AnnotationException) {
55-
// ignore failing annotations
5653
} catch (\Exception $e) {
5754
$this->ignoreAutoloadException($mappedClass, $e);
5855
}

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
1313

14-
use Doctrine\Common\Annotations\AnnotationException;
1514
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1615
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
1716
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
@@ -50,8 +49,6 @@ protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter, string
5049
if ($metadataFactory->hasMetadataFor($mappedClass)) {
5150
$metadataFactory->getMetadataFor($mappedClass);
5251
}
53-
} catch (AnnotationException) {
54-
// ignore failing annotations
5552
} catch (\Exception $e) {
5653
$this->ignoreAutoloadException($mappedClass, $e);
5754
}

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,9 +899,6 @@ private function addAssetMapperSection(ArrayNodeDefinition $rootNode, callable $
899899
->info('The directory to store JavaScript vendors.')
900900
->defaultValue('%kernel.project_dir%/assets/vendor')
901901
->end()
902-
->scalarNode('provider')
903-
->setDeprecated('symfony/framework-bundle', '6.4', 'Option "%node%" at "%path%" is deprecated and does nothing. Remove it.')
904-
->end()
905902
->end()
906903
->end()
907904
->end()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -564,14 +564,6 @@ public function load(array $configs, ContainerBuilder $container): void
564564
$this->registerHtmlSanitizerConfiguration($config['html_sanitizer'], $container, $loader);
565565
}
566566

567-
$this->addAnnotatedClassesToCompile([
568-
'**\\Controller\\',
569-
'**\\Entity\\',
570-
571-
// Added explicitly so that we don't rely on the class map being dumped to make it work
572-
AbstractController::class,
573-
]);
574-
575567
if (ContainerBuilder::willBeAvailable('symfony/mime', MimeTypes::class, ['symfony/framework-bundle'])) {
576568
$loader->load('mime_type.php');
577569
}

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,7 @@ public function boot(): void
9595

9696
$handler = ErrorHandler::register(null, false);
9797

98-
// When upgrading an existing Symfony application from 6.2 to 6.3, and
99-
// the cache is warmed up, the service is not available yet, so we need
100-
// to check if it exists.
101-
if ($this->container->has('debug.error_handler_configurator')) {
102-
$this->container->get('debug.error_handler_configurator')->configure($handler);
103-
}
98+
$this->container->get('debug.error_handler_configurator')->configure($handler);
10499

105100
if ($this->container->getParameter('kernel.http_method_override')) {
106101
Request::enableHttpMethodParameterOverride();

src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@
5656
->private()
5757
->tag('cache.pool')
5858

59-
->set('cache.annotations')
60-
->parent('cache.system')
61-
->private()
62-
->tag('cache.pool')
63-
6459
->set('cache.property_info')
6560
->parent('cache.system')
6661
->private()

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
use Symfony\Component\HttpKernel\HttpKernelInterface;
4949
use Symfony\Component\HttpKernel\KernelEvents;
5050
use Symfony\Component\HttpKernel\KernelInterface;
51-
use Symfony\Component\HttpKernel\UriSigner as HttpKernelUriSigner;
5251
use Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner;
5352
use Symfony\Component\Runtime\Runner\Symfony\ResponseRunner;
5453
use Symfony\Component\Runtime\SymfonyRuntime;
@@ -158,8 +157,6 @@ class_exists(WorkflowEvents::class) ? WorkflowEvents::ALIASES : []
158157
param('kernel.secret'),
159158
])
160159
->alias(UriSigner::class, 'uri_signer')
161-
->alias(HttpKernelUriSigner::class, 'uri_signer')
162-
->deprecate('symfony/framework-bundle', '6.4', 'The "%alias_id%" alias is deprecated, use "'.UriSigner::class.'" instead.')
163160

164161
->set('config_cache_factory', ResourceCheckerConfigCacheFactory::class)
165162
->args([

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Psr\Log\LoggerAwareInterface;
16-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1716
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
1817
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1918
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage;
@@ -91,8 +90,6 @@
9190

9291
abstract class FrameworkExtensionTestCase extends TestCase
9392
{
94-
use ExpectDeprecationTrait;
95-
9693
private static array $containerCache = [];
9794

9895
abstract protected function loadFromFile(ContainerBuilder $container, $file);

src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Symfony\Component\HttpFoundation\Cookie as HttpFoundationCookie;
2424
use Symfony\Component\HttpFoundation\Request;
2525
use Symfony\Component\HttpFoundation\Response;
26-
use Symfony\Component\HttpFoundation\Test\Constraint\ResponseHeaderLocationSame;
2726

2827
class WebTestCaseTest extends TestCase
2928
{
@@ -62,10 +61,6 @@ public function testAssertResponseRedirectsWithLocation()
6261

6362
public function testAssertResponseRedirectsWithLocationWithoutHost()
6463
{
65-
if (!class_exists(ResponseHeaderLocationSame::class)) {
66-
$this->markTestSkipped('Requires symfony/http-foundation 6.3 or higher.');
67-
}
68-
6964
$this->getResponseTester(new Response('', 301, ['Location' => 'https://example.com/']))->assertResponseRedirects('/');
7065
$this->expectException(AssertionFailedError::class);
7166
$this->expectExceptionMessage('is redirected and has header "Location" matching "/".');
@@ -74,10 +69,6 @@ public function testAssertResponseRedirectsWithLocationWithoutHost()
7469

7570
public function testAssertResponseRedirectsWithLocationWithoutScheme()
7671
{
77-
if (!class_exists(ResponseHeaderLocationSame::class)) {
78-
$this->markTestSkipped('Requires symfony/http-foundation 6.3 or higher.');
79-
}
80-
8172
$this->getResponseTester(new Response('', 301, ['Location' => 'https://example.com/']))->assertResponseRedirects('//example.com/');
8273
$this->expectException(AssertionFailedError::class);
8374
$this->expectExceptionMessage('is redirected and has header "Location" matching "//example.com/".');

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Factory;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1615
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory;
1716
use Symfony\Component\DependencyInjection\ChildDefinition;
1817
use Symfony\Component\DependencyInjection\ContainerBuilder;
1918

2019
class AbstractFactoryTest extends TestCase
2120
{
22-
use ExpectDeprecationTrait;
23-
2421
private ContainerBuilder $container;
2522

2623
protected function setUp(): void

src/Symfony/Component/AssetMapper/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
],
1818
"require": {
1919
"php": ">=8.2",
20-
"symfony/deprecation-contracts": "^2.5|^3",
2120
"symfony/filesystem": "^6.4|^7.0",
2221
"symfony/http-client": "^6.4|^7.0"
2322
},

src/Symfony/Component/Clock/ClockAwareTrait.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ public function setClock(ClockInterface $clock): void
2929
$this->clock = $clock;
3030
}
3131

32-
/**
33-
* @return DatePoint
34-
*/
35-
protected function now(): \DateTimeImmutable
32+
protected function now(): DatePoint
3633
{
3734
$now = ($this->clock ??= new Clock())->now();
3835

src/Symfony/Component/DependencyInjection/Tests/ServiceLocatorTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@
1818
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
1919
use Symfony\Component\DependencyInjection\ServiceLocator;
2020
use Symfony\Contracts\Service\ServiceSubscriberInterface;
21-
use Symfony\Contracts\Service\Test\ServiceLocatorTest as LegacyServiceLocatorTestCase;
2221
use Symfony\Contracts\Service\Test\ServiceLocatorTestCase;
2322

24-
if (!class_exists(ServiceLocatorTestCase::class)) {
25-
class_alias(LegacyServiceLocatorTestCase::class, ServiceLocatorTestCase::class);
26-
}
27-
2823
class ServiceLocatorTest extends ServiceLocatorTestCase
2924
{
3025
public function getServiceLocator(array $factories): ContainerInterface

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,11 @@ public function sendContent(): static
392392
*
393393
* @return $this
394394
*/
395-
public function send(/* bool $flush = true */): static
395+
public function send(bool $flush = true): static
396396
{
397397
$this->sendHeaders();
398398
$this->sendContent();
399399

400-
$flush = 1 <= \func_num_args() ? func_get_arg(0) : true;
401400
if (!$flush) {
402401
return $this;
403402
}

src/Symfony/Component/HttpFoundation/UriSigner.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,3 @@ private function buildUrl(array $url, array $params = []): string
105105
return $scheme.$user.$pass.$host.$port.$path.$query.$fragment;
106106
}
107107
}
108-
109-
if (!class_exists(\Symfony\Component\HttpKernel\UriSigner::class, false)) {
110-
class_alias(UriSigner::class, \Symfony\Component\HttpKernel\UriSigner::class);
111-
}

src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ final protected function unserialize(string $data): void
9797
{
9898
}
9999

100-
/**
101-
* @return void
102-
*/
103-
public function reset()
100+
public function reset(): void
104101
{
105102
$this->data = [];
106103
}

0 commit comments

Comments
 (0)