|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Defines a component that is later extended to parse specialized components or |
|
5
|
|
|
* keywords. |
|
6
|
|
|
* |
|
7
|
|
|
* There is a small difference between *Component and *Keyword classes: usually, |
|
8
|
|
|
* *Component parsers can be reused in multiple situations and *Keyword parsers |
|
9
|
|
|
* count on the *Component classes to do their job. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace PhpMyAdmin\SqlParser; |
|
13
|
|
|
|
|
14
|
2 |
|
require_once 'common.php'; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* A component (of a statement) is a part of a statement that is common to |
|
18
|
|
|
* multiple query types. |
|
19
|
|
|
* |
|
20
|
|
|
* @category Components |
|
21
|
|
|
* |
|
22
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ |
|
23
|
|
|
*/ |
|
24
|
|
|
abstract class Component |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Parses the tokens contained in the given list in the context of the given |
|
28
|
|
|
* parser. |
|
29
|
|
|
* |
|
30
|
|
|
* @param Parser $parser the parser that serves as context |
|
31
|
|
|
* @param TokensList $list the list of tokens that are being parsed |
|
32
|
|
|
* @param array $options parameters for parsing |
|
33
|
|
|
* |
|
34
|
|
|
* @throws \Exception not implemented yet |
|
35
|
|
|
* |
|
36
|
|
|
* @return mixed |
|
37
|
|
|
*/ |
|
38
|
1 |
|
public static function parse( |
|
39
|
|
|
Parser $parser, |
|
40
|
|
|
TokensList $list, |
|
41
|
|
|
array $options = array() |
|
42
|
|
|
) { |
|
43
|
|
|
// This method should be abstract, but it can't be both static and |
|
44
|
|
|
// abstract. |
|
45
|
1 |
|
throw new \Exception(\__('Not implemented yet.')); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Builds the string representation of a component of this type. |
|
50
|
|
|
* |
|
51
|
|
|
* In other words, this function represents the inverse function of |
|
52
|
|
|
* `static::parse`. |
|
53
|
|
|
* |
|
54
|
|
|
* @param mixed $component the component to be built |
|
55
|
|
|
* @param array $options parameters for building |
|
56
|
|
|
* |
|
57
|
|
|
* @throws \Exception not implemented yet |
|
58
|
|
|
* |
|
59
|
|
|
* @return string |
|
60
|
|
|
*/ |
|
61
|
1 |
|
public static function build($component, array $options = array()) |
|
62
|
|
|
{ |
|
63
|
|
|
// This method should be abstract, but it can't be both static and |
|
64
|
|
|
// abstract. |
|
65
|
1 |
|
throw new \Exception(\__('Not implemented yet.')); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Builds the string representation of a component of this type. |
|
70
|
|
|
* |
|
71
|
|
|
* @see static::build |
|
72
|
|
|
* |
|
73
|
|
|
* @return string |
|
74
|
|
|
*/ |
|
75
|
36 |
|
public function __toString() |
|
76
|
|
|
{ |
|
77
|
36 |
|
return static::build($this); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|