Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


assertContains is not type-safe for (non-object) primitive types #745

farnoux opened this Issue · 0 comments

2 participants


Currently the $checkForObjectIdentity parameter, as its name indicates, only check identity for object elements. Is there any reason the assertContains() method doesn't check identity also for primitive types?


$this->assertContains('hello', array(10, 45, 0)); // Success :(

This assert is unexpectedly successful due to the fact that 0 == 'hello' returns true.
This is successful whatever the value of the $checkForObjectIdentity parameter, because it only applies for elements of type Object.

@whatthejeff whatthejeff closed this issue from a commit
@farnoux farnoux Allow identity checking for non object types in TraversableContains a…

This fixes #745.
The possibility to check identity for non object is done by adding a new optional parameter.
This comes in addition to the existing one that already allow to check object identity or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.