function TraversablePatch::apply
Forces class to implement Iterator interface.
Parameters
ClassNode $node:
Overrides ClassPatchInterface::apply
File
-
vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ ClassPatch/ TraversablePatch.php, line 64
Class
- TraversablePatch
- Traversable interface patch. Forces classes that implement interfaces, that extend Traversable to also implement Iterator.
Namespace
Prophecy\Doubler\ClassPatchCode
public function apply(ClassNode $node) {
$node->addInterface('Iterator');
$currentMethod = new MethodNode('current');
\PHP_VERSION_ID >= 80100 && $currentMethod->setReturnTypeNode(new ReturnTypeNode('mixed'));
$node->addMethod($currentMethod);
$keyMethod = new MethodNode('key');
\PHP_VERSION_ID >= 80100 && $keyMethod->setReturnTypeNode(new ReturnTypeNode('mixed'));
$node->addMethod($keyMethod);
$nextMethod = new MethodNode('next');
\PHP_VERSION_ID >= 80100 && $nextMethod->setReturnTypeNode(new ReturnTypeNode('void'));
$node->addMethod($nextMethod);
$rewindMethod = new MethodNode('rewind');
\PHP_VERSION_ID >= 80100 && $rewindMethod->setReturnTypeNode(new ReturnTypeNode('void'));
$node->addMethod($rewindMethod);
$validMethod = new MethodNode('valid');
\PHP_VERSION_ID >= 80100 && $validMethod->setReturnTypeNode(new ReturnTypeNode('bool'));
$node->addMethod($validMethod);
}