Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix interaction between template type and union type
- Loading branch information
Showing
6 changed files
with
280 additions
and
7 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
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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bug5591; | ||
|
||
class EntityA {} | ||
class EntityB {} | ||
|
||
/** | ||
* @template TEntity as object | ||
*/ | ||
class TestClass | ||
{ | ||
/** @var class-string<TEntity> The fully-qualified (::class) class name of the entity being managed. */ | ||
protected $entityClass; | ||
|
||
/** @param TEntity|null $record */ | ||
public function outerMethod($record = null): void | ||
{ | ||
$record = $this->innerMethod($record); | ||
} | ||
|
||
/** | ||
* @param TEntity|null $record | ||
* | ||
* @return TEntity | ||
*/ | ||
public function innerMethod($record = null): object | ||
{ | ||
return new ($this->entityClass)(); | ||
} | ||
} | ||
|
||
/** | ||
* @template TEntity as EntityA|EntityB | ||
* @extends TestClass<TEntity> | ||
*/ | ||
class TestClass2 extends TestClass | ||
{ | ||
public function outerMethod($record = null): void | ||
{ | ||
$record = $this->innerMethod($record); | ||
} | ||
} |
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