Skip to content

Commit bf8c439

Browse files
committed
deprecate HeaderBag::get and fix tests and dependencies
1 parent 7811bc6 commit bf8c439

File tree

47 files changed

+338
-237
lines changed

Some content is hidden

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

47 files changed

+338
-237
lines changed

src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\DependencyInjection\Extension\Extension;
1818
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1919
use Symfony\Component\DependencyInjection\Reference;
20+
use Symfony\Component\VarDumper\Caster\ReflectionCaster;
2021
use Symfony\Component\VarDumper\Dumper\CliDumper;
2122
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
2223

@@ -43,9 +44,9 @@ public function load(array $configs, ContainerBuilder $container)
4344
->addMethodCall('setMinDepth', [$config['min_depth']])
4445
->addMethodCall('setMaxString', [$config['max_string_length']]);
4546

46-
if (method_exists(ReflectionClass::class, 'unsetClosureFileInfo')) {
47+
if (method_exists(ReflectionCaster::class, 'unsetClosureFileInfo')) {
4748
$container->getDefinition('var_dumper.cloner')
48-
->addMethodCall('addCasters', ReflectionClass::UNSET_CLOSURE_FILE_INFO);
49+
->addMethodCall('addCasters', [ReflectionCaster::UNSET_CLOSURE_FILE_INFO]);
4950
}
5051

5152
if (method_exists(HtmlDumper::class, 'setTheme') && 'dark' !== $config['theme']) {

src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bundle\DebugBundle\DependencyInjection\DebugExtension;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
18+
use Symfony\Component\VarDumper\Caster\ReflectionCaster;
1819

1920
class DebugExtensionTest extends TestCase
2021
{
@@ -36,6 +37,39 @@ public function testLoadWithoutConfiguration()
3637
$this->assertSame($expectedTags, $container->getDefinition('data_collector.dump')->getTag('data_collector'));
3738
}
3839

40+
public function testUnsetClosureFileInfoShouldBeRegisteredInVarCloner()
41+
{
42+
if (!method_exists(ReflectionCaster::class, 'unsetClosureFileInfo')) {
43+
$this->markTestSkipped('Method not available');
44+
}
45+
46+
$container = $this->createContainer();
47+
$container->registerExtension(new DebugExtension());
48+
$container->loadFromExtension('debug', []);
49+
$this->compileContainer($container);
50+
51+
$definition = $container->getDefinition('var_dumper.cloner');
52+
53+
$called = false;
54+
foreach ($definition->getMethodCalls() as $call) {
55+
if ('addCasters' !== $call[0]) {
56+
continue;
57+
}
58+
59+
$argument = $call[1][0] ?? null;
60+
if (null === $argument) {
61+
continue;
62+
}
63+
64+
if (['Closure' => ReflectionCaster::class.'::unsetClosureFileInfo'] === $argument) {
65+
$called = true;
66+
break;
67+
}
68+
}
69+
70+
$this->assertTrue($called);
71+
}
72+
3973
private function createContainer()
4074
{
4175
$container = new ContainerBuilder(new ParameterBag([

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CHANGELOG
2323
* [BC Break] When using Messenger, the default transport changed from
2424
using Symfony's serializer service to use `PhpSerializer`, which uses
2525
PHP's native `serialize()` and `unserialize()` functions. To use the
26-
original serialization method, set the `framework.messenger.defaut_serializer`
26+
original serialization method, set the `framework.messenger.default_serializer`
2727
config option to `messenger.transport.symfony_serializer`. Or set the
2828
`serializer` option under one specific `transport`.
2929
* [BC Break] The `framework.messenger.serializer` config key changed to

src/Symfony/Bundle/FrameworkBundle/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getKernel()
6666
*/
6767
public function getProfile()
6868
{
69-
if (!$this->kernel->getContainer()->has('profiler')) {
69+
if (null === $this->response || !$this->kernel->getContainer()->has('profiler')) {
7070
return false;
7171
}
7272

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,20 @@
1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
1313

1414
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface as LegacyServiceSubscriberInterface;
15+
use Symfony\Contracts\Service\ServiceSubscriberInterface;
1516

1617
if (interface_exists(LegacyServiceSubscriberInterface::class)) {
17-
require __DIR__.\DIRECTORY_SEPARATOR.'CompatibilityServiceSubscriberInterface.legacy.php';
18+
/**
19+
* @internal
20+
*/
21+
interface CompatibilityServiceSubscriberInterface extends LegacyServiceSubscriberInterface
22+
{
23+
}
1824
} else {
19-
require __DIR__.\DIRECTORY_SEPARATOR.'CompatibilityServiceSubscriberInterface.contracts.php';
25+
/**
26+
* @internal
27+
*/
28+
interface CompatibilityServiceSubscriberInterface extends ServiceSubscriberInterface
29+
{
30+
}
2031
}

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

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

1414
use Doctrine\Common\Annotations\AnnotationRegistry;
1515
use Doctrine\Common\Annotations\Reader;
16+
use Http\Client\HttpClient;
1617
use Psr\Cache\CacheItemPoolInterface;
1718
use Psr\Container\ContainerInterface as PsrContainerInterface;
1819
use Psr\Http\Client\ClientInterface;
@@ -60,7 +61,6 @@
6061
use Symfony\Component\Form\FormTypeExtensionInterface;
6162
use Symfony\Component\Form\FormTypeGuesserInterface;
6263
use Symfony\Component\Form\FormTypeInterface;
63-
use Symfony\Component\HttpClient\Psr18Client;
6464
use Symfony\Component\HttpClient\ScopingHttpClient;
6565
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
6666
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
@@ -652,6 +652,10 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
652652
$definitionDefinition->addArgument($transitions);
653653
$definitionDefinition->addArgument($initialMarking);
654654
$definitionDefinition->addArgument($metadataStoreDefinition);
655+
$definitionDefinition->addTag('workflow.definition', [
656+
'name' => $name,
657+
'type' => $type,
658+
]);
655659

656660
// Create MarkingStore
657661
if (isset($workflow['marking_store']['type'])) {
@@ -1881,6 +1885,10 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
18811885
$container->removeAlias(ClientInterface::class);
18821886
}
18831887

1888+
if (!interface_exists(HttpClient::class)) {
1889+
$container->removeDefinition(HttpClient::class);
1890+
}
1891+
18841892
foreach ($config['scoped_clients'] as $name => $scopeConfig) {
18851893
if ('http_client' === $name) {
18861894
throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.', $name));
@@ -1901,9 +1909,8 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
19011909
$container->registerAliasForArgument($name, HttpClientInterface::class);
19021910

19031911
if ($hasPsr18) {
1904-
$container->register('psr18.'.$name, Psr18Client::class)
1905-
->setAutowired(true)
1906-
->setArguments([new Reference($name)]);
1912+
$container->setDefinition('psr18.'.$name, new ChildDefinition('psr18.http_client'))
1913+
->replaceArgument(0, new Reference($name));
19071914

19081915
$container->registerAliasForArgument('psr18.'.$name, ClientInterface::class, $name);
19091916
}

src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<argument type="service" id="form.choice_list_factory"/>
7272
</service>
7373
<service id="form.type.file" class="Symfony\Component\Form\Extension\Core\Type\FileType" public="true">
74+
<tag name="form.type" />
7475
<argument type="service" id="translator" on-invalid="ignore" />
7576
</service>
7677

src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,11 @@
2222
<argument type="service" id="Psr\Http\Message\StreamFactoryInterface" on-invalid="ignore" />
2323
</service>
2424
<service id="Psr\Http\Client\ClientInterface" alias="psr18.http_client" />
25+
26+
<service id="Http\Client\HttpClient" class="Symfony\Component\HttpClient\HttplugClient">
27+
<argument type="service" id="http_client" />
28+
<argument type="service" id="Http\Message\ResponseFactory" on-invalid="ignore" />
29+
<argument type="service" id="Http\Message\StreamFactory" on-invalid="ignore" />
30+
</service>
2531
</services>
2632
</container>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ public function testWorkflowLegacy()
311311
$workflowDefinition->getArgument(0),
312312
'Places are passed to the workflow definition'
313313
);
314+
315+
$this->assertSame(['workflow.definition' => [['name' => 'legacy', 'type' => 'state_machine']]], $workflowDefinition->getTags());
314316
}
315317

316318
/**

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public function testProfilerIsDisabled($insulate)
2828

2929
// enable the profiler for the next request
3030
$client->enableProfiler();
31-
$crawler = $client->request('GET', '/profiler');
32-
$profile = $client->getProfile();
33-
$this->assertInternalType('object', $profile);
31+
$this->assertFalse($client->getProfile());
32+
$client->request('GET', '/profiler');
33+
$this->assertInternalType('object', $client->getProfile());
3434

3535
$client->request('GET', '/profiler');
3636
$this->assertFalse($client->getProfile());

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy