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

Skip to content

Commit 9d5285f

Browse files
[7.0] Cleanup legacy code paths
1 parent f0f5b99 commit 9d5285f

File tree

37 files changed

+49
-436
lines changed

37 files changed

+49
-436
lines changed

.github/expected-missing-return-types.diff

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/
4545
+ protected function filterResponse(object $response): Response
4646
{
4747
return $response;
48-
diff --git a/src/Symfony/Component/Clock/ClockAwareTrait.php b/src/Symfony/Component/Clock/ClockAwareTrait.php
49-
--- a/src/Symfony/Component/Clock/ClockAwareTrait.php
50-
+++ b/src/Symfony/Component/Clock/ClockAwareTrait.php
51-
@@ -33,5 +33,5 @@ trait ClockAwareTrait
52-
* @return DatePoint
53-
*/
54-
- protected function now(): \DateTimeImmutable
55-
+ protected function now(): DatePoint
56-
{
57-
$now = ($this->clock ??= new Clock())->now();
5848
diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
5949
--- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
6050
+++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
@@ -408,6 +398,23 @@ diff --git a/src/Symfony/Component/HttpKernel/KernelInterface.php b/src/Symfony/
408398
- public function shutdown();
409399
+ public function shutdown(): void;
410400

401+
/**
402+
diff --git a/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php b/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php
403+
--- a/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php
404+
+++ b/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php
405+
@@ -226,5 +226,5 @@ abstract class AttributeClassLoader implements LoaderInterface
406+
* @return string
407+
*/
408+
- protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
409+
+ protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method): string
410+
{
411+
$name = str_replace('\\', '_', $class->name).'_'.$method->name;
412+
@@ -325,5 +325,5 @@ abstract class AttributeClassLoader implements LoaderInterface
413+
* @return void
414+
*/
415+
- abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot);
416+
+ abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void;
417+
411418
/**
412419
diff --git a/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php b/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php
413420
--- a/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php
@@ -426,14 +433,14 @@ diff --git a/src/Symfony/Component/Security/Core/Authentication/RememberMe/Token
426433
+ public function deleteTokenBySeries(string $series): void;
427434

428435
/**
429-
@@ -46,5 +46,5 @@ interface TokenProviderInterface
436+
@@ -44,5 +44,5 @@ interface TokenProviderInterface
430437
* @throws TokenNotFoundException if the token is not found
431438
*/
432-
- public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed);
433-
+ public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed): void;
439+
- public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTimeInterface $lastUsed);
440+
+ public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTimeInterface $lastUsed): void;
434441

435442
/**
436-
@@ -53,4 +53,4 @@ interface TokenProviderInterface
443+
@@ -51,4 +51,4 @@ interface TokenProviderInterface
437444
* @return void
438445
*/
439446
- public function createNewToken(PersistentTokenInterface $token);

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

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

1212
namespace Symfony\Bridge\Doctrine\DependencyInjection;
1313

14-
use Symfony\Component\Config\Resource\GlobResource;
1514
use Symfony\Component\DependencyInjection\Alias;
1615
use Symfony\Component\DependencyInjection\ContainerBuilder;
1716
use Symfony\Component\DependencyInjection\Definition;
@@ -91,8 +90,8 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
9190
if (!$mappingConfig) {
9291
continue;
9392
}
94-
} elseif (!$mappingConfig['type']) {
95-
$mappingConfig['type'] = $this->detectMappingType($mappingConfig['dir'], $container);
93+
} else {
94+
$mappingConfig['type'] ??= 'attribute';
9695
}
9796

9897
$this->assertValidMappingConfiguration($mappingConfig, $objectManager['name']);
@@ -154,7 +153,7 @@ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \Re
154153
}
155154

156155
if (!$bundleConfig['dir']) {
157-
if (\in_array($bundleConfig['type'], ['annotation', 'staticphp', 'attribute'])) {
156+
if (\in_array($bundleConfig['type'], ['staticphp', 'attribute'])) {
158157
$bundleConfig['dir'] = $bundleClassDir.'/'.$this->getMappingObjectDefaultName();
159158
} else {
160159
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory($bundleDir);
@@ -187,21 +186,8 @@ protected function registerMappingDrivers(array $objectManager, ContainerBuilder
187186
if ($container->hasDefinition($mappingService)) {
188187
$mappingDriverDef = $container->getDefinition($mappingService);
189188
$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-
}
189+
$args[0] = array_merge(array_values($driverPaths), $args[0]);
195190
$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-
]);
205191
} else {
206192
$mappingDriverDef = new Definition($this->getMetadataDriverClass($driverType), [
207193
array_values($driverPaths),
@@ -237,8 +223,8 @@ protected function assertValidMappingConfiguration(array $mappingConfig, string
237223
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
238224
}
239225

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')));
226+
if (!\in_array($mappingConfig['type'], ['xml', 'yml', 'php', 'staticphp', 'attribute'])) {
227+
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')));
242228
}
243229
}
244230

@@ -264,8 +250,8 @@ protected function detectMetadataDriver(string $dir, ContainerBuilder $container
264250
}
265251
$container->fileExists($resource, false);
266252

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

271257
return null;
@@ -275,41 +261,6 @@ protected function detectMetadataDriver(string $dir, ContainerBuilder $container
275261
return $driver;
276262
}
277263

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-
313264
/**
314265
* Loads a configured object manager metadata, query or result cache driver.
315266
*

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,6 @@ public function testFixManagersAutoMappings(array $originalEm1, array $originalE
174174
], $expectedEm2));
175175
}
176176

177-
public function testMappingTypeDetection()
178-
{
179-
$container = $this->createContainer();
180-
181-
$reflection = new \ReflectionClass($this->extension);
182-
$method = $reflection->getMethod('detectMappingType');
183-
184-
// The ordinary fixtures contain annotation
185-
$mappingType = $method->invoke($this->extension, __DIR__.'/../Fixtures', $container);
186-
$this->assertSame($mappingType, 'attribute');
187-
188-
// In the attribute folder, attributes are used
189-
$mappingType = $method->invoke($this->extension, __DIR__.'/../Fixtures/Attribute', $container);
190-
$this->assertSame($mappingType, 'attribute');
191-
}
192-
193177
public static function providerBasicDrivers()
194178
{
195179
return [

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/".');

0 commit comments

Comments
 (0)