Skip to content

Generated stubs don't respect dependency order in some cases. #40

@Hug0-Drelon

Description

@Hug0-Drelon

I'm not sure if this is a real issue or not, maybe there is a way to fix this with \StubsGenerator API.

What?

Here is a generated stubs file:

<?php

namespace WP_Syntex\SomePackage;

interface FirstInterface
{
    /**
     * @return SecondInterface
     */
    public function get(): \WP_Syntex\SomePackage\SecondInterface;
}
interface SecondInterface
{
    public function getId(): int;
}
class SecondObject implements \WP_Syntex\SomePackage\SecondInterface
{
    public function __construct(int $id)
    {
    }
    public function getId(): int
    {
    }
}
class FirstObject implements \WP_Syntex\SomePackage\FirstInterface
{
    public function __construct(\WP_Syntex\SomePackage\SecondObject $second)
    {
    }
    /**
     * @return SecondObject
     */
    public function get(): \WP_Syntex\SomePackage\SecondObject
    {
    }
}

Additional information

We can see that FirstInterface depends on SecondInterface. It seems to create weird PHPStan errors (see)...

Here is the directory tree:

.
├── FirstInterface.php
├── FirstObject.php
├── SecondInterface.php
└── SecondObject.php

And the finder configuration:

return \StubsGenerator\Finder::create()
	->in('./SomePackage');

Expected result

I would expect SecondInterface to be defined before FirstInterface.
Note that this behavior occurs also with concrete classes (in Polylang stubs for instance).

Otherwise thanks for this awesome tool ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions