8000 bug #20415 [DI][Serializer] Add missing deprecations (nicolas-grekas) · symfony/symfony@5bd3a00 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5bd3a00

Browse files
committed
bug #20415 [DI][Serializer] Add missing deprecations (nicolas-grekas)
This PR was merged into the 3.2-dev branch. Discussion ---------- [DI][Serializer] Add missing deprecations | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 90ba197 [DI][Serializer] Add missing deprecations
2 parents a559036 + 90ba197 commit 5bd3a00

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

src/Symfony/Component/DependencyInjection/Compiler/Compiler.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,18 @@ public function getLoggingFormatter()
7070
* @param string $type The type of the pass
7171
* @param int $priority Used to sort the passes
7272
*/
73-
public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION/**, $priority = 0*/)
73+
public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION/*, $priority = 0*/)
7474
{
75-
// For BC
7675
if (func_num_args() >= 3) {
7776
$priority = func_get_arg(2);
7877
} else {
78+
if (__CLASS__ !== get_class($this)) {
79+
$r = new \ReflectionMethod($this, __FUNCTION__);
80+
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
81+
@trigger_error(sprintf('Method %s() will have a third `$priority = 0` argument in version 4.0. Not defining it is deprecated since 3.2.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
82+
}
83+
}
84+
7985
$priority = 0;
8086
}
8187

src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,16 @@ public function getPasses()
9696
*/
9797
public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION/*, $priority = 0*/)
9898
{
99-
// For BC
10099
if (func_num_args() >= 3) {
101100
$priority = func_get_arg(2);
102101
} else {
102+
if (__CLASS__ !== get_class($this)) {
103+
$r = new \ReflectionMethod($this, __FUNCTION__);
104+
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
105+
@trigger_error(sprintf('Method %s() will have a third `$priority = 0` argument in version 4.0. Not defining it is deprecated since 3.2.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
106+
}
107+
}
108+
103109
$priority = 0;
104110
}
105111

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,8 @@ public function loadFromExtension($extension, array $values = array())
310310
*
311311
* @return ContainerBuilder The current instance
312312
*/
313-
public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION/**, $priority = 0*/)
313+
public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION/*, $priority = 0*/)
314314
{
315-
// For BC
316315
if (func_num_args() >= 3) {
317316
$priority = func_get_arg(2);
318317
} else {

src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,18 @@ protected function getConstructor(array &$data, $class, array &$context, \Reflec
289289
*/
290290
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes/*, $format = null*/)
291291
{
292-
$format = func_num_args() >= 6 ? func_get_arg(5) : null;
292+
if (func_num_args() >= 6) {
293+
$format = func_get_arg(5);
294+
} else {
295+
if (__CLASS__ !== get_class($this)) {
296+
$r = new \ReflectionMethod($this, __FUNCTION__);
297+
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
298+
@trigger_error(sprintf('Method %s() will have a 6th `$format = null` argument in version 4.0. Not defining it is deprecated since 3.2.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
299+
}
300+
}
301+
302+
$format = null;
303+
}
293304

294305
if (
295306
isset($context[static::OBJECT_TO_POPULATE]) &&

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ protected function isAllowedAttribute($classOrObject, $attribute, $format = null
5959
return in_array($attribute, array('foo', 'baz'));
6060
}
6161

62-
public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
62+
public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, $format = null)
6363
{
64-
return parent::instantiateObject($data, $class, $context, $reflectionClass, $allowedAttributes);
64+
return parent::instantiateObject($data, $class, $context, $reflectionClass, $allowedAttributes, $format);
6565
}
6666
}
6767

0 commit comments

Comments
 (0)
0