bug #30992 [TwigBridge][DependencyInjection] ignore null arguments (xabbuh)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[TwigBridge][DependencyInjection] ignore null arguments

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

44eb7a0485 fix backwards compatibility breaks
This commit is contained in:
Fabien Potencier 2019-04-08 07:15:29 +02:00
commit 02e865b298
2 changed files with 6 additions and 2 deletions

View File

@ -47,7 +47,7 @@ class HttpFoundationExtension extends AbstractExtension
$requestContext = null;
if (2 === \func_num_args()) {
$requestContext = \func_get_arg(1);
if (!$requestContext instanceof RequestContext) {
if (null !== $requestContext && !$requestContext instanceof RequestContext) {
throw new \TypeError(sprintf('The second argument must be an instance of "%s".', RequestContext::class));
}
}

View File

@ -53,6 +53,10 @@ final class BoundArgument implements ArgumentInterface
*/
public function setValues(array $values)
{
list($this->value, $this->identifier, $this->used, $this->type, $this->file) = $values;
if (5 === count($values)) {
list($this->value, $this->identifier, $this->used, $this->type, $this->file) = $values;
} else {
list($this->value, $this->identifier, $this->used) = $values;
}
}
}