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

Skip to content

Commit da376d9

Browse files
committed
feature #22886 [HttpKernel] remove deprecated features (xabbuh)
This PR was merged into the 4.0-dev branch. Discussion ---------- [HttpKernel] remove deprecated features | Q | A | ------------- | --- | Branch? | master | Bug fix? | /no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 4d522d3 [HttpKernel] remove deprecated features
2 parents 7263d77 + 4d522d3 commit da376d9

File tree

11 files changed

+27
-310
lines changed

11 files changed

+27
-310
lines changed

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines 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

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

1212
namespace Symfony\Component\HttpKernel\DataCollector;
1313

14-
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
1514
use Symfony\Component\VarDumper\Caster\ClassStub;
1615
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
1716
use Symfony\Component\VarDumper\Cloner\Data;
@@ -29,11 +28,6 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
2928
{
3029
protected $data = array();
3130

32-
/**
33-
* @var ValueExporter
34-
*/
35-
private $valueExporter;
36-
3731
/**
3832
* @var ClonerInterface
3933
*/
@@ -62,42 +56,14 @@ public function unserialize($data)
6256
protected function cloneVar($var)
6357
{
6458
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();
59+
if (!class_exists(ClassStub::class)) {
60+
throw new \LogicException(sprintf('The VarDumper component is needed for the %s() method. Install symfony/var-dumper version 3.2 or above.', __METHOD__));
7661
}
7762

78-
return $this->valueExporter->exportValue($var);
63+
self::$cloner = new VarCloner();
64+
self::$cloner->setMaxItems(-1);
7965
}
8066

8167
return self::$cloner->cloneVar($var);
8268
}
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-
}
10369
}

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

Lines changed: 0 additions & 99 deletions
This file was deleted.

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

Lines 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

Lines 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

Lines 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

Lines changed: 0 additions & 51 deletions
This file was deleted.

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

Lines 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/Fragment/InlineFragmentRendererTest.php

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

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpFoundation\RequestStack;
16-
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
17-
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
1816
use Symfony\Component\HttpKernel\Controller\ControllerReference;
1917
use Symfony\Component\HttpKernel\HttpKernel;
2018
use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer;
@@ -53,27 +51,6 @@ public function testRenderWithObjectsAsAttributes()
5351
$this->assertSame('foo', $strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/'))->getContent());
5452
}
5553

56-
/**
57-
* @group legacy
58-
*/
59-
public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController()
60-
{
61-
$resolver = $this->getMockBuilder(ControllerResolverInterface::class)->getMock();
62-
$resolver
63-
->expects($this->once())
64-
->method('getController')
65-
->will($this->returnValue(function (\stdClass $object, Bar $object1) {
66-
return new Response($object1->getBar());
67-
}))
68-
;
69-
70-
$kernel = new HttpKernel(new EventDispatcher(), $resolver, new RequestStack(), new ArgumentResolver());
71-
$renderer = new InlineFragmentRenderer($kernel);
72-
73-
$response = $renderer->render(new ControllerReference('main_controller', array('object' => new \stdClass(), 'object1' => new Bar()), array()), Request::create('/'));
74-
$this->assertEquals('bar', $response->getContent());
75-
}
76-
7754
public function testRenderWithTrustedHeaderDisabled()
7855
{
7956
Request::setTrustedProxies(array(), 0);

0 commit comments

Comments
 (0)