Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 508ba77

Browse filesBrowse files
committed
[WIP][HttpKernel] remove deprecated features
1 parent d6bdd23 commit 508ba77
Copy full SHA for 508ba77

File tree

10 files changed

+27
-286
lines changed
Filter options

10 files changed

+27
-286
lines changed

‎src/Symfony/Component/HttpKernel/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/CHANGELOG.md
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ CHANGELOG
44
4.0.0
55
-----
66

7+
* removed the `DataCollector::varToString()` method, use `DataCollector::cloneVar()`
8+
instead
9+
* using the `DataCollector::cloneVar()` method requires the VarDumper component
10+
* removed the `ValueExporter` class
711
* removed `ControllerResolverInterface::getArguments()`
812
* removed `TraceableControllerResolver::getArguments()`
913
* removed `ControllerResolver::getArguments()` and the ability to resolve arguments
1014
* removed the `argument_resolver` service dependency from the `debug.controller_resolver`
1115
* removed `LazyLoadingFragmentHandler::addRendererService()`
1216
* removed `Psr6CacheClearer::addPool()`
1317
* removed `Extension::addClassesToCompile()` and `Extension::getClassesToCompile()`
14-
* removed `Kernel::loadClassCache()`, `Kernel::doLoadClassCache()` and `Kernel::setClassCache()`
18+
* removed `Kernel::loadClassCache()`, `Kernel::doLoadClassCache()`, `Kernel::setClassCache()`,
19+
and `Kernel::getEnvParameters()`
20+
* support for the `X-Status-Code` when handling exceptions in the `HttpKernel`
21+
has been dropped, use the `HttpKernel::allowCustomResponseCode()` method
22+
instead
1523

1624
3.3.0
1725
-----

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php
+4-37Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
2929
{
3030
protected $data = array();
3131

32-
/**
33-
* @var ValueExporter
34-
*/
35-
private $valueExporter;
36-
3732
/**
3833
* @var ClonerInterface
3934
*/
@@ -62,42 +57,14 @@ public function unserialize($data)
6257
protected function cloneVar($var)
6358
{
6459
if (null === self::$cloner) {
65-
if (class_exists(ClassStub::class)) {
66-
self::$cloner = new VarCloner();
67-
self::$cloner->setMaxItems(-1);
68-
} else {
69-
@trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since version 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), E_USER_DEPRECATED);
70-
self::$cloner = false;
71-
}
72-
}
73-
if (false === self::$cloner) {
74-
if (null === $this->valueExporter) {
75-
$this->valueExporter = new ValueExporter();
60+
if (!class_exists(ClassStub::class)) {
61+
throw new \LogicException(sprintf('The VarDumper component is needed for the %s() method. Install symfony/var-dumper version 3.2 or above.', __METHOD__));
7662
}
7763

78-
return $this->valueExporter->exportValue($var);
64+
self::$cloner = new VarCloner();
65+
self::$cloner->setMaxItems(-1);
7966
}
8067

8168
return self::$cloner->cloneVar($var);
8269
}
83-
84-
/**
85-
* Converts a PHP variable to a string.
86-
*
87-
* @param mixed $var A PHP variable
88-
*
89-
* @return string The string representation of the variable
90-
*
91-
* @deprecated since version 3.2, to be removed in 4.0. Use cloneVar() instead.
92-
*/
93-
protected function varToString($var)
94-
{
95-
@trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use cloneVar() instead.', __METHOD__), E_USER_DEPRECATED);
96-
97-
if (null === $this->valueExporter) {
98-
$this->valueExporter = new ValueExporter();
99-
}
100-
101-
return $this->valueExporter->exportValue($var);
102-
}
10370
}

‎src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php
-99Lines changed: 0 additions & 99 deletions
This file was deleted.

