beberlei / assert

Thin assertion library for use in libraries and business-model
Other
2.41k stars 186 forks source link

EQ argument meaning swapped #224

Closed romaninsh closed 7 years ago

romaninsh commented 7 years ago

I really enjoying your library, great replacement for PHPUnit, but there is one incompatibility.

phpunit: eq(expected, actual).

assert: eq(actual, expected).

It's more common for methods to have "defining" arguments first. Consider this example:

eq(10, $var);

can also be written as

eq10($var);

This is why I think this swap should be made, (not because phpunit)

To fix arguments here should be swapped: https://github.com/beberlei/assert/blob/master/lib/Assert/Assertion.php#L305

I can create PR for this.

rquadling commented 7 years ago

Both eq() and same(), as well as their negative counterparts notEq() and notSame() all have the the same structure of 'actual' vs 'expected'.

I'm unsure what value there would be in amending the message when things are consistent within this library.

In addition, with lazy assertions, the first value can be passed through several assertions, making the first value the 'actual'.

romaninsh commented 7 years ago

Although I think that having "expected" as a first argument is more sensible, I respect your choice and the importance to be consistent with lazy assertions.