PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.9
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.9
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
betterdocs / includes / Dependencies / SuperClosure / Analyzer / Token.php

Token.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.8.9, at includes/Dependencies/SuperClosure/Analyzer/Token.php

71 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace WPDeveloper\BetterDocs\Dependencies\SuperClosure\Analyzer;
2
3 /**
4 * A Token object represents and individual token parsed from PHP code.
5 *
6 * Each Token object is a normalized token created from the result of the
7 * `get_token_all()`. function, which is part of PHP's tokenizer.
8 *
9 * @link http://us2.php.net/manual/en/tokens.php
10 */
11 class Token
12 {
13 /**
14 * @var string The token name. Always null for literal tokens.
15 */
16 public $name;
17
18 /**
19 * @var int|null The token's integer value. Always null for literal tokens.
20 */
21 public $value;
22
23 /**
24 * @var string The PHP code of the token.
25 */
26 public $code;
27
28 /**
29 * @var int|null The line number of the token in the original code.
30 */
31 public $line;
32
33 /**
34 * Constructs a token object.
35 *
36 * @param string $code
37 * @param int|null $value
38 * @param int|null $line
39 *
40 * @throws \InvalidArgumentException
41 */
42 public function __construct($code, $value = null, $line = null)
43 {
44 if (is_array($code)) {
45 list($value, $code, $line) = array_pad($code, 3, null);
46 }
47
48 $this->code = $code;
49 $this->value = $value;
50 $this->line = $line;
51 $this->name = $value ? token_name($value) : null;
52 }
53
54 /**
55 * Determines if the token's value/code is equal to the specified value.
56 *
57 * @param mixed $value The value to check.
58 *
59 * @return bool True if the token is equal to the value.
60 */
61 public function is($value)
62 {
63 return ($this->code === $value || $this->value === $value);
64 }
65
66 public function __toString()
67 {
68 return $this->code;
69 }
70 }
71