Skip to content

Dependency namespace being written on every line when overriding autoloader #134

@begroff

Description

@begroff

I have a WordPress theme which uses Timber via Composer. Timber has a dependency of a version of Twig that has the following autoloader in their composer.json.

    "autoload": {
        "psr-0" : {
            "Twig_" : "lib/"
        },
        "psr-4" : {
            "Twig\\" : "src/"
        }
    },

When I attempt to run vendor\bin\mozart compose, I get an error, File already exists at path: lib/Dependencies/Twig/Extension/InitRuntimeInterface.php. I understand why this error happens, because in the twig package they have the same set of files in different directories to support both psr-0 and psr-4 and mozart is trying to process it twice.

I attempted to override this autoloader behavior in the mozart configuration, but I don't think I'm doing it right. I tried the following:

"override_autoload": {
                "twig/twig": {
                    "psr-0" : {
                        "Twig_" : "src/"
                    },
                    "psr-4" : {
                        "Twig\\" : "src/"
                    }
                }
            },

When compose ran, it copied my dependent namespace on every line of the processed files. I also tried having psr-0 with empty curly braces and got the same behavior. I am using mozart version 0.7.1.

Am I going about this the wrong way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions