8000 Fixes more deprecation notices. · symfony/symfony@97efd2c · GitHub
[go: up one dir, main page]

Skip to content

Commit 97efd2c

Browse files
author
Hugo Hamon
committed
Fixes more deprecation notices.
1 parent fd9c7bb commit 97efd2c

File tree

5 files changed

+49
-14
lines changed

5 files changed

+49
-14
lines changed

src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct(Profiler $profiler, RequestMatcherInterface $matcher
5353
// Prevent the deprecation notice to be triggered all the time.
5454
// The onKernelRequest() method fires some logic only when the
5555
// RequestStack instance is not provided as a dependency.
56-
trigger_error('The '.__CLASS__.'::onKernelRequest method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);
56+
trigger_error('Since version 2.4, the '.__METHOD__.' method must accept a RequestStack instance to get the request instead of using the '.__CLASS__.'::onKernelRequest method that will be removed in 3.0.', E_USER_DEPRECATED);
5757
}
5858

5959
$this->profiler = $profiler;

src/Symfony/Component/HttpKernel/EventListener/RouterListener.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public function __construct($matcher, RequestContext $context = null, LoggerInte
6767
throw new \InvalidArgumentException('You must either pass a RequestContext or the matcher must implement RequestContextAwareInterface.');
6868
}
6969

70+
if (!$requestStack instanceof RequestStack) {
71+
trigger_error('The '.__METHOD__.' method now requires a RequestStack instance as '.__CLASS__.'::setRequest method will not be supported anymore in 3.0.');
72+
}
73+
7074
$this->matcher = $matcher;
7175
$this->context = $context ?: $matcher->getContext();
7276
$this->requestStack = $requestStack;
@@ -88,9 +92,15 @@ public function setRequest(Request $request = null)
8892
{
8993
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be made private in 3.0.', E_USER_DEPRECATED);
9094

95+
$this->setCurrentRequest($request);
96+
}
97+
98+
private function setCurrentRequest(Request $request = null)
99+
{
91100
if (null !== $request && $this->request !== $request) {
92101
$this->context->fromRequest($request);
93102
}
103+
94104
$this->request = $request;
95105
}
96106

@@ -100,19 +110,19 @@ public function onKernelFinishRequest(FinishRequestEvent $event)
100110
return; // removed when requestStack is required
101111
}
102112

103-
$this->setRequest($this->requestStack->getParentRequest());
113+
$this->setCurrentRequest($this->requestStack->getParentRequest());
104114
}
105115

106116
public function onKernelRequest(GetResponseEvent $event)
107117
{
108118
$request = $event->getRequest();
109119

110120
// initialize the context that is also used by the generator (assuming matcher and generator share the same context instance)
111-
// we call setRequest even if most of the time, it has already been done to keep compatibility
121+
// we call setCurrentRequest even if most of the time, it has already been done to keep compatibility
112122
// with frameworks which do not use the Symfony service container
113123
// when we have a RequestStack, no need to do it
114124
if (null !== $this->requestStack) {
115-
$this->setRequest($request);
125+
$this->setCurrentRequest($request);
116126
}
117127

118128
if ($request->attributes->has('_controller')) {

src/Symfony/Component/Validator/Validator/LegacyValidator.php

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

1212
namespace Symfony\Component\Validator\Validator;
1313

14-
trigger_error('The '.__NAMESPACE__.'\LegacyValidator class is deprecated since version 2.5 and will be removed in 3.0. Use the Symfony\Component\Validator\RecursiveValidator class instead.', E_USER_DEPRECATED);
15-
1614
use Symfony\Component\Validator\Constraint;
1715
use Symfony\Component\Validator\Constraints\GroupSequence;
1816
use Symfony\Component\Validator\Constraints\Valid;
@@ -54,7 +52,7 @@ public function validate($value, $groups = null, $traverse = false, $deep = fals
5452
return parent::validate($value, $constraints, $groups);
5553
}
5654

57-
trigger_error('Symfony\\Component\\Validator\\ValidatorInterface::validate() was deprecated in version 2.5 and will be removed in version 3.0. Please use Symfony\\Component\\Validator\\Validator\\ValidatorInterface::validate() instead.', E_USER_DEPRECATED);
55+
trigger_error('The Symfony\Component\Validator\Validator\ValidatorInterface::validate method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED);
5856

5957
$constraint = new Valid(array('traverse' => $traverse, 'deep' => $deep));
6058

@@ -63,13 +61,15 @@ public function validate($value, $groups = null, $traverse = false, $deep = fals
6361

6462
public function validateValue($value, $constraints, $groups = null)
6563
{
66-
trigger_error('Symfony\\Component\\Validator\\ValidatorInterface::validateValue() was deprecated in version 2.5 and will be removed in version 3.0. Please use Symfony\\Component\\Validator\\Validator\\ValidatorInterface::validate() instead.', E_USER_DEPRECATED);
64+
trigger_error('The Symfony\Component\Validator\Validator\ValidatorInterface::validateValue method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED);
6765

6866
return parent::validate($value, $constraints, $groups);
6967
}
7068

7169
public function getMetadataFactory()
7270
{
71+
trigger_error('The Symfony\Component\Validator\Validator\ValidatorInterface::getMetadataFactory method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED);
72+
7373
return $this->metadataFactory;
7474
}
7575

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Symfony\Component\Yaml\Deprecated;
4+
5+
trigger_error('Constant ENCODING in class Symfony\Component\Yaml\Unescaper is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
6+
7+
/**
8+
* @deprecated since version 2.7, to be removed in 3.0.
9+
* @internal
10+
*/
11+
final class Unescaper
12+
{
13+
const ENCODING = 'UTF-8';
14+
15+
private function __construct()
16+
{
17+
18+
}
19+
}

src/Symfony/Component/Yaml/Unescaper.php

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

1212
namespace Symfony\Component\Yaml;
1313

14+
use Symfony\Component\Yaml\Deprecated\Unescaper as Deprecated;
15+
1416
/**
1517
* Unescaper encapsulates unescaping rules for single and double-quoted
1618
* YAML strings.
@@ -19,13 +21,17 @@
1921
*/
2022
class Unescaper
2123
{
22-
// Parser and Inline assume UTF-8 encoding, so escaped Unicode characters
23-
// must be converted to that encoding.
24-
// @deprecated since version 2.5, to be removed in 3.0
25-
const ENCODING = 'UTF-8';
24+
/**
25+
* Parser and Inline assume UTF-8 encoding, so escaped Unicode characters
26+
* must be converted to that encoding.
27+
*
28+
* @deprecated since version 2.5, to be removed in 3.0
29+
*/
30+
const ENCODING = Deprecated::ENCODING;
2631

27-
// Regex fragment that matches an escaped character in a double quoted
28-
// string.
32+
/**
33+
* Regex fragment that matches an escaped character in a double quoted string.
34+
*/
2935
const REGEX_ESCAPED_CHARACTER = "\\\\([0abt\tnvfre \\\"\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})";
3036

3137
/**

0 commit comments

Comments
 (0)
0