Skip to content

Suggestion: remove return type declaration check from assertObjectEquals #4707

@jrfnl

Description

@jrfnl

Related to #4467 and 1dba8c3

I'm currently looking at polyfilling the assertObjectEquals() assertion for the PHPUnit Polyfills.

As things stand, the assertion does a check on the $method to make sure that:

  1. a return type is declared and
  2. this return type is not nullable and
  3. this return type is of type bool

This prohibits the writing of PHP/PHPUnit cross-version compatible code using comparator methods, where PHP < 7.0 still has to be supported. (yeah, I know, don't get me started....).

The thing is, if I look at the implementation, that check should not have to be a blocker.

If the return type check is removed and replaced by a check that the output of $other->{$this->method}($this->expected) is of type boolean before checking that the value is true, this part of the assertion is still safeguarded, while not blocking cross-version code.

Would a change to this effect be deemed acceptable ? If so, I'd be willing to create the PR for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature/assertionIssues related to assertions and expectations

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions