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

Application bootstrap: fix version check #100

Merged
merged 2 commits into from
Mar 3, 2022

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Mar 1, 2022

Allow version check in application entry file to work

As reported in #62, the "version check" for PHP < 5.3 in the application bootstrap did not work as the code in file would cause a parse error when run on PHP < 5.3.

By putting the class name, which contains PHP 5.3 namespace separator tokens, as a variable and then dynamically calling the class, the parse error on PHP < 5.3 is prevented and the version check at the top of the file can work as expected.

Fixes #62

Note: this is not something which can really be unit tested as this concerns the application bootstrap file. An integration test would be an option, but then, this integration test would need to be run against PHP 5.2 (or lower) in a workflow.
Adding a setup for this is outside the scope of this PR.

Make the version check more informative

Previously, the PHP version check run at the start of the script would display PHP Parallel Lint requires PHP 5.3.0 or newer. if the PHP version was too low.

The message has been updated to include the currently detected PHP version and the path to the PHP binary.

Note: both constants used are available in PHP cross-version

Testing the PR

  • On PHP 5.2, with develop or master: try to run the parallel-lint command and see it fail with a parse error.
  • Switch to this branch.
  • Try running the parallel-lint command again and see it fail with an informative error message saying that "PHP Parallel Lint requires PHP 5.3.o or newer"

jrfnl added 2 commits March 1, 2022 17:57
By putting the class name, which contains PHP 5.3 namespace separator tokens, as a variable and then dynamically calling the class, the parse error on PHP < 5.3 is prevented and the version check at the top of the file can work as expected.

Fixes 62
Previously, the PHP version check run at the start of the script would display `PHP Parallel Lint requires PHP 5.3.0 or newer.` if the PHP version was too low.

The message has been updated to include the currently detected PHP version and the path to the PHP binary.

Note: both constants used are available in PHP cross-version.
@jrfnl jrfnl added the Type: bug label Mar 1, 2022
@jrfnl jrfnl added this to the 2.0.0 milestone Mar 1, 2022
@jrfnl jrfnl requested a review from grogy March 1, 2022 17:11
@grogy grogy merged commit 36233b2 into develop Mar 3, 2022
@grogy grogy deleted the feature/62-fix-version-check branch March 3, 2022 14:57
@grogy
Copy link
Member

grogy commented Mar 3, 2022

Thank you, this is elegant solution :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

PHP version check at start of file doesn't work
2 participants