Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORMExecutor->execute expects diffrented class than Loader->getFixures() returns #414

Closed
ghost opened this issue Jan 3, 2023 · 7 comments · Fixed by #416
Closed

ORMExecutor->execute expects diffrented class than Loader->getFixures() returns #414

ghost opened this issue Jan 3, 2023 · 7 comments · Fixed by #416

Comments

@ghost
Copy link

ghost commented Jan 3, 2023

I get the following error from latest versions:

  Line   tests/Functional/FunctionalTestCase.php                                                                                                                      
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  91     Parameter #1 $fixtures of method Doctrine\Common\DataFixtures\Executor\ORMExecutor::execute() expects array<Doctrine\Common\DataFixtures\FixtureInterface>,  
         array<class-string<Doctrine\Common\DataFixtures\OrderedFixtureInterface>|int, Doctrine\Common\DataFixtures\OrderedFixtureInterface> given.    

I think it could be resolved if OrderedFixtureInterface extends from FixtureInterface

@greg0ire
Copy link
Member

greg0ire commented Jan 3, 2023

OrderedFixtureInterface doesn't extend FixtureInterface, which probably means something like OrderedFixtureInterface&FixtureInterface should be used somewhere.

@greg0ire
Copy link
Member

greg0ire commented Jan 3, 2023

Hard to tell where without the source code of tests/Functional/FunctionalTestCase.php, of course.

@ghost
Copy link
Author

ghost commented Jan 3, 2023

@greg0ire this is what the class looks like:

xxx

    protected function refreshFixtures(): void
    {
        $loader = new Doctrine\Common\DataFixtures\Loader();
        $fixture = new CustomFixture();
        $fixture->setContainer($this->getKernelBrowser()->getContainer());
        $loader->addFixture($fixture);
        $purger = new Doctrine\Common\DataFixtures\Purger\ORMPurger();
        $executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor($this->getEntityManager(), $purger);
        $executor->execute($loader->getFixtures());
    }

@greg0ire
Copy link
Member

greg0ire commented Jan 3, 2023

Ok, so the issue is with

* @psalm-return array<class-string<OrderedFixtureInterface>|int, OrderedFixtureInterface>

Do you feel up to making it more precise?

Kind of makes me wonder why OrderedFixtureInterface doesn't extend FixtureInterface in the first place though 🤔

@ghost
Copy link
Author

ghost commented Jan 3, 2023

Ok, so the issue is with

* @psalm-return array<class-string<OrderedFixtureInterface>|int, OrderedFixtureInterface>

Do you feel up to making it more precise?

Kind of makes me wonder why OrderedFixtureInterface doesn't extend FixtureInterface in the first place though thinking

Yes i think its in the Loader.php, i haven't debugged the issue much i could try to change the return types but i also wonder why that OrderedFixtureInterface doesn't extend from FixtureInterface haha i dont know who introduced it maybe they know best.

I saw docs updates where done in #389 but they made it consistent with the property $fixtures docs

@greg0ire
Copy link
Member

greg0ire commented Jan 3, 2023

i dont know who introduced it maybe they know best

If only there was a way for us to know that, like some kind of code history tool 🤔

Trolling aside it was introduced more than 10 years ago in #5 , so… long shot, but @l3pp4rd , super long shot, but maybe you have some input you can provide on this?

@ghost
Copy link
Author

ghost commented Jan 3, 2023

Haha fair, i didn't look that fair back ;p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant