You can use an inline matcher:
namespace spec;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use MySpecialType;
class MyArraySpec extends ObjectBehavior
{
function it_should_have_an_array_of_myspecialtypes()
{
$this->getMySpecialTypes()->shouldReturnArrayOfSpecialTypes();
}
function getMatchers()
{
return array(
'returnArrayOfSpecialTypes' => function($mySpecialTypes) {
foreach ($mySpecialTypes as $element) {
if (!$element instanceof MySpecialType) {
return false;
}
}
return true;
}
);
}
}