beberlei / assert

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

Introduce notFalse() #274

Open simPod opened 5 years ago

simPod commented 5 years ago

I was rewriting this code

/** @var SplFileInfo $file */
$filename = $file->getRealPath();
assert($filename !== false);

into Assertion and the Assertion::notFalse() method was missing. Using Assertion::true($filename !== false) IMO loses the benefit of using Assertion as nice readable wrappers around simple conditions.

notFalse() is similar to notNull(). Especially some PHP internal functions return type of <result>|bool but actually bool there is false -> <result>|false which stands for failure. This is handy instrument how to handle it.

stefanfisk commented 3 months ago

I'd very much appreciate this addition! Would it be accepted if I supplied an update to date PR?