beberlei / assert

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

add isResource assertion. #222

Closed abacaphiliac closed 7 years ago

abacaphiliac commented 7 years ago

i had to update the doc-block on propertiesExist so that the generated docs for that method were not incorrectly updated to mixed.

rquadling commented 7 years ago

All $values are mixed.

It is upto the assertion to validate the type.

I'm also thinking propertiesExist should be deprecated in favour of the default allPropertyExists method.

abacaphiliac commented 7 years ago

i had to update the second param ($properties) of propertiesExist from mixed to array, not $value/$values. $properties is an array of property names. never a single property.

normally i wouldn't blend two things like this into a single request, but when i ran the doc generator script the docs for propertiesExist were updated also, and i think incorrectly. changing properties to array seems correct per the functionality and ensures that there are no errant changes to the docs.

regarding deprecation, i think the names of propertyExists and propertiesExist are too similar and leads to confusion.

propertyExists allows you to assert that a single object has a single property, while allPropertyExists allows you to assert that multiple objects all have a single property.

propertiesExist allows you to assert that a single object has multiple properties, while allPropertiesExists allows you to assert that multiple objects all have multiple properties.

rquadling commented 7 years ago

With regard to the 'mixed'=>'array' docblock correction, I've done that manually.

abacaphiliac commented 7 years ago

@rquadling thank you for fixing that. sorry for lumping that into this thread : )

rquadling commented 7 years ago

No problem.

rquadling commented 7 years ago

Can you cast your eye over https://github.com/beberlei/assert/pull/219.

abacaphiliac commented 7 years ago

i agree with the changes in #219