Skip to content

Missing typehints and incorrect usage description #13

@SvenRtbg

Description

@SvenRtbg

The usage description reads:

assertMessageBodyMatches($message, $constraint) / bodyMatches($constraint)

Asserts that the message body matches the constraint $constraint. If $constraint is a primitive value, the assertion will pass when the message body is equal to the constraint. If $constraint is an instance of the PHPUnit\Framework\Constraint\Constraint class, the constraint will be evaluated as-is.

The trait definition has no type declaration for the $constraint parameter (https://github.com/martin-helmich/phpunit-psr7-assert/blob/master/src/Psr7Assertions.php#L41), however if I pass anything other than a PHPUnit Constraint object, I get a fatal error because the inner call static::bodyMatches($constraint) calls a function that requires a Constraint object.

The same is true for the function definition (https://github.com/martin-helmich/phpunit-psr7-assert/blob/master/src/Functions.php#L91) which passes the parameter straight to the constructor of Constraint\BodyMatchesConstraint, which requires the same object type and does not allow a primitive value.

The problem seems to be spread out over more than this example, but this was the one I stepped on right now.

The easy fix would be to add the type declaration - however passing a primitive value is much more useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions