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

'??' operator used in AccessTokenController@issueToken() (no support in PHP 5.X) #10

Closed
DCdeBrabander opened this issue Dec 7, 2016 · 9 comments

Comments

@DCdeBrabander
Copy link

DCdeBrabander commented Dec 7, 2016

In \dusterio\lumen-passport\src\Http\Controllers\AccessTokenController@issueToken() r. 26 is written the following:
$clientId = ((array) $request->getParsedBody())['client_id'] ?? null;

Which is introduced in last commit:
256aece

The ?? operator isn't supported in PHP versions lower then PHP 7, since it is introduced in PHP 7.0:
http://php.net/manual/en/migration70.new-features.php

Therefor the package is crashing instantly when calling (for example): POST /oauth/token endpoints

Suggested fix, something in line of:
$clientId = !is_null($request->getParsedBody()) ? $request->getParsedBody()['client_id'] : null;

or increasing 'minimum supported php' to version 7 😄

@dusterio
Copy link
Owner

dusterio commented Dec 7, 2016

Thanks for spotting this! I'm so used to PHP7 features, I completely forgot about this :) I fixed it just now

@dusterio dusterio closed this as completed Dec 7, 2016
@DCdeBrabander
Copy link
Author

DCdeBrabander commented Dec 7, 2016

moved to new issue

@paolopiccinini
Copy link

paolopiccinini commented Dec 8, 2016

Hi @dusterio there is another error now in Dusterio\LumenPassport\Http\Controllers\AccessTokenController.php line 27

$clientId = array_key_exists('client_id', (array) $request->getParsedBody()) ? ((array) $request->getParsedBody())['client_id'] : null;

this is giving syntax error, unexpected '['at line 27 col 17.

Maybe you would do this:

$parsedBody = (array) $request->getParsedBody(); $clientId = array_key_exists('client_id', (array) $request->getParsedBody()) ? $parsedBody['client_id'] : null;

@dusterio
Copy link
Owner

dusterio commented Dec 8, 2016 via email

@paolopiccinini
Copy link

also i think it's correct but i'm getting this:
error
do you know why?

@dusterio
Copy link
Owner

It seems that PHP 5.5 doesn't allow to cast a variable to an array and get one value in one line :( I'll fix this for old PHP shortly

@paolopiccinini
Copy link

i'm using PHP 5.6.25. Maybe it's time to upgrade. :)

@dusterio
Copy link
Owner

It definitely is! :) It's so much faster and new extra features are very helpful

@DCdeBrabander
Copy link
Author

Lumen needs PHP 5.6.4 installed so there is no reason for supporting 5.5.x :
https://lumen.laravel.com/docs/5.3

also https://github.com/dusterio/lumen-passport says 5.6.3?

Really there is no point in supporting 5.5

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

No branches or pull requests

3 participants