forked from phan/phan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request phan#4535 from TysonAndre/upgrade-instruction
Add upgrade instructions for php-ast, fix false positive in MoreSpecificElementTypePlugin
- Loading branch information
Showing
5 changed files
with
53 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
1 change: 1 addition & 0 deletions
1
tests/infer_missing_types_test/expected/005_more_specific.php.expected
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 @@ | ||
src/005_more_specific.php:3 PhanReadOnlyPublicProperty Possibly zero write references to public property \TestSpecific->m |
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,42 @@ | ||
<?php | ||
class TestSpecific { | ||
public $m=5; | ||
public $validList=false; | ||
/** | ||
* @return array{s:?int,e:?int} | ||
*/ | ||
public function item() { | ||
$s=rand(0,$this->m);$e=rand(0,$this->m); | ||
if($s==0)$s=null; | ||
if($e==0)$e=null; | ||
return ['s'=>$s,'e'=>$e]; | ||
} | ||
|
||
/** | ||
* @return array<array{s:?int,e:?int}> | ||
*/ | ||
public function list() { | ||
$result=[]; | ||
$l=[0,1,2,3,4,5]; // Array to use foreach to be close to project case | ||
foreach($l as $_) { | ||
$result[]=$this->item(); | ||
} | ||
return $result; | ||
} | ||
|
||
|
||
/** | ||
* @return array<array{s:?int,e:?int}> | ||
*/ | ||
public function validList() { | ||
$result=[]; | ||
if($this->validList) { | ||
$result=$this->list(); | ||
} | ||
return $result; | ||
} | ||
} | ||
$t = new TestSpecific(); | ||
var_dump($t->validList()); | ||
$t->validList=true; | ||
var_dump($t->validList()); |