8000 [Console] Fixed: Trying to access array offset on value of type int · symfony/symfony@96c0d47 · GitHub
[go: up one dir, main page]

Skip to content

Commit 96c0d47

Browse files
eskylakenicolas-grekas
authored andcommitted
[Console] Fixed: Trying to access array offset on value of type int
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.
1 parent 5cacc5d commit 96c0d47

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Console/Input/ArrayInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function __toString()
107107
{
108108
$params = [];
109109
foreach ($this->parameters as $param => $val) {
110-
if ($param && '-' === $param[0]) {
110+
if ($param && '-' === ($param[0] ?? $param)) {
111111
if (\is_array($val)) {
112112
foreach ($val as $v) {
113113
$params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');

0 commit comments

Comments
 (0)
0