Phpinspectionsea: Idea: support beberlei/assert assertions

Created on 17 Jan 2018  路  4Comments  路  Source: kalessil/phpinspectionsea

Currently, I believe phpunit assertions work for helping determine types, e.g.:

private function x(\stdClass $b)
{
}

/**
 * @return \stdClass|null
 */
private function g()
{
}

private function y()
{
    $g = $this->g();
//    \PHPUnit\Framework\Assert::assertNotNull($g);
//    \Assert\Assert::that($g)->notNull();
    $this->x($g);
}

If the PHPUnit assertion assertNotNull($g) is uncommented, the Null pointer exception goes away (awesome!)

However, the beberlei/assert assertion is not recognised... uncomment \Assert\Assert::that($g)->notNull(), but the null pointer exception remains (boo! hiss!)

Wonder if support for this great assertion library (to be clear: beberlei/assert) could be added at all?

Example use case: I often use beberlei/assert in production, but phpunit assertions only in a require-dev dependency, so may not exist.

bug / false-positive fixed

Most helpful comment

Will do.
For myself: + Assertion::notNull

All 4 comments

Will do.
For myself: + Assertion::notNull

Done

wow, that was quick, thanks @kalessil :+1:

You are welcome James =)

Was this page helpful?
0 / 5 - 0 ratings