8000 Composer does not respect plugin files autoload requirements · Issue #10024 · composer/composer · GitHub
[go: up one dir, main page]

Skip to content
Composer does not respect plugin files autoload requirements #10024
@cs278

Description

@cs278

Composer does not appear to load the files section of the autoload definition for plugins. This appears to hold true for the plugin itself and any dependencies, I expect this might be a design decision but I cannot see it documented anywhere. I've stumbled upon this while investigating a problem with the new releases of symfony/yaml package using PHP 8 functions breaking plugins on PHP 7.4 which led me to symfony/symfony#42280. I've put together a test plugin to demonstrate the problem.

My composer.json:

{
    "repositories": [{
            "type": "git",
            "url": "https://github.com/cs278/composer-include-test-plugin"
        }],
    "require": {
        "cs278/composer-include-test-plugin": "@dev"
    }
}

Output of composer diagnose:

Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
require.cs278/composer-include-test-plugin : unbound version constraints (@dev) should be avoided
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version: OK
Composer version: 2.1.5
PHP version: 7.4.21
PHP binary path: /usr/bin/php7.4
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018
cURL version: 7.58.0 libz 1.2.11 ssl OpenSSL/1.1.1
zip: extension present, unzip present, 7-Zip present (7z)

When I run this command:

php -f composer.phar test-plugin -vvv

I get the following output:

Reading ./composer.json (/tmp/chris.smith/tmp.DROuBGKkqm/composer.json)
Loading config file ./composer.json (/tmp/chris.smith/tmp.DROuBGKkqm/composer.json)
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/tmp/chris.smith/tmp.DROuBGKkqm): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/chris.smith/tmp.DROuBGKkqm): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/tmp/chris.smith/tmp.DROuBGKkqm): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/chris.smith/tmp.DROuBGKkqm): hg branch
Executing command (/tmp/chris.smith/tmp.DROuBGKkqm): fossil branch list
Executing command (/tmp/chris.smith/tmp.DROuBGKkqm): fossil tag list
Executing command (/tmp/chris.smith/tmp.DROuBGKkqm): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /tmp/chris.smith/tmp.DROuBGKkqm/.composer/composer.json

Reading /tmp/chris.smith/tmp.DROuBGKkqm/vendor/composer/installed.json
Loading plugin Cs278\ComposerIncludeTestPlugin\ComposerPlugin (from cs278/composer-include-test-plugin)
Running 2.1.5 (2021-07-23 10:35:47) with PHP 7.4.21 on Linux / 5.4.0-80-generic
PHP/7.4.21
str_contains? NO
bootstrap.php included? NO
PHP Fatal error:  Uncaught Error: Call to undefined function Symfony\Component\Yaml\str_starts_with() in /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Inline.php:567
Stack trace:
#0 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Inline.php(459): Symfony\Component\Yaml\Inline::evaluateScalar()
#1 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Inline.php(85): Symfony\Component\Yaml\Inline::parseMapping()
#2 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Parser.php(384): Symfony\Component\Yaml\Inline::parse()
#3 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Parser.php(97): Symfony\Component\Yaml\Parser->doParse()
#4 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Yaml.php(80): Symfony\Component\Yaml\Parser->parse()
#5 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/cs278/composer-include-test-plugin/src/TestCommand.php(33): Symfony\Component\Yaml\Yaml::parse()
#6 phar:///tmp/chris.smith/tmp.DROuBGKkqm/composer.phar/vendor/symfony/console/Command/Command.php(245): Cs278\ComposerIncludeTestPlugin\TestCommand-> in /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Inline.php on line 567

Fatal error: Uncaught Error: Call to undefined function Symfony\Component\Yaml\str_starts_with() in /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Inline.php:567
Stack trace:
#0 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Inline.php(459): Symfony\Component\Yaml\Inline::evaluateScalar()
#1 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Inline.php(85): Symfony\Component\Yaml\Inline::parseMapping()
#2 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Parser.php(384): Symfony\Component\Yaml\Inline::parse()
#3 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Parser.php(97): Symfony\Component\Yaml\Parser->doParse()
#4 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Yaml.php(80): Symfony\Component\Yaml\Parser->parse()
#5 /tmp/chris.smith/tmp.DROuBGKkqm/vendor/cs278/composer-include-test-plugin/src/TestCommand.php(33): Symfony\Component\Yaml\Yaml::parse()
#6 phar:///tmp/chris.smith/tmp.DROuBGKkqm/composer.phar/vendor/symfony/console/Command/Command.php(245): Cs278\ComposerIncludeTestPlugin\TestCommand-> in /tmp/chris.smith/tmp.DROuBGKkqm/vendor/symfony/yaml/Inline.php on line 567

And I expected this to happen:

PHP/7.4.21
str_contains? YES (user-defined)
bootstrap.php included? YES
Yaml::parse? Array
(
    [foo] => bar
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0