public function testArrayAccessIsset() { $stack = new ezcDocumentRstStack(); $stack->unshift(1); $array = array(1); $stack->prepend($prepend = array(23, 42)); $array = array_merge($prepend, $array); $this->assertSame(isset($array[-1]), isset($stack[-1])); $this->assertSame(isset($array[0]), isset($stack[0])); $this->assertSame(isset($array[1]), isset($stack[1])); $this->assertSame(isset($array[2]), isset($stack[2])); $this->assertSame(isset($array[3]), isset($stack[3])); }
/** * Reduce reference * * Reduce references as defined at: * http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup * * @param ezcDocumentRstNode $node * @return void */ protected function reduceReference(ezcDocumentRstNode $node) { // Pop closing brace $closing = $this->documentStack->shift(); // Find all childs. // // May be multiple childs, since the references may consist of multiple // characters with special chars ( *, # ) embedded. $childs = array(); while (isset($this->documentStack[0]) && $this->documentStack[0]->type === ezcDocumentRstNode::TEXT_LINE) { $child = $this->documentStack->shift(); if ($child->token->type === ezcDocumentRstToken::SPECIAL_CHARS && $child->token->content === '[') { /* DEBUG echo " => Found matching tag.\n"; // /DEBUG */ // We found the nearest matching open tag. Append all included // stuff as child nodes and add the closing tag to the document // stack. $node->name = $childs; $node->footnoteType = $this->detectFootnotetype($childs); return $node; } /* DEBUG echo " - Collected " . ezcDocumentRstNode::getTokenName( $child->type ) . ".\n"; // /DEBUG */ // Append unusable but inline node to potential child list. array_unshift($childs, $child->token); } // We did not find an opening node. // // This is not a parse error, but in this case we just consider the // closing node as text and reattach all found childs to the document // stack. /* DEBUG echo " => Use as Text.\n"; // /DEBUG */ $this->documentStack->prepend(array_merge(array($closing), $childs)); return new ezcDocumentRstTextLineNode($node->token); }