Skip to content

Commit aaac48b

Browse files
committed
Drop USE_UTF_STRINGS constant
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent fd47aeb commit aaac48b

File tree

3 files changed

+2
-25
lines changed

3 files changed

+2
-25
lines changed

phpstan.neon.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@ parameters:
1212
reportUnmatchedIgnoredErrors: true
1313
excludePaths:
1414
- tools/doctum-config.php
15-
dynamicConstantNames:
16-
- USE_UTF_STRINGS

psalm-baseline.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4841,9 +4841,6 @@
48414841
<code>parseOperator</code>
48424842
<code>parseSymbol</code>
48434843
</PossiblyUnusedMethod>
4844-
<RedundantCondition>
4845-
<code>USE_UTF_STRINGS</code>
4846-
</RedundantCondition>
48474844
</file>
48484845
<file src="src/Parser.php">
48494846
<InvalidPropertyAssignmentValue>

src/Lexer.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,13 @@
66

77
use PhpMyAdmin\SqlParser\Exceptions\LexerException;
88

9-
use function define;
10-
use function defined;
119
use function in_array;
1210
use function mb_strlen;
1311
use function sprintf;
1412
use function str_ends_with;
1513
use function strlen;
1614
use function substr;
1715

18-
if (! defined('USE_UTF_STRINGS')) {
19-
// NOTE: In previous versions of PHP (5.5 and older) the default
20-
// internal encoding is "ISO-8859-1".
21-
// All `mb_` functions must specify the correct encoding, which is
22-
// 'UTF-8' in order to work properly.
23-
24-
/*
25-
* Forces usage of `UtfString` if the string is multibyte.
26-
* `UtfString` may be slower, but it gives better results.
27-
*
28-
* @var bool
29-
*/
30-
define('USE_UTF_STRINGS', true);
31-
}
32-
3316
/**
3417
* Defines the lexer of the library.
3518
*
@@ -199,9 +182,8 @@ public function __construct($str, $strict = false, $delimiter = null)
199182
// parse each byte of the input.
200183
$len = $str instanceof UtfString ? $str->length() : strlen($str);
201184

202-
// For multi-byte strings, a new instance of `UtfString` is
203-
// initialized (only if `UtfString` usage is forced.
204-
if (! $str instanceof UtfString && USE_UTF_STRINGS && $len !== mb_strlen($str, 'UTF-8')) {
185+
// For multi-byte strings, a new instance of `UtfString` is initialized.
186+
if (! $str instanceof UtfString && $len !== mb_strlen($str, 'UTF-8')) {
205187
$str = new UtfString($str);
206188
}
207189

0 commit comments

Comments
 (0)