-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when template types map and variances map are not of equal …
…length
- Loading branch information
1 parent
c6fad64
commit 1308c52
Showing
3 changed files
with
101 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug10049Recursive; | ||
|
||
/** | ||
* @template SELF of SimpleEntity<SELF> | ||
*/ | ||
abstract class SimpleEntity | ||
{ | ||
/** | ||
* @param SimpleTable<SELF> $table | ||
*/ | ||
public function __construct(protected readonly SimpleTable $table) | ||
{ | ||
} | ||
} | ||
|
||
/** | ||
* @template-covariant E of SimpleEntity | ||
*/ | ||
class SimpleTable | ||
{ | ||
/** | ||
* @template ENTITY of SimpleEntity | ||
* | ||
* @param class-string<ENTITY> $className | ||
* | ||
* @return SimpleTable<ENTITY> | ||
*/ | ||
public static function table(string $className, string $name): SimpleTable | ||
{ | ||
return new SimpleTable($className, $name); | ||
} | ||
|
||
/** | ||
* @param class-string<E> $className | ||
*/ | ||
private function __construct(readonly string $className, readonly string $table) | ||
{ | ||
} | ||
} | ||
|
||
/** | ||
* @template-extends SimpleEntity<TestEntity> | ||
*/ | ||
class TestEntity extends SimpleEntity | ||
{ | ||
public function __construct() | ||
{ | ||
$table = SimpleTable::table(TestEntity::class, 'testentity'); | ||
parent::__construct($table); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* @template-extends SimpleEntity<AnotherEntity> | ||
*/ | ||
class AnotherEntity extends SimpleEntity | ||
{ | ||
public function __construct() | ||
{ | ||
$table = SimpleTable::table(AnotherEntity::class, 'anotherentity'); | ||
parent::__construct($table); | ||
} | ||
} |