PluginProbe
SQLite Database Integration / 2.2.3
SQLite Database Integration v2.2.3
3.0.2 3.0.1 trunk 2.1.13 2.1.14 2.1.15 2.1.16 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.2.2 2.2.20 2.2.21 2.2.22 2.2.23 2.2.3 All 32 releases
sqlite-database-integration / wp-includes / parser / class-wp-parser-token.php

class-wp-parser-token.php in SQLite Database Integration 2.2.3, at wp-includes/parser/class-wp-parser-token.php

78 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * A token, representing a leaf in the parse tree.
5 *
6 * This class represents a token that is consumed and recognized by WP_Parser.
7 * In a parse tree, a token represent a leaf, that is, a node without children.
8 * It is a simple generic container for a token ID and value, that can be used
9 * as a base class and extended for specific use cases.
10 */
11 class WP_Parser_Token {
12 /**
13 * Token ID represented as an integer constant.
14 *
15 * @var int $id
16 */
17 public $id;
18
19 /**
20 * Byte offset in the input where the token begins.
21 *
22 * @var int
23 */
24 public $start;
25
26 /**
27 * Byte length of the token in the input.
28 *
29 * @var int
30 */
31 public $length;
32
33 /**
34 * Input bytes from which the token was parsed.
35 *
36 * @var string
37 */
38 private $input;
39
40 /**
41 * Constructor.
42 *
43 * @param int $id Token type.
44 * @param int $start Byte offset in the input where the token begins.
45 * @param int $length Byte length of the token in the input.
46 * @param string $input Input bytes from which the token was parsed.
47 */
48 public function __construct(
49 int $id,
50 int $start,
51 int $length,
52 string $input
53 ) {
54 $this->id = $id;
55 $this->start = $start;
56 $this->length = $length;
57 $this->input = $input;
58 }
59
60 /**
61 * Get the raw bytes of the token from the input.
62 *
63 * @return string The token bytes.
64 */
65 public function get_bytes(): string {
66 return substr( $this->input, $this->start, $this->length );
67 }
68
69 /**
70 * Get the real unquoted value of the token.
71 *
72 * @return string The token value.
73 */
74 public function get_value(): string {
75 return $this->get_bytes();
76 }
77 }
78