Skip to content

Commit 73fc55e

Browse files
committed
Merge #458 - Disallow short nullable
Pull-request: #458 Pull-request: #457 Signed-off-by: William Desportes <[email protected]>
3 parents aeb52db + c1cb505 + 1ee106f commit 73fc55e

File tree

10 files changed

+18
-21
lines changed

10 files changed

+18
-21
lines changed

phpcs.xml.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@
6969
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint">
7070
<severity>4</severity>
7171
</rule>
72-
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat.DisallowedShortNullable">
73-
<severity>4</severity>
74-
</rule>
7572
<rule ref="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps">
7673
<severity>4</severity>
7774
</rule>

src/Components/IndexHint.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ final class IndexHint implements Component
5252
* @param Expression[] $indexes List of indexes in this hint
5353
*/
5454
public function __construct(
55-
?string $type = null,
56-
?string $indexOrKey = null,
57-
?string $for = null,
55+
string|null $type = null,
56+
string|null $indexOrKey = null,
57+
string|null $for = null,
5858
array $indexes = []
5959
) {
6060
$this->type = $type;

src/Context.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ abstract class Context
357357
*
358358
* @param bool $isReserved checks if the keyword is reserved
359359
*/
360-
public static function isKeyword(string $string, bool $isReserved = false): ?int
360+
public static function isKeyword(string $string, bool $isReserved = false): int|null
361361
{
362362
$upperString = strtoupper($string);
363363

@@ -374,7 +374,7 @@ public static function isKeyword(string $string, bool $isReserved = false): ?int
374374
/**
375375
* Checks if the given string is an operator and returns the appropriate flag for the operator.
376376
*/
377-
public static function isOperator(string $string): ?int
377+
public static function isOperator(string $string): int|null
378378
{
379379
return static::$operators[$string] ?? null;
380380
}
@@ -392,7 +392,7 @@ public static function isWhitespace(string $string): bool
392392
*
393393
* @return int|null the appropriate flag for the comment type
394394
*/
395-
public static function isComment(string $string, bool $end = false): ?int
395+
public static function isComment(string $string, bool $end = false): int|null
396396
{
397397
if ($string === '') {
398398
return null;
@@ -455,7 +455,7 @@ public static function isNumber(string $string): bool
455455
*
456456
* @return int|null the appropriate flag for the symbol type
457457
*/
458-
public static function isSymbol(string $string): ?int
458+
public static function isSymbol(string $string): int|null
459459
{
460460
if ($string === '') {
461461
return null;
@@ -483,7 +483,7 @@ public static function isSymbol(string $string): ?int
483483
*
484484
* @return int|null the appropriate flag for the string type
485485
*/
486-
public static function isString(string $string): ?int
486+
public static function isString(string $string): int|null
487487
{
488488
if ($string === '') {
489489
return null;
@@ -559,7 +559,7 @@ public static function load(string $context = ''): bool
559559
*
560560
* @return string|null The loaded context. `null` if no context was loaded.
561561
*/
562-
public static function loadClosest(string $context = ''): ?string
562+
public static function loadClosest(string $context = ''): string|null
563563
{
564564
$length = strlen($context);
565565
for ($i = $length; $i > 0;) {
@@ -776,7 +776,7 @@ public static function getIdentifierQuote(): string
776776
*
777777
* @return bool false on empty param, true/false on given constant/int value
778778
*/
779-
public static function hasMode(?int $flag = null): bool
779+
public static function hasMode(int|null $flag = null): bool
780780
{
781781
if (empty($flag)) {
782782
return false;

src/Exceptions/ParserException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ParserException extends Exception
2424
* @param Token $token the token that produced this exception
2525
* @param int $code the code of this error
2626
*/
27-
public function __construct($msg = '', ?Token $token = null, $code = 0)
27+
public function __construct($msg = '', Token|null $token = null, $code = 0)
2828
{
2929
parent::__construct($msg, $code);
3030
$this->token = $token;

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ public function parse()
629629
*
630630
* @throws ParserException throws the exception, if strict mode is enabled.
631631
*/
632-
public function error($msg, ?Token $token = null, $code = 0)
632+
public function error($msg, Token|null $token = null, $code = 0)
633633
{
634634
$error = new ParserException(
635635
Translator::gettext($msg),

src/Statement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ abstract class Statement implements Stringable
102102
* @param Parser|null $parser the instance that requests parsing
103103
* @param TokensList|null $list the list of tokens to be parsed
104104
*/
105-
public function __construct(?Parser $parser = null, ?TokensList $list = null)
105+
public function __construct(Parser|null $parser = null, TokensList|null $list = null)
106106
{
107107
if (($parser === null) || ($list === null)) {
108108
return;

src/TokensList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function getNext()
118118
* Gets the previous token. Skips any irrelevant token (whitespaces and
119119
* comments).
120120
*/
121-
public function getPrevious(): ?Token
121+
public function getPrevious(): Token|null
122122
{
123123
for (; $this->idx >= 0; --$this->idx) {
124124
if (
@@ -201,7 +201,7 @@ public function getNextOfTypeAndValue($type, $value)
201201
* @param int $type the type of the token
202202
* @param int $flag the flag of the token
203203
*/
204-
public function getNextOfTypeAndFlag(int $type, int $flag): ?Token
204+
public function getNextOfTypeAndFlag(int $type, int $flag): Token|null
205205
{
206206
for (; $this->idx < $this->count; ++$this->idx) {
207207
if (($this->tokens[$this->idx]->type === $type) && ($this->tokens[$this->idx]->flags === $flag)) {

tests/Lexer/ContextTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testLoad(): void
3030
*
3131
* @dataProvider contextLoadingProvider
3232
*/
33-
public function testLoadClosest(string $context, ?string $expected): void
33+
public function testLoadClosest(string $context, string|null $expected): void
3434
{
3535
$this->assertEquals($expected, Context::loadClosest($context));
3636
if ($expected !== null) {

tests/Misc/UtfStringTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function testToString(): void
8686
*
8787
* @dataProvider utf8StringsProvider
8888
*/
89-
public function testAccess(string $text, ?string $pos10, ?string $pos20): void
89+
public function testAccess(string $text, string|null $pos10, string|null $pos20): void
9090
{
9191
$str = new UtfString($text);
9292
$this->assertEquals($pos10, $str->offsetGet(10));

tests/Utils/MiscTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MiscTest extends TestCase
1919
*
2020
* @dataProvider getAliasesProvider
2121
*/
22-
public function testGetAliases(string $query, ?string $db, array $expected): void
22+
public function testGetAliases(string $query, string|null $db, array $expected): void
2323
{
2424
$parser = new Parser($query);
2525
$statement = empty($parser->statements[0]) ?

0 commit comments

Comments
 (0)