Skip to content

Commit 9f2586f

Browse files
committed
Remove Context::load call from the Context file
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent e9c5a45 commit 9f2586f

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

phpcs.xml.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@
3434
<exclude-pattern>src/Contexts/*</exclude-pattern>
3535
</rule>
3636

37-
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
38-
<exclude-pattern>src/Context.php</exclude-pattern>
39-
</rule>
40-
4137
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName">
4238
<exclude-pattern>src/TokensList.php</exclude-pattern>
4339
<exclude-pattern>src/UtfString.php</exclude-pattern>

src/Context.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,3 @@ public static function hasMode($flag = null)
639639
return (self::$MODE & $flag) === $flag;
640640
}
641641
}
642-
643-
// Initializing the default context.
644-
Context::load();

src/Core.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ class Core
3333
*/
3434
public $errors = [];
3535

36+
public function __construct()
37+
{
38+
if (Context::$KEYWORDS !== []) {
39+
return;
40+
}
41+
42+
Context::load();
43+
}
44+
3645
/**
3746
* Creates a new error log.
3847
*

src/Lexer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ public static function getTokens($str, $strict = false, $delimiter = null)
171171
*/
172172
public function __construct($str, $strict = false, $delimiter = null)
173173
{
174+
parent::__construct();
175+
174176
// `strlen` is used instead of `mb_strlen` because the lexer needs to
175177
// parse each byte of the input.
176178
$len = $str instanceof UtfString ? $str->length() : strlen($str);

src/Parser.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ class Parser extends Core
362362
*/
363363
public function __construct($list = null, $strict = false)
364364
{
365+
parent::__construct();
366+
365367
if (is_string($list) || ($list instanceof UtfString)) {
366368
$lexer = new Lexer($list, $strict);
367369
$this->list = $lexer->list;

src/Utils/CLI.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
*/
2828
class CLI
2929
{
30+
public function __construct()
31+
{
32+
Context::load();
33+
}
34+
3035
/**
3136
* @param string[]|false[] $params
3237
* @param string[] $longopts

0 commit comments

Comments
 (0)