yii2-materializecss icon indicating copy to clipboard operation
yii2-materializecss copied to clipboard

PHP 8 compatibility issue

Open mpasang opened this issue 4 years ago • 3 comments

Unparenthesized a ? b : c ? d : e is not supported in PHP 8. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e) in https://github.com/MacGyer/yii2-materializecss/blob/3fb85450e72ad0458c60e7f46a9a8e42989e90af/src/widgets/form/SwitchButton.php#L155

mpasang avatar Oct 12 '21 09:10 mpasang

It should be $this->inputOptions['uncheck'] = isset($this->uncheck) ? $this->uncheck : (is_null($this->uncheck) ? null : '0'); Kindly update. Thanks!

mpasang avatar Oct 12 '21 10:10 mpasang

Hey @mpasang,

thanks for reporting the issue.

I think, the whole expression is somewhat over the top. As its purpose is to use either the value of $this->uncheck or set it to '0' I would prefer to write it as follows:

$this->inputOptions['uncheck'] = isset($this->uncheck) ? $this->uncheck : '0'

Would you mind testing this solution? Thanks

MacGyer avatar Oct 28 '21 18:10 MacGyer

I agree @MacGyer . That definitely works and is much more accepted. I just added the parentheses in the existing line to get over with the unsupported PHP 8 case.

Thanks for getting back to me. When will the fix be available then for release?

mpasang avatar Oct 29 '21 05:10 mpasang

fixed in https://github.com/MacGyer/yii2-materializecss/releases/tag/4.0.0-RC1

MacGyer avatar Nov 27 '22 16:11 MacGyer