MastermindsHTML5TestsParserEventStack

This testing class gathers events from a parser and builds a stack of events.

Defined (1)

The class is defined in the following location(s).

/vendor/masterminds/html5/test/HTML5/Parser/EventStack.php  
  1. class EventStack implements EventHandler 
  2.  
  3. protected $stack; 
  4.  
  5. public function __construct() 
  6. $this->stack = array(); 
  7.  
  8. /** 
  9. * Get the event stack. 
  10. */ 
  11. public function events() 
  12. return $this->stack; 
  13.  
  14. public function depth() 
  15. return count($this->stack); 
  16.  
  17. public function get($index) 
  18. return $this->stack[$index]; 
  19.  
  20. protected function store($event, $data = null) 
  21. $this->stack[] = array( 
  22. 'name' => $event,  
  23. 'data' => $data 
  24. ); 
  25.  
  26. public function doctype($name, $type = 0, $id = null, $quirks = false) 
  27. $args = array( 
  28. $name,  
  29. $type,  
  30. $id,  
  31. $quirks 
  32. ); 
  33. $this->store('doctype', $args); 
  34.  
  35. public function startTag($name, $attributes = array(), $selfClosing = false) 
  36. $args = func_get_args(); 
  37. $this->store('startTag', $args); 
  38. if ($name == 'pre' || $name == 'script') { 
  39. return Elements::TEXT_RAW; 
  40.  
  41. public function endTag($name) 
  42. $this->store('endTag', array( 
  43. $name 
  44. )); 
  45.  
  46. public function comment($cdata) 
  47. $this->store('comment', array( 
  48. $cdata 
  49. )); 
  50.  
  51. public function cdata($data) 
  52. $this->store('cdata', func_get_args()); 
  53.  
  54. public function text($cdata) 
  55. // fprintf(STDOUT, "Received TEXT event with: " . $cdata); 
  56. $this->store('text', array( 
  57. $cdata 
  58. )); 
  59.  
  60. public function eof() 
  61. $this->store('eof'); 
  62.  
  63. public function parseError($msg, $line, $col) 
  64. // throw new EventStackParseError(sprintf("%s (line %d, col %d)", $msg, $line, $col)); 
  65. // $this->store(sprintf("%s (line %d, col %d)", $msg, $line, $col)); 
  66. $this->store('error', func_get_args()); 
  67.  
  68. public function processingInstruction($name, $data = null) 
  69. $this->store('pi', func_get_args());