bobthecow/psysh

Loop only returns the last value if the curly brackets start on a new line

victorelec14 opened this issue · 1 comments

  • Psy Shell v0.11.12 (PHP 8.1.10 — cli) by Justin Hileman

Description:

psysh displays only the last value of a loop if the curly backet starts in new line

Steps To Reproduce:

$data = [
    "1111",
    "2222",
    "3333",
    "4444",
];
foreach ($data as $pos)
{
    echo $pos . "\n";
}

Result:

4444

Now with the curly backet in the same line of the foreach

$data = [
    "1111",
    "2222",
    "3333",
    "4444",
];
foreach ($data as $pos){
    echo $pos . "\n";
}`

Result :

1111
2222
3333
4444

Thanks

Related: laravel/tinker#161

Oh, I just left a comment explaining it on laravel/tinker#161 (comment) 😛