diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e4d60b42..43284b74 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -745,7 +745,7 @@ parameters: path: src/Parsers/GroupKeywords.php - - message: '#^Property PhpMyAdmin\\SqlParser\\Components\\IndexHint\:\:\$type \(string\|null\) does not accept mixed\.$#' + message: '#^Property PhpMyAdmin\\SqlParser\\Components\\IndexHint\:\:\$type \(string\) does not accept mixed\.$#' identifier: assign.propertyType count: 1 path: src/Parsers/IndexHints.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 2ad64101..1da89f1b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + @@ -45,12 +45,6 @@ - - - indexOrKey]]> - type]]> - - dest]]> diff --git a/src/Components/IndexHint.php b/src/Components/IndexHint.php index 052fb77d..5b6cc30d 100644 --- a/src/Components/IndexHint.php +++ b/src/Components/IndexHint.php @@ -13,43 +13,17 @@ final class IndexHint implements Component { /** - * The type of hint (USE/FORCE/IGNORE) - */ - public string|null $type; - - /** - * What the hint is for (INDEX/KEY) - */ - public string|null $indexOrKey; - - /** - * The clause for which this hint is (JOIN/ORDER BY/GROUP BY) - */ - public string|null $for; - - /** - * List of indexes in this hint - * - * @var Expression[] - */ - public array $indexes = []; - - /** - * @param string $type the type of hint (USE/FORCE/IGNORE) + * @param string $type The type of hint (USE/FORCE/IGNORE) * @param string $indexOrKey What the hint is for (INDEX/KEY) - * @param string $for the clause for which this hint is (JOIN/ORDER BY/GROUP BY) + * @param string|null $for The clause for which this hint is (JOIN/ORDER BY/GROUP BY) * @param Expression[] $indexes List of indexes in this hint */ public function __construct( - string|null $type = null, - string|null $indexOrKey = null, - string|null $for = null, - array $indexes = [], + public string $type = '', + public string $indexOrKey = '', + public string|null $for = null, + public array $indexes = [], ) { - $this->type = $type; - $this->indexOrKey = $indexOrKey; - $this->for = $for; - $this->indexes = $indexes; } public function build(): string diff --git a/src/Parsers/IndexHints.php b/src/Parsers/IndexHints.php index f3ff31cc..bf34d866 100644 --- a/src/Parsers/IndexHints.php +++ b/src/Parsers/IndexHints.php @@ -28,7 +28,7 @@ public static function parse(Parser $parser, TokensList $list, array $options = { $ret = []; $expr = new IndexHint(); - $expr->type = $options['type'] ?? null; + $expr->type = $options['type'] ?? ''; /** * The state of the parser. * diff --git a/tests/data/parser/parseSelectIndexHintErr1.out b/tests/data/parser/parseSelectIndexHintErr1.out index 202cf477..f0dbb22c 100644 --- a/tests/data/parser/parseSelectIndexHintErr1.out +++ b/tests/data/parser/parseSelectIndexHintErr1.out @@ -252,7 +252,7 @@ { "@type": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", "type": "FORCE", - "indexOrKey": null, + "indexOrKey": "", "for": null, "indexes": [ {