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

Fixing bug in isPHPVersionMoreRecentThan #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BenFunnelFuel
Copy link

If the installed version is 8.1, and the function is called with the string 7.4, it should return true because 8.1 is more recent than 7.4. however it returns false, because the first conditional check fails, so we fall through to the second conditional (the elseif).

The problem with this second conditional is that it only examines the minor version, not taking into account the major version. So in our example, it compares 1 to 4. Since 1 is less than 4, this condition succeeds, and the function returns false.

This fix also simplifies the function by using a native PHP method that is purpose built for this use case

… certain version threshold. This not only simplifies the function by using a native PHP method purpose built for this use case, but it also fixes a bug with the implementation. If the installed version is 8.1, and the function is called with the string 7.4, it should return true because 8.1 is more recent than 7.4. however it returns false, because the first conditional check fails, so we fall through to the second conditional (the elseif). The problem with this second conditional is that it only examines the minor version, not taking into account the major version. So in our example, it compares 1 to 4. Since 1 is less than 4, this condition succeeds, and the function returns false.
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

Successfully merging this pull request may close these issues.

2 participants