-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use NullableTypeSniff to check for implicitly nullable types in php8.4
Remove the php7.1 check, as that is obsolete Remove test case with required parameter follows by optional, as that is deprecated in php8.0 This includes an autofix to add the missing ? Bug: T362014 Change-Id: Ide15839e98a6229c22584d1c1c88c690982e1d7a
- Loading branch information
1 parent
6d16a0f
commit 477ac00
Showing
4 changed files
with
74 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
8 | ERROR | Use nullable type("?MyClass") for parameters documented as nullable | ||
| | (MediaWiki.Commenting.FunctionComment.PHP71NullableDocOptionalArg) | ||
15 | ERROR | Use PHP 7.1 syntax for nullable parameters ("?MyClass $x") | ||
| | (MediaWiki.Usage.NullableType.PHP71NullableStyle) | ||
23 | ERROR | Use PHP 7.1 syntax for nullable parameters ("?MyClass $x") | ||
| | (MediaWiki.Usage.NullableType.PHP71NullableStyle) | ||
23 | ERROR | Use PHP 7.1 syntax for nullable parameters ("?MyClass $y") | ||
| | (MediaWiki.Usage.NullableType.PHP71NullableStyle) | ||
31 | ERROR | Use PHP 7.1 syntax for nullable parameters ("?MyClass $x") | ||
| | (MediaWiki.Usage.NullableType.PHP71NullableStyle) | ||
40 | ERROR | Use PHP 7.1 syntax for nullable parameters ("?MyClass $x") | ||
| | (MediaWiki.Usage.NullableType.PHP71NullableStyle) | ||
40 | ERROR | Use PHP 7.1 syntax for nullable parameters ("?MyClass $y") | ||
| | (MediaWiki.Usage.NullableType.PHP71NullableStyle) | ||
47 | ERROR | Use PHP 7.1 syntax for nullable parameters ("?MyClass $x") | ||
| | (MediaWiki.Usage.NullableType.PHP71NullableStyle) | ||
8 | ERROR | [x] Use PHP 8.4 compatible syntax for explicit nullable types ("?MyClass $x = null") | ||
| | (MediaWiki.Usage.NullableType.ExplicitNullableTypes) | ||
8 | ERROR | [ ] Use nullable type("?MyClass") for parameters documented as nullable | ||
| | (MediaWiki.Commenting.FunctionComment.PHP71NullableDocOptionalArg) | ||
15 | ERROR | [x] Use PHP 8.4 compatible syntax for explicit nullable types ("?MyClass $x = null") | ||
| | (MediaWiki.Usage.NullableType.ExplicitNullableTypes) | ||
23 | ERROR | [x] Use PHP 8.4 compatible syntax for explicit nullable types ("?MyClass $x = null") | ||
| | (MediaWiki.Usage.NullableType.ExplicitNullableTypes) | ||
23 | ERROR | [x] Use PHP 8.4 compatible syntax for explicit nullable types ("?MyClass $y = null") | ||
| | (MediaWiki.Usage.NullableType.ExplicitNullableTypes) | ||
29 | ERROR | [x] Use PHP 8.4 compatible syntax for explicit nullable types ("?MyClass $x = null") | ||
| | (MediaWiki.Usage.NullableType.ExplicitNullableTypes) | ||
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound | ||
class FailedExamples { | ||
/** | ||
* @param string $foo | ||
* @param ?MyClass $x | ||
*/ | ||
public function docNullableArgOptional( $foo, ?MyClass $x = null ) { | ||
} | ||
|
||
/** | ||
* @param string $foo | ||
* @param MyClass|null $x | ||
*/ | ||
public function nullableAfterRequired( $foo, ?MyClass $x = null ) { | ||
} | ||
|
||
/** | ||
* @param string $foo | ||
* @param MyClass|null $x | ||
* @param MyClass|null $y | ||
*/ | ||
public function nullableAfterRequired2( $foo, ?MyClass $x = null, ?MyClass $y = null ) { | ||
} | ||
|
||
/** | ||
* @param MyClass|null $x | ||
*/ | ||
public function nullableOnly( ?MyClass $x = null ) { | ||
} | ||
} | ||
|
||
class PassedExamples { | ||
/** | ||
* @param ?MyClass $x | ||
* @param string $foo | ||
*/ | ||
public function genericNullable( ?MyClass $x, $foo ) { | ||
} | ||
|
||
/** | ||
* We allow this per T218816. | ||
* @param string $foo | ||
* @param MyClass|null $x | ||
*/ | ||
public function docOptionalArgNullable( $foo, ?MyClass $x ) { | ||
} | ||
} |