Maximum number of iterations, null means infinite, any integer greater
than zero sets value. Zero is invalid because there must be at least one
iteration. Defaults to 1. Loop breaks if result of two consequent
iterations shows no change in processed text.
public withMaxIterations ( integer | null $iterations ) : self | ||
$iterations | integer | null | |
Результат | self |
public function testPreventInfiniteLoop() { $handlers = new HandlerContainer(); $handlers->add('name', function (ShortcodeInterface $s) { return $s->getName(); })->add('content', function (ShortcodeInterface $s) { return $s->getContent(); })->add('reverse', new ReverseShortcode())->addAlias('c', 'content')->addAlias('n', 'name')->add('self', function () { return '[self]'; })->add('other', function () { return '[self]'; })->add('random', function () { return '[various]'; }); $processor = new Processor(new RegexParser(), $handlers); $processor->withMaxIterations(null); $processor->process('[self]'); $processor->process('[other]'); $processor->process('[random]'); }
public function testPreventInfiniteLoop() { $handlers = new HandlerContainer(); $handlers->add('self', function () { return '[self]'; })->add('other', function () { return '[self]'; })->add('random', function () { return '[other]'; }); $processor = new Processor(new RegexParser(), $handlers); $processor->withMaxIterations(null); $processor->process('[self]'); $processor->process('[other]'); $processor->process('[random]'); }