-
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.
Inferring
new
from parent constructor - reject types that would fai…
…l bound check of the child class
- Loading branch information
1 parent
dce063a
commit d06f792
Showing
2 changed files
with
77 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace Bug12386; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
function doFoo() { | ||
$landMapper = new Application_Model_Mapper_Land(); | ||
assertType('Bug12386\\Clx_Model_Iterator<Bug12386\\Application_Model_Land>', $landMapper->fetchAllActivePrependDefault(12)); | ||
} | ||
|
||
/** | ||
* @template T of Clx_Model_Abstract | ||
*/ | ||
abstract class Clx_Model_Mapper_Abstract | ||
{ | ||
public function __construct() | ||
{ | ||
} | ||
} | ||
|
||
/** | ||
* @template T of Application_Model_Land | ||
* | ||
* @extends Clx_Model_Mapper_Abstract<T> | ||
*/ | ||
class ClxProductNet_Model_Mapper_Land extends Clx_Model_Mapper_Abstract | ||
{ | ||
/** | ||
* @param int $defaultLandid | ||
* | ||
* @return Clx_Model_Iterator<T> | ||
*/ | ||
public function fetchAllActivePrependDefault($defaultLandid): Clx_Model_Iterator | ||
{} | ||
} | ||
|
||
/** | ||
* @template T of Application_Model_Land | ||
* | ||
* @extends ClxProductNet_Model_Mapper_Land<T> | ||
*/ | ||
final class Application_Model_Mapper_Land extends ClxProductNet_Model_Mapper_Land | ||
{ | ||
} | ||
|
||
/** | ||
* @template T of Clx_Model_Abstract | ||
* | ||
* @implements \Iterator<T> | ||
*/ | ||
abstract class Clx_Model_Iterator implements \Countable, \Iterator | ||
{} | ||
|
||
abstract class Clx_Model_Abstract implements \Stringable | ||
{} | ||
|
||
abstract class ClxProductNet_Model_Land extends Clx_Model_Abstract | ||
{} | ||
|
||
final class Application_Model_Land extends ClxProductNet_Model_Land | ||
{ | ||
public function __toString() | ||
{ | ||
return 'foo'; | ||
} | ||
|
||
} |