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

Unable to handle non-array psr-4 autoload directories #36

Open
edmondscommerce opened this issue Apr 20, 2018 · 2 comments
Open

Unable to handle non-array psr-4 autoload directories #36

edmondscommerce opened this issue Apr 20, 2018 · 2 comments
Labels

Comments

@edmondscommerce
Copy link
Owner

If you set your psr-4 autoload directory as:

    "autoload": {
        "psr-4": {
            "EdmondsCommerce\\Vault\\": "src/"
        }
    },

Rather than:

    "autoload": {
        "psr-4": {
            "EdmondsCommerce\\Vault\\": [
                "src/"
            ]
        }
    },

Then you get the following error:

PHP Fatal error:  Uncaught EdmondsCommerce\DoctrineStaticMeta\Exception\ErrorException: Invalid argument supplied for foreach()

The issue is in NamespaceHelper->getProjectRootNamespaceFromComposerJson():427

// ...
                foreach ($json['autoload']['psr-4'] as $namespace => $dirs) {
                    foreach ($dirs as $dir) { // <-- Here $dirs is a string
                        $dir = trim($dir, '/');
                        if ($dir === $dirForNamespace) {
                            return $this->tidy(rtrim($namespace, '\\'));
                        }
                    }
                }
// ...
@edmondscommerce
Copy link
Owner Author

Will need to change the JSON decode to force assoc, it's just a bool flag

@edmondscommerce
Copy link
Owner Author

actually scratch that, we need to check if its an array and then if not give a more helpful error message

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

No branches or pull requests

1 participant