Пример #1
0
 public function testInvariant_fail()
 {
     $this->setExpectedException('Wikimedia\\Assert\\InvariantException');
     Assert::invariant(false, 'test');
 }
Пример #2
0
 private function inTemplateMode($token, $value, $attribs = null, $selfClose = false)
 {
     if ($token === 'text' || $token === 'comment') {
         return $this->inBodyMode($token, $value, $attribs, $selfClose);
     } elseif ($token === 'eof') {
         if ($this->stack->indexOf('template') < 0) {
             $this->stopParsing();
         } else {
             $this->stack->popTag('template');
             $this->afe->clearToMarker();
             array_pop($this->templateInsertionModes);
             $this->resetInsertionMode();
             $this->insertToken($token, $value, $attribs, $selfClose);
         }
         return true;
     } elseif ($token === 'tag') {
         switch ($value) {
             case 'base':
             case 'basefont':
             case 'bgsound':
             case 'link':
             case 'meta':
             case 'noframes':
                 // OMITTED: <script>
             // OMITTED: <script>
             case 'style':
             case 'template':
                 // OMITTED: <title>
                 return $this->inHeadMode($token, $value, $attribs, $selfClose);
             case 'caption':
             case 'colgroup':
             case 'tbody':
             case 'tfoot':
             case 'thead':
                 return $this->switchModeAndReprocess('inTableMode', $token, $value, $attribs, $selfClose);
             case 'col':
                 return $this->switchModeAndReprocess('inColumnGroupMode', $token, $value, $attribs, $selfClose);
             case 'tr':
                 return $this->switchModeAndReprocess('inTableBodyMode', $token, $value, $attribs, $selfClose);
             case 'td':
             case 'th':
                 return $this->switchModeAndReprocess('inRowMode', $token, $value, $attribs, $selfClose);
         }
         return $this->switchModeAndReprocess('inBodyMode', $token, $value, $attribs, $selfClose);
     } elseif ($token === 'endtag') {
         switch ($value) {
             case 'template':
                 return $this->inHeadMode($token, $value, $attribs, $selfClose);
         }
         return true;
     } else {
         Assert::invariant(false, "Bad token type: {$token}");
     }
 }