Skip to content

Commit aec2309

Browse files
committed
Remove nullability from IndexHint
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent 25ad961 commit aec2309

File tree

5 files changed

+10
-42
lines changed

5 files changed

+10
-42
lines changed

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ parameters:
745745
path: src/Parsers/GroupKeywords.php
746746

747747
-
748-
message: '#^Property PhpMyAdmin\\SqlParser\\Components\\IndexHint\:\:\$type \(string\|null\) does not accept mixed\.$#'
748+
message: '#^Property PhpMyAdmin\\SqlParser\\Components\\IndexHint\:\:\$type \(string\) does not accept mixed\.$#'
749749
identifier: assign.propertyType
750750
count: 1
751751
path: src/Parsers/IndexHints.php

psalm-baseline.xml

Lines changed: 1 addition & 7 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="6.0.0@b8e96bb617bf59382113b1b56cef751f648a7dc9">
2+
<files psalm-version="6.1.0@827971f8bc7a28bb4f842f34bf8901521de1cea3">
33
<file src="src/Components/AlterOperation.php">
44
<PossiblyNullReference>
55
<code><![CDATA[has]]></code>
@@ -45,12 +45,6 @@
4545
<code><![CDATA[$type]]></code>
4646
</PossiblyUnusedProperty>
4747
</file>
48-
<file src="src/Components/IndexHint.php">
49-
<PossiblyNullOperand>
50-
<code><![CDATA[$this->indexOrKey]]></code>
51-
<code><![CDATA[$this->type]]></code>
52-
</PossiblyNullOperand>
53-
</file>
5448
<file src="src/Components/IntoKeyword.php">
5549
<PossiblyNullOperand>
5650
<code><![CDATA[$this->dest]]></code>

src/Components/IndexHint.php

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,17 @@
1313
final class IndexHint implements Component
1414
{
1515
/**
16-
* The type of hint (USE/FORCE/IGNORE)
17-
*/
18-
public string|null $type;
19-
20-
/**
21-
* What the hint is for (INDEX/KEY)
22-
*/
23-
public string|null $indexOrKey;
24-
25-
/**
26-
* The clause for which this hint is (JOIN/ORDER BY/GROUP BY)
27-
*/
28-
public string|null $for;
29-
30-
/**
31-
* List of indexes in this hint
32-
*
33-
* @var Expression[]
34-
*/
35-
public array $indexes = [];
36-
37-
/**
38-
* @param string $type the type of hint (USE/FORCE/IGNORE)
16+
* @param string $type The type of hint (USE/FORCE/IGNORE)
3917
* @param string $indexOrKey What the hint is for (INDEX/KEY)
40-
* @param string $for the clause for which this hint is (JOIN/ORDER BY/GROUP BY)
18+
* @param string|null $for The clause for which this hint is (JOIN/ORDER BY/GROUP BY)
4119
* @param Expression[] $indexes List of indexes in this hint
4220
*/
4321
public function __construct(
44-
string|null $type = null,
45-
string|null $indexOrKey = null,
46-
string|null $for = null,
47-
array $indexes = [],
22+
public string $type = '',
23+
public string $indexOrKey = '',
24+
public string|null $for = null,
25+
public array $indexes = [],
4826
) {
49-
$this->type = $type;
50-
$this->indexOrKey = $indexOrKey;
51-
$this->for = $for;
52-
$this->indexes = $indexes;
5327
}
5428

5529
public function build(): string

src/Parsers/IndexHints.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
2828
{
2929
$ret = [];
3030
$expr = new IndexHint();
31-
$expr->type = $options['type'] ?? null;
31+
$expr->type = $options['type'] ?? '';
3232
/**
3333
* The state of the parser.
3434
*

tests/data/parser/parseSelectIndexHintErr1.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@
252252
{
253253
"@type": "PhpMyAdmin\\SqlParser\\Components\\IndexHint",
254254
"type": "FORCE",
255-
"indexOrKey": null,
255+
"indexOrKey": "",
256256
"for": null,
257257
"indexes": [
258258
{

0 commit comments

Comments
 (0)