laravel / tinker

Powerful REPL for the Laravel framework.
https://laravel.com/docs/artisan#tinker
MIT License
7.32k stars 130 forks source link

Use psysh with Semicolon for more compatibility #162

Closed victorelec14 closed 1 year ago

victorelec14 commented 1 year ago

I Tink that this MR will give more compatibility between Psysh and Laravel / Pint by allowing the brackets to be on a new line.

In itself, that is not a problem from Psysh as @bobthecow explained in this post:

https://github.com/laravel/tinker/issues/161#issuecomment-1481037313

This MR has breaking changes that will make semicolons mandatory in Tinker, but it's something we're used to by now.

User::all()

It will always have to be with a semicolon at the end

User::all();

The list of Psysh options is here: https://github.com/bobthecow/psysh/wiki/Config-options#-config-options

Test Data:

$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

taylorotwell commented 1 year ago

I don't want semicolons to be mandatory?

bobthecow commented 1 year ago

This is very much a matter of user preference and should be specified by users, not by the framework. The defaults are good 🙂