webmozarts / assert

Assertions to validate method input/output with nice error messages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Renaming greaterThan(Eq) 2nd argument

helsner opened this issue · comments

Currently the function has $limit as second argument name.
This is not wrong but could IMHO be improved into something like "minLimit" or "min" to clarify the usage of the function.
As the greaterThan and lessThan functions both share the same order of arguments but acting the opposite way a support via naming it differently.

This is just a proposal - eventually the majority of people have a different view.

As the greaterThan and lessThan functions both share the same order of arguments but acting the opposite way a support via naming it differently.

The method name is a clear way to separate them =)

Assert::greaterThan($number, 5).

If this was suggested when we first added greaterThan(), greaterThanEq(), lessThan() and lessThanEq() I would maybe have agreed with you. But at the moment, I dont think it is worth changing. Also, in PHP8 it would be a BC break.

(Generally I dont care about named variables, but I would only rename it for good reasons).