-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHP 8 - report deprecated required parameter after optional
- Loading branch information
1 parent
bbda299
commit cc864d2
Showing
10 changed files
with
288 additions
and
0 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
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
11 changes: 11 additions & 0 deletions
11
tests/PHPStan/Rules/Functions/data/required-parameter-after-optional-arrow.php
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,11 @@ | ||
<?php // lint >= 7.4 | ||
|
||
namespace RequiredAfterOptional; | ||
|
||
fn ($foo = null, $bar): int => 1; // not OK | ||
|
||
fn (int $foo = null, $bar): int => 1; // is OK | ||
|
||
fn (int $foo = 1, $bar): int => 1; // not OK | ||
|
||
fn (bool $foo = true, $bar): int => 1; // not OK |
19 changes: 19 additions & 0 deletions
19
tests/PHPStan/Rules/Functions/data/required-parameter-after-optional-closures.php
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,19 @@ | ||
<?php | ||
|
||
namespace RequiredAfterOptional; | ||
|
||
function ($foo = null, $bar): void // not OK | ||
{ | ||
}; | ||
|
||
function (int $foo = null, $bar): void // is OK | ||
{ | ||
}; | ||
|
||
function (int $foo = 1, $bar): void // not OK | ||
{ | ||
}; | ||
|
||
function(bool $foo = true, $bar): void // not OK | ||
{ | ||
}; |
20 changes: 20 additions & 0 deletions
20
tests/PHPStan/Rules/Functions/data/required-parameter-after-optional.php
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,20 @@ | ||
<?php | ||
|
||
namespace RequiredAfterOptional; | ||
|
||
function doFoo($foo = null, $bar): void // not OK | ||
{ | ||
|
||
} | ||
|
||
function doBar(int $foo = null, $bar): void // is OK | ||
{ | ||
} | ||
|
||
function doBaz(int $foo = 1, $bar): void // not OK | ||
{ | ||
} | ||
|
||
function doLorem(bool $foo = true, $bar): void // not OK | ||
{ | ||
} |
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
25 changes: 25 additions & 0 deletions
25
tests/PHPStan/Rules/Methods/data/required-parameter-after-optional.php
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,25 @@ | ||
<?php | ||
|
||
namespace RequiredAfterOptional; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo($foo = null, $bar): void // not OK | ||
{ | ||
|
||
} | ||
|
||
public function doBar(int $foo = null, $bar): void // is OK | ||
{ | ||
} | ||
|
||
public function doBaz(int $foo = 1, $bar): void // not OK | ||
{ | ||
} | ||
|
||
public function doLorem(bool $foo = true, $bar): void // not OK | ||
{ | ||
} | ||
|
||
} |