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

isPHPVersionMoreRecentThan($version) function is completely broken #32

Open
natehouk opened this issue Dec 30, 2022 · 0 comments
Open

Comments

@natehouk
Copy link

natehouk commented Dec 30, 2022

This code simply doesn't work and is functionally broken. It will compare 8.0.0 to 7.4.0 and return FALSE when it should return TRUE.

I will work on a PR, but in the meantime as a workaround it is easier to just remove the use of this function from the code if you know you are running a PHP version >8.0.0

edit: looks like a PR has already been created with the fix. Needs to be merged.

	/**
	 * A private methode to save the company details in the DB.
	 *
	 * @param mixed $version
	 *
	 * @return bool
	 */
	private function isPHPVersionMoreRecentThan($version)
	{
		$phpVersion = PHP_VERSION;
		$phpVersionParts = explode('.', $phpVersion);
		$phpMinVersionParts = explode('.', $version);

		if ((int) $phpVersionParts[0] < (int) $phpMinVersionParts[0]) {
			return false;
		} elseif ((int) $phpVersionParts[1] < (int) $phpMinVersionParts[1]) {
			return false;
		} elseif ((int) $phpVersionParts[2] < (int) $phpMinVersionParts[2]) {
			return false;
		}

		return true;
	}
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

1 participant