Skip to content

Commit 1aa400f

Browse files
committed
Revert the deprecation of passing string to Context::setMode
This is useful when passing the sql_mode result directly from MySQL/MariaDB. Signed-off-by: Maurício Meneghini Fauth <[email protected]>
1 parent 43fb5bd commit 1aa400f

File tree

3 files changed

+2
-26
lines changed

3 files changed

+2
-26
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* Add missing return types annotations
66
* Improve the WITH statements parser (#363)
77
* Add support for passing `Context::SQL_MODE*` constants to `Context::setMode` method
8-
* Deprecate passing strings to the `Context::setMode` method
98

109
## [5.5.0] - 2021-12-08
1110

src/Context.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,16 +672,13 @@ public static function getMode(): int
672672
/**
673673
* Sets the SQL mode.
674674
*
675-
* @param int $mode
676-
* @psalm-param 0|positive-int $mode
675+
* @param int|string $mode
677676
*
678677
* @return void
679678
*/
680679
public static function setMode($mode = self::SQL_MODE_NONE)
681680
{
682-
/** @var int|string $mode Used to set the old type to $mode for static analysis tools. */
683-
$mode = $mode;
684-
if (is_int($mode) && $mode >= 1) {
681+
if (is_int($mode)) {
685682
static::$MODE = $mode;
686683

687684
return;

tests/Lexer/ContextTest.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ public function testLoadError(): void
128128
*/
129129
public function testMode($mode, int $expected): void
130130
{
131-
/**
132-
* @psalm-suppress ArgumentTypeCoercion
133-
* @phpstan-ignore-next-line
134-
*/
135131
Context::setMode($mode);
136132
$this->assertSame($expected, Context::getMode());
137133
}
@@ -143,7 +139,6 @@ public function testMode($mode, int $expected): void
143139
public function providerForTestMode(): array
144140
{
145141
return [
146-
[-1, Context::SQL_MODE_NONE],
147142
[0, Context::SQL_MODE_NONE],
148143
[1, 1],
149144
['', Context::SQL_MODE_NONE],
@@ -202,15 +197,8 @@ public function testModeWithCombinedModes(): void
202197
$this->assertSame(Context::SQL_MODE_NONE, Context::getMode());
203198
}
204199

205-
/**
206-
* BC tests
207-
*/
208200
public function testModeWithString(): void
209201
{
210-
/**
211-
* @psalm-suppress InvalidScalarArgument
212-
* @phpstan-ignore-next-line
213-
*/
214202
Context::setMode('REAL_AS_FLOAT,ANSI_QUOTES,IGNORE_SPACE');
215203
$this->assertSame(
216204
Context::SQL_MODE_REAL_AS_FLOAT | Context::SQL_MODE_ANSI_QUOTES | Context::SQL_MODE_IGNORE_SPACE,
@@ -221,17 +209,9 @@ public function testModeWithString(): void
221209
$this->assertFalse(Context::hasMode(Context::SQL_MODE_REAL_AS_FLOAT | Context::SQL_MODE_ALLOW_INVALID_DATES));
222210
$this->assertFalse(Context::hasMode(Context::SQL_MODE_ALLOW_INVALID_DATES));
223211

224-
/**
225-
* @psalm-suppress InvalidScalarArgument
226-
* @phpstan-ignore-next-line
227-
*/
228212
Context::setMode('TRADITIONAL');
229213
$this->assertSame(Context::SQL_MODE_TRADITIONAL, Context::getMode());
230214

231-
/**
232-
* @psalm-suppress InvalidScalarArgument
233-
* @phpstan-ignore-next-line
234-
*/
235215
Context::setMode('');
236216
$this->assertSame(Context::SQL_MODE_NONE, Context::getMode());
237217
}

0 commit comments

Comments
 (0)