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

Fatal error with php 7.4RC3 #286

Closed
kumy opened this issue Oct 5, 2019 · 5 comments
Closed

Fatal error with php 7.4RC3 #286

kumy opened this issue Oct 5, 2019 · 5 comments

Comments

@kumy
Copy link
Contributor

kumy commented Oct 5, 2019

A fatal error is returned when loading f3 with php 7.4RC3.

Fatal error: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`

Step to reproduce

$ docker run --rm -it php:7.4.0RC3-cli-alpine sh
/ # mkdir f3; cd f3

/f3 # cat <<'EOF' > index.php
<?php
require __DIR__.'/vendor/autoload.php';
$f3 = \Base::instance();
$f3->route('/', function (){echo 'Hello';});
$f3->run();
EOF

/f3 # php index.php 
Fatal error: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`

/f3 # php --version
PHP 7.4.0RC3 (cli) (built: Oct  4 2019 21:53:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies

Notes
No line number is returned by php, but seems to happens there https://github.com/bcosca/fatfree-core/blob/master/base.php#L993-L995.

It don't know the legacy php <= 7.3 behavior. How should it be fixed?

(isset($prop) ? $prop : $frac) ? strlen($frac)-2 : 0
or
isset($prop) ? $prop : ($frac ? strlen($frac)-2 : 0)
@Rayne
Copy link
Member

Rayne commented Oct 5, 2019

I thought that we already fixed another PHP 7.4-RC issue but was not able to find one. Which F3 version are you using? I'll have a look.

The relevant section in the manual: Ternary Operator.

@kumy
Copy link
Contributor Author

kumy commented Oct 5, 2019

I'm on 3.6.5

$ composer show|grep fatfree
bcosca/fatfree-core                3.6.5              A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

@kumy
Copy link
Contributor Author

kumy commented Oct 5, 2019

According to the Example #4 Non-obvious Ternary Behaviour from your link, the fix shoud be:
(isset($prop) ? $prop : $frac) ? strlen($frac)-2 : 0

Would you like a PR?

@Rayne
Copy link
Member

Rayne commented Oct 5, 2019

The bug is no longer present in the master branch. The bug is already fixed but is not part of a stable release: bcosca/fatfree#1142

@kumy
Copy link
Contributor Author

kumy commented Oct 5, 2019

Ho you're right, just discovered the parenthesis in master branch! BTW I naivelly have put the parenthesis the other way, but I've not tested anything.

Sorry to make you loose your time.

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

2 participants