> IMPLEMENTATION STYLE #1: collectionof operator > The style of implementation I like the most is a collectionof operator in > parallel to the instance_of operator. It would be instanceof's plural > brother, so > > $arg collectionof \SomeClass > > To pass the check $arg must be of the iterable psuedotype with all its > values being a \SomeClass object. > > This is all well and good, but collection integrity checks are usually > going to be looking to see if all the members are the same scalar. > > $arg collectionof string > > For language consistency we would need to allow instance_of to do the same, > which it currently does not. > > $arg instanceof string > > This does create duplication with the is_* family of functions, but > instanceof already overlaps is_a heavily.
I see no value to this operator being applied to non-array traversables. Our iterators cannot always be reliably rewound, such as when using generators. Checking that the generator returns only strings would consume all the input and would therefore be useless. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php