Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
<exclude-pattern>src/Contexts/*</exclude-pattern>
</rule>

<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>src/Context.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName">
<exclude-pattern>src/TokensList.php</exclude-pattern>
<exclude-pattern>src/UtfString.php</exclude-pattern>
Expand Down
3 changes: 0 additions & 3 deletions src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,3 @@ public static function hasMode($flag = null)
return (self::$MODE & $flag) === $flag;
}
}

// Initializing the default context.
Context::load();
9 changes: 9 additions & 0 deletions src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ class Core
*/
public $errors = [];

public function __construct()
{
if (Context::$KEYWORDS !== []) {
return;
}

Context::load();
}

/**
* Creates a new error log.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ public static function getTokens($str, $strict = false, $delimiter = null)
*/
public function __construct($str, $strict = false, $delimiter = null)
{
parent::__construct();

// `strlen` is used instead of `mb_strlen` because the lexer needs to
// parse each byte of the input.
$len = $str instanceof UtfString ? $str->length() : strlen($str);
Expand Down
2 changes: 2 additions & 0 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ class Parser extends Core
*/
public function __construct($list = null, $strict = false)
{
parent::__construct();

if (is_string($list) || ($list instanceof UtfString)) {
$lexer = new Lexer($list, $strict);
$this->list = $lexer->list;
Expand Down
5 changes: 5 additions & 0 deletions src/Utils/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
*/
class CLI
{
public function __construct()
{
Context::load();
}

/**
* @param string[]|false[] $params
* @param string[] $longopts
Expand Down