From 60938697f1866cf430bc8aa1d0c066c4590e9e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Mon, 10 Jul 2023 00:49:34 +0200 Subject: [PATCH] qa: add failing test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- tests/Template/ClassTemplateTest.php | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/Template/ClassTemplateTest.php b/tests/Template/ClassTemplateTest.php index 3858da04d8f..1ecf5fc6f32 100644 --- a/tests/Template/ClassTemplateTest.php +++ b/tests/Template/ClassTemplateTest.php @@ -4207,6 +4207,68 @@ public function aggregate(...$values): null|int|float 'ignored_issues' => [], 'php_version' => '8.0', ], + 'inheritedConditionalsWithMatchingTypes' => [ + 'code' => '|string $id + * @return ($id is class-string ? TRequestedInstance : InstanceType) + * @throws InvalidArgumentException + */ + public function get(string $id): mixed; + } + + interface PluginInterface + {} + + class ConcretePlugin implements PluginInterface + {} + + /** + * @template InstanceType + * @template-implements PluginManagerInterface + */ + abstract class AbstractPluginManager implements PluginManagerInterface + { + public function get(string $id): mixed + { + throw new InvalidArgumentException(); + } + } + + /** + * @template InstanceType of object + * @template-extends AbstractPluginManager + */ + abstract class AbstractSingleInstancePluginManager extends AbstractPluginManager + { + /** + * {@inheritDoc} + */ + public function get(string $id): object + { + return parent::get($id); + } + } + + /** @template-extends AbstractSingleInstancePluginManager */ + class ConcretePluginManager extends AbstractSingleInstancePluginManager + {} + + $plugins = new ConcretePluginManager(); + $classString = $plugins->get(ConcretePlugin::class); + $string = $plugins->get("foo"); + ', + 'assertions' => [ + '$classString' => 'ConcretePlugin', + '$string' => 'PluginInterface', + ], + 'ignored_issues' => [], + 'php_version' => '8.0', + ], ]; }