Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #76

Merged
merged 1 commit into from
Mar 22, 2023
Merged

Update README.md #76

merged 1 commit into from
Mar 22, 2023

Conversation

undersound
Copy link
Contributor

@undersound undersound commented Mar 22, 2023

When using the example from the readme
Ssh::create('user', 'host')->onOutput(fn($type, $line) => echo $line)->execute('whoami');

I am getting the following error
Parse error: syntax error, unexpected token "echo"

When using the following syntax it works
Ssh::create('user', 'host')->onOutput(function($type, $line) {echo $line;})->execute('whoami');

When using the example from the readme
Ssh::create('user', 'host')->onOutput(fn($type, $line) => echo $line)->execute('whoami');

I am getting the following error 
Parse error: syntax error, unexpected token "echo"

When using the following syntax it works
Ssh::create('user', 'host')->onOutput(function($type, $line) {echo $line;})->execute('whoami');
@freekmurze
Copy link
Member

ThE current syntax is valid in PHP 7.4 and above

@freekmurze freekmurze closed this Mar 22, 2023
@undersound
Copy link
Contributor Author

It is valid syntax but it still complains https://3v4l.org/ai9XS#v7.4.33
Any idea why? Seems it nags about using echo

@freekmurze freekmurze reopened this Mar 22, 2023
@freekmurze
Copy link
Member

Ah, it's because a short closure tries to return something and it can't do that with the echo

So, you were right, the current syntax is invalid.

Thanks for the fix!

@freekmurze freekmurze merged commit fac1a97 into spatie:main Mar 22, 2023
@undersound undersound deleted the patch-1 branch March 22, 2023 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants