Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bug #34632 [Console] Fix trying to access array offset on value of ty…
…pe int (Tavafi)

This PR was merged into the 3.4 branch.

Discussion
----------

[Console] Fix trying to access array offset on value of type int

| Q             | A
| ------------- | ---
| Branch?       | 5.0
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
|Tests pass?| yes
| License       | MIT

PHP 7.4 throws an error exception when you are trying to access an array by an integer key.
I got this error while I was running a console command:

```
ErrorException: Trying to access array offset on value of type int
at /my/project/vendor/symfony/console/Input/ArrayInput.php:110

Exception trace:
/my/project/vendor/symfony/console/Input/ArrayInput.php:110
/my/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
/my/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
/my/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
/my/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
/my/project/vendor/laravel/framework/src/Illuminate/Container/Container.php:564
/my/project/vendor/laravel/framework/src/Illuminate/Console/Command.php:179
/my/project/vendor/symfony/console/Command/Command.php:255
/my/project/vendor/laravel/framework/src/Illuminate/Console/Command.php:166
/my/project/vendor/symfony/console/Application.php:934
/my/project/vendor/symfony/console/Application.php:273
/my/project/vendor/symfony/console/Application.php:149
/my/project/vendor/laravel/framework/src/Illuminate/Console/Application.php:89
/my/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122
/my/project/artisan:37

```

Commits
-------

069d214 [Console] Fix trying to access array offset on value of type int
  • Loading branch information
nicolas-grekas committed Nov 28, 2019
2 parents 5cacc5d + 069d214 commit e23fd9e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/Console/Input/ArrayInput.php
Expand Up @@ -39,8 +39,8 @@ public function __construct(array $parameters, InputDefinition $definition = nul
*/
public function getFirstArgument()
{
foreach ($this->parameters as $key => $value) {
if ($key && '-' === $key[0]) {
foreach ($this->parameters as $param => $value) {
if ($param && \is_string($param) && '-' === $param[0]) {
continue;
}

Expand Down Expand Up @@ -107,7 +107,7 @@ public function __toString()
{
$params = [];
foreach ($this->parameters as $param => $val) {
if ($param && '-' === $param[0]) {
if ($param && \is_string($param) && '-' === $param[0]) {
if (\is_array($val)) {
foreach ($val as $v) {
$params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
Expand Down

0 comments on commit e23fd9e

Please sign in to comment.