Skip to content

Commit

Permalink
[Console] Fixed: Trying to access array offset on value of type int
Browse files Browse the repository at this point in the history
PHP 7.4 throws an error exception when you are accessing an array offset of a value of type int.
There is an if statement inside the __toString() method of the \Symfony\Component\Console\Input\ArrayInput class that checks the first key of each given parameter to the console command.
It throws an ErrorException with the message: Trying to access array offset on value of type int, because of integer keys of the parameters property of the class.
This modification checks and returns the first key of the parameter if PHP can access to it or, it returns the parameter's key itself.
  • Loading branch information
eskylake authored and nicolas-grekas committed Nov 28, 2019
1 parent 5cacc5d commit 96c0d47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Input/ArrayInput.php
Expand Up @@ -107,7 +107,7 @@ public function __toString()
{
$params = [];
foreach ($this->parameters as $param => $val) {
if ($param && '-' === $param[0]) {
if ($param && '-' === ($param[0] ?? $param)) {
if (\is_array($val)) {
foreach ($val as $v) {
$params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
Expand Down

0 comments on commit 96c0d47

Please sign in to comment.