nette / php-generator

🐘 Generates neat PHP code for you. Supports new PHP 8.3 features.

Home Page:https://doc.nette.org/php-generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extended interfaces are marked as implemented in ClassType::from

iggyvolz opened this issue · comments

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

$class->setImplements(array_diff($class->getImplements(), $from->getParentClass()->getInterfaceNames()));
may need to split based on whether the class is an interface or not - from my understanding interfaces can only extend other interfaces.

fixed