1<?php
2/**
3 * HTML API: WP_HTML_Stack_Event class
4 *
5 * @package WordPress
6 * @subpackage HTML-API
7 * @since 6.6.0
8 */
9
10/**
11 * Core class used by the HTML Processor as a record for stack operations.
12 *
13 * This class is for internal usage of the WP_HTML_Processor class.
14 *
15 * @access private
16 * @since 6.6.0
17 *
18 * @see WP_HTML_Processor
19 */
20class WP_HTML_Stack_Event {
21 /**
22 * Refers to popping an element off of the stack of open elements.
23 *
24 * @since 6.6.0
25 */
26 const POP = 'pop';
27
28 /**
29 * Refers to pushing an element onto the stack of open elements.
30 *
31 * @since 6.6.0
32 */
33 const PUSH = 'push';
34
35 /**
36 * References the token associated with the stack push event,
37 * even if this is a pop event for that element.
38 *
39 * @since 6.6.0
40 *
41 * @var WP_HTML_Token
42 */
43 public $token;
44
45 /**
46 * Indicates which kind of stack operation this event represents.
47 *
48 * May be one of the class constants.
49 *
50 * @since 6.6.0
51 *
52 * @see self::POP
53 * @see self::PUSH
54 *
55 * @var string
56 */
57 public $operation;
58
59 /**
60 * Indicates if the stack element is a real or virtual node.
61 *
62 * @since 6.6.0
63 *
64 * @var string
65 */
66 public $provenance;
67
68 /**
69 * Constructor function.
70 *
71 * @since 6.6.0
72 *
73 * @param WP_HTML_Token $token Token associated with stack event, always an opening token.
74 * @param string $operation One of self::PUSH or self::POP.
75 * @param string $provenance "virtual" or "real".
76 */
77 public function __construct( WP_HTML_Token $token, string $operation, string $provenance ) {
78 $this->token = $token;
79 $this->operation = $operation;
80 $this->provenance = $provenance;
81 }
82}
83