-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a66cb6
commit c05ba98
Showing
5 changed files
with
77 additions
and
1 deletion.
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
24 changes: 24 additions & 0 deletions
24
tests/PHPStan/Analyser/data/nullable-closure-parameter.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,24 @@ | ||
<?php // lint >= 7.4 | ||
|
||
namespace NullableClosureParameter; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo() | ||
{ | ||
$a = function (string $test = null) { | ||
assertType('string|null', $test); | ||
return $test; | ||
}; | ||
assertType('string|null', $a()); | ||
|
||
$b = fn (string $test = null) => $test; | ||
assertType('string|null', $b()); | ||
|
||
fn (string $test = null): string => assertType('string|null', $test); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Bug6701; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo(int $i) | ||
{ | ||
$a = function ( string $test = null ): string { | ||
return $test ?? ''; | ||
}; | ||
$a(null); | ||
$a($i); | ||
|
||
$b = fn ( string $test = null ): string => $test ?? ''; | ||
$b(null); | ||
$b($i); | ||
|
||
$c = function ( ?string $test = null ): string { | ||
return $test ?? ''; | ||
}; | ||
$c(null); | ||
$c($i); | ||
} | ||
|
||
} |