‎src/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function render($uri, Request $request, array $options = array())
6565
{
6666
if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) {
6767
if ($uri instanceof ControllerReference && $this->containsNonScalars($uri->attributes)) {
68-
@trigger_error('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated since version 3.1, and will be removed in 4.0. Use a different rendering strategy or pass scalar values.', E_USER_DEPRECATED);
68+
throw new \InvalidArgumentException('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is not supported. Use a different rendering strategy or pass scalar values.');
6969
}
7070

7171
return $this->inlineStrategy->render($uri, $request, $options);

‎src/Symfony/Component/HttpKernel/HttpKernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/HttpKernel.php
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,7 @@ private function handleException(\Exception $e, $request, $type)
239239
$response = $event->getResponse();
240240

241241
// the developer asked for a specific status code
242-
if ($response->headers->has('X-Status-Code')) {
243-
@trigger_error(sprintf('Using the X-Status-Code header is deprecated since version 3.3 and will be removed in 4.0. Use %s::allowCustomResponseCode() instead.', GetResponseForExceptionEvent::class), E_USER_DEPRECATED);
244-
245-
$response->setStatusCode($response->headers->get('X-Status-Code'));
246-
247-
$response->headers->remove('X-Status-Code');
248-
} elseif (!$event->isAllowingCustomResponseCode() && !$response->isClientError() && !$response->isServerError() && !$response->isRedirect()) {
242+
if (!$event->isAllowingCustomResponseCode() && !$response->isClientError() && !$response->isServerError() && !$response->isRedirect()) {
249243
// ensure that we actually have an error response
250244
if ($e instanceof HttpExceptionInterface) {
251245
// keep the HTTP status code and headers

‎src/Symfony/Component/HttpKernel/Kernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Kernel.php
+12-41Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -544,50 +544,21 @@ protected function getKernelParameters()
544544
);
545545
}
546546

547-
return array_merge(
548-
array(
549-
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
550-
'kernel.project_dir' => realpath($this->projectDir) ?: $this->projectDir,
551-
'kernel.environment' => $this->environment,
552-
'kernel.debug' => $this->debug,
553-
'kernel.name' => $this->name,
554-
'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(),
555-
'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),
556-
'kernel.bundles' => $bundles,
557-
'kernel.bundles_metadata' => $bundlesMetadata,
558-
'kernel.charset' => $this->getCharset(),
559-
'kernel.container_class' => $this->getContainerClass(),
560-
),
561-
$this->getEnvParameters(false)
547+
return array(
548+
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
549+
'kernel.project_dir' => realpath($this->projectDir) ?: $this->projectDir,
550+
'kernel.environment' => $this->environment,
551+
'kernel.debug' => $this->debug,
552+
'kernel.name' => $this->name,
553+
'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(),
554+
'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),
555+
'kernel.bundles' => $bundles,
556+
'kernel.bundles_metadata' => $bundlesMetadata,
557+
'kernel.charset' => $this->getCharset(),
558+
'kernel.container_class' => $this->getContainerClass(),
562559
);
563560
}
564561

565-
/**
566-
* Gets the environment parameters.
567-
*
568-
* Only the parameters starting with "SYMFONY__" are considered.
569-
*
570-
* @return array An array of parameters
571-
*
572-
* @deprecated since version 3.3, to be removed in 4.0
573-
*/
574-
protected function getEnvParameters()
575-
{
576-
if (0 === func_num_args() || func_get_arg(0)) {
577-
@trigger_error(sprintf('The %s() method is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax to get the value of any environment variable from configuration files instead.', __METHOD__), E_USER_DEPRECATED);
578-
}
579-
580-
$parameters = array();
581-
foreach ($_SERVER as $key => $value) {
582-
if (0 === strpos($key, 'SYMFONY__')) {
583-
@trigger_error(sprintf('The support of special environment variables that start with SYMFONY__ (such as "%s") is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax instead to get the value of environment variables in configuration files.', $key), E_USER_DEPRECATED);
584-
$parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value;
585-
}
586-
}
587-
588-
return $parameters;
589-
}
590-
591562
/**
592563
* Builds the service container.
593564
*

‎src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php
-51Lines changed: 0 additions & 51 deletions
This file was deleted.

‎src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php
-12Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@ public function testRenderFallbackToInlineStrategyIfEsiNotSupported()
2626
$strategy->render('/', Request::create('/'));
2727
}
2828

29-
/**
30-
* @group legacy
31-
* @expectedDeprecation Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated %s.
32-
*/
33-
public function testRenderFallbackWithObjectAttributesIsDeprecated()
34-
{
35-
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo'));
36-
$request = Request::create('/');
37-
$reference = new ControllerReference('main_controller', array('foo' => array('a' => array(), 'b' => new \stdClass())), array());
38-
$strategy->render($reference, $request);
39-
}
40-
4129
public function testRender()
4230
{
4331
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy());

‎src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
-18Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,6 @@ public function testHandleHttpException()
111111
$this->assertEquals('POST', $response->headers->get('Allow'));
112112
}
113113

114-
/**
115-
* @group legacy
116-
* @dataProvider getStatusCodes
117-
*/
118-
public function testLegacyHandleWhenAnExceptionIsHandledWithASpecificStatusCode($responseStatusCode, $expectedStatusCode)
119-
{
120-
$dispatcher = new EventDispatcher();
121-
$dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) use ($responseStatusCode, $expectedStatusCode) {
122-
$event->setResponse(new Response('', $responseStatusCode, array('X-Status-Code' => $expectedStatusCode)));
123-
});
124-
125-
$kernel = $this->getHttpKernel($dispatcher, function () { throw new \RuntimeException(); });
126-
$response = $kernel->handle(new Request());
127-
128-
$this->assertEquals($expectedStatusCode, $response->getStatusCode());
129-
$this->assertFalse($response->headers->has('X-Status-Code'));
130-
}
131-
132114
public function getStatusCodes()
133115
{
134116
return array(

‎src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/KernelTest.php
-19Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -717,25 +717,6 @@ public function testKernelRootDirNameStartingWithANumber()
717717
$this->assertEquals('_123', $kernel->getName());
718718
}
719719

720-
/**
721-
* @group legacy
722-
* @expectedDeprecation The Symfony\Component\HttpKernel\Kernel::getEnvParameters() method is deprecated as of 3.3 and will be removed in 4.0. Use the %cenv()%c syntax to get the value of any environment variable from configuration files instead.
723-
* @expectedDeprecation The support of special environment variables that start with SYMFONY__ (such as "SYMFONY__FOO__BAR") is deprecated as of 3.3 and will be removed in 4.0. Use the %cenv()%c syntax instead to get the value of environment variables in configuration files.
724-
*/
725-
public function testSymfonyEnvironmentVariables()
726-
{
727-
$_SERVER['SYMFONY__FOO__BAR'] = 'baz';
728-
729-
$kernel = $this->getKernel();
730-
$method = new \ReflectionMethod($kernel, 'getEnvParameters');
731-
$method->setAccessible(true);
732-
733-
$envParameters = $method->invoke($kernel);
734-
$this->assertSame('baz', $envParameters['foo.bar']);
735-
736-
unset($_SERVER['SYMFONY__FOO__BAR']);
737-
}
738-
739720
/**
740721
* Returns a mock for the BundleInterface.
741722
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.