Skip to content

Commit 94a89e8

Browse files
committed
Move motranslator initialization to share core class
Signed-off-by: Michal Čihař <michal@cihar.com>
1 parent 26f97bc commit 94a89e8

5 files changed

Lines changed: 11 additions & 17 deletions

File tree

src/Component.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
*/
1313
namespace SqlParser;
1414

15-
require_once 'common.php';
16-
1715
/**
1816
* A component (of a statement) is a part of a statement that is common to
1917
* multiple query types.

src/Core.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
namespace SqlParser;
99

10+
use MoTranslator;
1011

1112
class Core
1213
{
@@ -33,6 +34,14 @@ class Core
3334
*/
3435
public $errors = array();
3536

37+
/**
38+
* Constructor.
39+
*/
40+
public function __construct()
41+
{
42+
MoTranslator\Loader::load_functions();
43+
}
44+
3645
/**
3746
* Creates a new error log.
3847
*

src/Lexer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
*/
1212
namespace SqlParser;
1313

14-
require_once 'common.php';
15-
1614
use SqlParser\Exceptions\LexerException;
1715

1816
if (!defined('USE_UTF_STRINGS')) {
@@ -162,6 +160,7 @@ public static function getTokens($str, $strict = false, $delimiter = null)
162160
*/
163161
public function __construct($str, $strict = false, $delimiter = null)
164162
{
163+
parent::__construct();
165164
// `strlen` is used instead of `mb_strlen` because the lexer needs to
166165
// parse each byte of the input.
167166
$len = ($str instanceof UtfString) ? $str->length() : strlen($str);

src/Parser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
*/
1010
namespace SqlParser;
1111

12-
require_once 'common.php';
13-
1412
use SqlParser\Exceptions\ParserException;
1513
use SqlParser\Statements\SelectStatement;
1614
use SqlParser\Statements\TransactionStatement;
@@ -340,6 +338,7 @@ class Parser extends Core
340338
*/
341339
public function __construct($list = null, $strict = false)
342340
{
341+
parent::__construct();
343342
if ((is_string($list)) || ($list instanceof UtfString)) {
344343
$lexer = new Lexer($list, $strict);
345344
$this->list = $lexer->list;

src/common.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)