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

add assertion to compare arbitrary versions and to compare PHP versions. #203

Merged
merged 1 commit into from
Jan 5, 2017
Merged

add assertion to compare arbitrary versions and to compare PHP versions. #203

merged 1 commit into from
Jan 5, 2017

Conversation

abacaphiliac
Copy link
Contributor

this request adds assertions to compare versions, and a helper for PHP version specifically. i'm working on another request to assert extension versions, but am running into HHVM issues so that helper will have to wait.

of particular interest is my opinionated requirement of the $operator param. PHP's version_compare method does not require it, which changes the output/behavior of the method. i am not a fan of ambiguity so internally my new assertion asserts that $operator is not empty. i am open to suggestions. maybe my opinion is not so great : )

}

/**
* Assert that extension is loaded.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cut and paste error!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh!

*/
public static function version($version1, $operator, $version2, $message = null, $propertyPath = null)
{
Assertion::notEmpty($operator, 'versionCompare operator is required and cannot be empty.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use static:: otherwise unable to extend.

*/
public static function phpVersion($operator, $version, $message = null, $propertyPath = null)
{
self::defined('PHP_VERSION');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use static:: here and below.

@abacaphiliac
Copy link
Contributor Author

depends on #204

@rquadling rquadling merged commit 93d6af4 into beberlei:master Jan 5, 2017
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