|
10 | 10 | * |
11 | 11 | * @package SqlParser |
12 | 12 | */ |
| 13 | +namespace SqlParser; |
13 | 14 |
|
14 | | -namespace { |
| 15 | +require_once 'common.php'; |
15 | 16 |
|
16 | | - if (!function_exists('__')) { |
| 17 | +/** |
| 18 | + * A component (of a statement) is a part of a statement that is common to |
| 19 | + * multiple query types. |
| 20 | + * |
| 21 | + * @category Components |
| 22 | + * @package SqlParser |
| 23 | + * @author Dan Ungureanu <udan1107@gmail.com> |
| 24 | + * @license http://opensource.org/licenses/GPL-2.0 GNU Public License |
| 25 | + */ |
| 26 | +abstract class Component |
| 27 | +{ |
17 | 28 |
|
18 | | - /** |
19 | | - * Translates the given string. |
20 | | - * |
21 | | - * @param string $str String to be translated. |
22 | | - * |
23 | | - * @return string |
24 | | - */ |
25 | | - function __($str) |
26 | | - { |
27 | | - return $str; |
28 | | - } |
| 29 | + /** |
| 30 | + * Parses the tokens contained in the given list in the context of the given |
| 31 | + * parser. |
| 32 | + * |
| 33 | + * @param Parser $parser The parser that serves as context. |
| 34 | + * @param TokensList $list The list of tokens that are being parsed. |
| 35 | + * @param array $options Parameters for parsing. |
| 36 | + * |
| 37 | + * @throws \Exception Not implemented yet. |
| 38 | + * |
| 39 | + * @return mixed |
| 40 | + */ |
| 41 | + public static function parse( |
| 42 | + Parser $parser, TokensList $list, array $options = array() |
| 43 | + ) { |
| 44 | + // This method should be abstract, but it can't be both static and |
| 45 | + // abstract. |
| 46 | + throw new \Exception(\__('Not implemented yet.')); |
29 | 47 | } |
30 | | -} |
31 | | - |
32 | | -namespace SqlParser { |
33 | 48 |
|
34 | 49 | /** |
35 | | - * A component (of a statement) is a part of a statement that is common to |
36 | | - * multiple query types. |
| 50 | + * Builds the string representation of a component of this type. |
| 51 | + * |
| 52 | + * In other words, this function represents the inverse function of |
| 53 | + * `static::parse`. |
37 | 54 | * |
38 | | - * @category Components |
39 | | - * @package SqlParser |
40 | | - * @author Dan Ungureanu <udan1107@gmail.com> |
41 | | - * @license http://opensource.org/licenses/GPL-2.0 GNU Public License |
| 55 | + * @param mixed $component The component to be built. |
| 56 | + * @param array $options Parameters for building. |
| 57 | + * |
| 58 | + * @throws \Exception Not implemented yet. |
| 59 | + * |
| 60 | + * @return string |
42 | 61 | */ |
43 | | - abstract class Component |
| 62 | + public static function build($component, array $options = array()) |
44 | 63 | { |
| 64 | + // This method should be abstract, but it can't be both static and |
| 65 | + // abstract. |
| 66 | + throw new \Exception(\__('Not implemented yet.')); |
| 67 | + } |
45 | 68 |
|
46 | | - /** |
47 | | - * Parses the tokens contained in the given list in the context of the given |
48 | | - * parser. |
49 | | - * |
50 | | - * @param Parser $parser The parser that serves as context. |
51 | | - * @param TokensList $list The list of tokens that are being parsed. |
52 | | - * @param array $options Parameters for parsing. |
53 | | - * |
54 | | - * @throws \Exception Not implemented yet. |
55 | | - * |
56 | | - * @return mixed |
57 | | - */ |
58 | | - public static function parse( |
59 | | - Parser $parser, TokensList $list, array $options = array() |
60 | | - ) { |
61 | | - // This method should be abstract, but it can't be both static and |
62 | | - // abstract. |
63 | | - throw new \Exception(\__('Not implemented yet.')); |
64 | | - } |
65 | | - |
66 | | - /** |
67 | | - * Builds the string representation of a component of this type. |
68 | | - * |
69 | | - * In other words, this function represents the inverse function of |
70 | | - * `static::parse`. |
71 | | - * |
72 | | - * @param mixed $component The component to be built. |
73 | | - * @param array $options Parameters for building. |
74 | | - * |
75 | | - * @throws \Exception Not implemented yet. |
76 | | - * |
77 | | - * @return string |
78 | | - */ |
79 | | - public static function build($component, array $options = array()) |
80 | | - { |
81 | | - // This method should be abstract, but it can't be both static and |
82 | | - // abstract. |
83 | | - throw new \Exception(\__('Not implemented yet.')); |
84 | | - } |
85 | | - |
86 | | - /** |
87 | | - * Builds the string representation of a component of this type. |
88 | | - * |
89 | | - * @see static::build |
90 | | - * |
91 | | - * @return string |
92 | | - */ |
93 | | - public function __toString() |
94 | | - { |
95 | | - return static::build($this); |
96 | | - } |
| 69 | + /** |
| 70 | + * Builds the string representation of a component of this type. |
| 71 | + * |
| 72 | + * @see static::build |
| 73 | + * |
| 74 | + * @return string |
| 75 | + */ |
| 76 | + public function __toString() |
| 77 | + { |
| 78 | + return static::build($this); |
97 | 79 | } |
98 | 80 | } |
0 commit comments