json-to-php-generator icon indicating copy to clipboard operation
json-to-php-generator copied to clipboard

Duplicate classes

Open dbannik opened this issue 2 years ago • 2 comments

Source

{
    "elements": {
        "test": 1,
        "elements": [
            {
                "elements": {
                    "test": 1,
                    "elements": []
                }
            }
        ]
    }
}

Result

final class RootObject
{
	public Elements $elements;

}

final class Elements
{
	public int $test;
	/** @var Elements[] */
	public array $elements;

}

final class Elements
{
	public Elements $elements;

}

final class Elements
{
	public int $test;
	public array $elements;

}

dbannik avatar May 04 '23 12:05 dbannik

Hi,

Thank you for reporting this issue. I think we should add incrementing suffixes to nested classes with the same name to make it clear which object is being used. It's hard to determine which nested classes are of the same type, so we can't just merge the classes with the same name.

jacobdekeizer avatar May 04 '23 17:05 jacobdekeizer

I ran into this as well. The duplicated files are identical and if they are they can be rendered only once.

spatelwearpact avatar May 09 '24 20:05 spatelwearpact