LibreBooking / app

Repository for the last open source version of Booked Scheduler. The "develop" branch contains the most current working code of the project and should be considered beta. The "master" branch is the most current stable release of BookedScheduler. Please read doc/README.md for further details.
GNU General Public License v3.0
398 stars 237 forks source link

PHP Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) - lib/Config/Configuration.php (VERSION variable) #117

Open larjona opened 2 years ago

larjona commented 2 years ago

Hello, thanks for keeping this project alive. I have updated a 2.7.x instance to 2.8.5.5 and got the following error:

PHP Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /var/www/html/lib/Config/Configuration.php on line 84, referer: https://example.com/Web/view-schedule.php?sid=13&sd=2022-05-16

I have seen that commit "PSR12 Compliance" https://github.com/effgarces/BookedScheduler/commit/0f7d1c1a4da4d7663c09f60394f2f2fff5be92a7 changes: const VERSION = '2.8.5.4'; to public const VERSION = '2.8.5.4';

I have reverted this variable VERSION to "const" (removed the word "public") in my local instance, and could finish the upgrade and everything seems to work ok.

I'm not submitting a pull request with this change because I don't know if that is the correct fix to this issue.

Kind regards

larjona commented 2 years ago

Forgot to say that this happens in a Debian 9 server (LTS) with the standard php provided (7.0.x). I didn't try in newer OS or PHP versions.

larjona commented 2 years ago

It seems that the "public const VERSION = '2.8.5.4';" line only works from PHP 7.1 or newer: https://www.php.net/manual/en/language.oop5.constants.php So maybe the correct way to fix this issue is to set 7.1 as the minimum PHP version in the documentation? (or remove the "public" part since default visibility for const is public anyway).