-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow undefined variables passed into by-ref parameters only if the t…
…ype is nullable
- Loading branch information
1 parent
f71da02
commit 7f8f9cc
Showing
3 changed files
with
71 additions
and
5 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
36 changes: 36 additions & 0 deletions
36
tests/PHPStan/Rules/Variables/data/pass-by-reference-into-not-nullable.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,36 @@ | ||
<?php // lint >= 8.0 | ||
|
||
namespace PassByReferenceIntoNotNullable; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFooNoType(&$test) | ||
{ | ||
|
||
} | ||
|
||
public function doFooMixedType(mixed &$test) | ||
{ | ||
|
||
} | ||
|
||
public function doFooIntType(int &$test) | ||
{ | ||
|
||
} | ||
|
||
public function doFooNullableType(?int &$test) | ||
{ | ||
|
||
} | ||
|
||
public function test() | ||
{ | ||
$this->doFooNoType($one); | ||
$this->doFooMixedType($two); | ||
$this->doFooIntType($three); | ||
$this->doFooNullableType($four); | ||
} | ||
|
||
} |