-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OverridingMethodRule - check return type covariance
- Loading branch information
1 parent
f478b91
commit ada27eb
Showing
5 changed files
with
173 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
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
71 changes: 71 additions & 0 deletions
71
tests/PHPStan/Rules/Methods/data/return-type-covariance.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,71 @@ | ||
<?php | ||
|
||
namespace ReturnTypeCovariance; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo(): iterable | ||
{ | ||
|
||
} | ||
|
||
public function doBar(): array | ||
{ | ||
|
||
} | ||
|
||
public function doBaz(): \Exception | ||
{ | ||
|
||
} | ||
|
||
public function doLorem(): \InvalidArgumentException | ||
{ | ||
|
||
} | ||
|
||
} | ||
|
||
class Bar extends Foo | ||
{ | ||
|
||
public function doFoo(): array | ||
{ | ||
|
||
} | ||
|
||
public function doBar(): iterable | ||
{ | ||
|
||
} | ||
|
||
public function doBaz(): \InvalidArgumentException | ||
{ | ||
|
||
} | ||
|
||
public function doLorem(): \Exception | ||
{ | ||
|
||
} | ||
|
||
} | ||
|
||
class A | ||
{ | ||
|
||
public function foo(string $s): ?\stdClass | ||
{ | ||
|
||
} | ||
} | ||
class B extends A | ||
{ | ||
|
||
public function foo($s) | ||
{ | ||
return rand(0, 1) ? new stdClass : null; | ||
} | ||
|
||
} |