8000 [DependencyInjection] Container lint fails comparing callable "type mismatch" · Issue #38056 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DependencyInjection] Container lint fails comparing callable "type mismatch" #38056

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

Closed
stloyd opened this issue Sep 4, 2020 · 6 comments
Closed

Comments

@stloyd
Copy link
Contributor
stloyd commented Sep 4, 2020

Symfony version(s) affected: 5.1.x (probably also lower)

Description

How to reproduce
Found while working with Doctrine Migrations & related bundle: SyliusLabs/DoctrineMigrationsExtraBundle#6

Exact error:

Invalid definition for service "doctrine.migrations.dependency_factory": argument 2 of
"Doctrine\Migrations\DependencyFactory::setDefinition" accepts "callable",
"SyliusLabs\DoctrineMigrationsExtraBundle\Factory\ContainerAwareVersionFactory" passed.

Doctrine migration uses ServiceClosureArgument:

        foreach ($config['services'] as $doctrineId => $symfonyId) {
            $diDefinition->addMethodCall('setDefinition', [$doctrineId, new ServiceClosureArgument(new Reference($symfonyId))]);
        }

Method definition:

    public function setDefinition(string $id, callable $service) : void
    {
        $this->assertNotFrozen();
        $this->factories[$id] = $service;
    }

Possible Solution
🤷 maybe transform ServiceClosureArgument in lint to callable? Or maybe the Doctrine should use \Closure not callable?

@hallboav
Copy link
Contributor

The same behavior happens in Symfony 4.4.

# 5.1
composer create-project symfony/skeleton:v5.1.99 /tmp/sf51 \
&& cd /tmp/sf51 \
&& composer require orm migrations sylius-labs/doctrine-migrations-extra-bundle \
&& (cat << CONFIG
    services:
        'Doctrine\Migrations\Version\MigrationFactory': 'SyliusLabs\DoctrineMigrationsExtraBundle\Factory\ContainerAwareVersionFactory'
CONFIG
) >> config/packages/doctrine_migrations.yaml \
&& bin/console lint:container

# 4.4
composer create-project symfony/skeleton:v4.4.99 /tmp/sf44 \
&& cd /tmp/sf44 \
&& composer require orm migrations sylius-labs/doctrine-migrations-extra-bundle \
&& (cat << CONFIG
    services:
        'Doctrine\Migrations\Version\MigrationFactory': 'SyliusLabs\DoctrineMigrationsExtraBundle\Factory\ContainerAwareVersionFactory'
CONFIG
) >> config/packages/doctrine_migrations.yaml \
&& bin/console lint:container

@hallboav
Copy link
Contributor

Related issue: doctrine/DoctrineMigrationsBundle#352

@goetas
Copy link
Contributor
goetas commented Sep 17, 2020

Should be fixed in doctrine-migrations-bundle, by doctrine/DoctrineMigrationsBundle#368

@nicolas-grekas
Copy link
Member

Thanks for investigating and the heads up. Closing therefor.

@timfennis
Copy link
timfennis commented May 3, 2021

I've updated to 3.1.x and I'm still getting this issue, am I going insane?


Edit: Running with --env prod as a temporary workaround.

@nicolas-grekas
Copy link
Member

You might hit #39259

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

No branches or pull requests

7 participants
0