Skip to content

Commit a028de5

Browse files
committed
Merge branch 'master' into 6.0.x
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
2 parents 7974af9 + 0deffe5 commit a028de5

File tree

5 files changed

+13
-33
lines changed

5 files changed

+13
-33
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

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ parameters:
3030
count: 1
3131
path: src/Components/AlterOperation.php
3232

33+
-
34+
message: "#^Result of && is always true\\.$#"
35+
count: 1
36+
path: src/Components/AlterOperation.php
37+
3338
-
3439
message: "#^array\\<PhpMyAdmin\\\\SqlParser\\\\Token\\>\\|string does not accept PhpMyAdmin\\\\SqlParser\\\\Token\\.$#"
3540
count: 3

psalm-baseline.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.18.1@dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb">
2+
<files psalm-version="4.19.0@a2ad69ae4f5ab1f7d225a8dc4e2ec2d9415ed599">
33
<file src="src/Components/AlterOperation.php">
44
<DocblockTypeContradiction occurrences="1">
55
<code>$component-&gt;field !== ''</code>
@@ -567,9 +567,9 @@
567567
<PossiblyNullPropertyAssignmentValue occurrences="1">
568568
<code>$tmp-&gt;expr</code>
569569
</PossiblyNullPropertyAssignmentValue>
570-
<RedundantCondition occurrences="1">
570+
<RedundantConditionGivenDocblockType occurrences="1">
571571
<code>$token-&gt;value === ','</code>
572-
</RedundantCondition>
572+
</RedundantConditionGivenDocblockType>
573573
</file>
574574
<file src="src/Components/UnionKeyword.php">
575575
<InvalidArgument occurrences="1">
@@ -1275,9 +1275,9 @@
12751275
<PossiblyInvalidIterator occurrences="1">
12761276
<code>$this-&gt;options['formats']</code>
12771277
</PossiblyInvalidIterator>
1278-
<RedundantCondition occurrences="1">
1278+
<RedundantConditionGivenDocblockType occurrences="1">
12791279
<code>$curr-&gt;type === Token::TYPE_KEYWORD</code>
1280-
</RedundantCondition>
1280+
</RedundantConditionGivenDocblockType>
12811281
</file>
12821282
<file src="src/Utils/Misc.php">
12831283
<DocblockTypeContradiction occurrences="1">

src/Context.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use function is_array;
1414
use function is_int;
1515
use function is_numeric;
16-
use function is_string;
1716
use function str_replace;
1817
use function str_starts_with;
1918
use function strlen;
@@ -607,23 +606,20 @@ public static function getMode(): int
607606
/**
608607
* Sets the SQL mode.
609608
*
610-
* @param int $mode
611-
* @psalm-param 0|positive-int $mode
609+
* @param int|string $mode
612610
*
613611
* @return void
614612
*/
615613
public static function setMode($mode = self::SQL_MODE_NONE)
616614
{
617-
/** @var int|string $mode Used to set the old type to $mode for static analysis tools. */
618-
$mode = $mode;
619-
if (is_int($mode) && $mode >= 1) {
615+
if (is_int($mode)) {
620616
static::$mode = $mode;
621617

622618
return;
623619
}
624620

625621
static::$mode = self::SQL_MODE_NONE;
626-
if (! is_string($mode) || $mode === '') {
622+
if ($mode === '') {
627623
return;
628624
}
629625

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)