nette / php-generator

🐘 Generates neat PHP code for you. Supports new PHP 8.3 features.
https://doc.nette.org/php-generator
Other
2.11k stars 138 forks source link

Extended interfaces are marked as implemented in ClassType::from #87

Closed iggyvolz closed 3 years ago

iggyvolz commented 3 years ago

Version: 3.5.4 (also reproduced on master)

Bug Description

When performing a ClassType::from on an interface which extends another interface, the relation is marked as an implements relationship rather than an extends relationship.

Steps To Reproduce

<?php
require_once __DIR__ . "/vendor/autoload.php";
interface a{}
interface b extends a{}
echo \Nette\PhpGenerator\ClassType::from(b::class);

Gives:

interface b implements a
{
}

Expected Behavior

interface b extends a
{
}

Possible Solution

The check here https://github.com/nette/php-generator/blob/a375837e177728f8f85e0ae1dda1d57e0d7cb02d/src/PhpGenerator/Factory.php#L44 may need to split based on whether the class is an interface or not - from my understanding interfaces can only extend other interfaces.

dg commented 3 years ago

fixed