theseer / Autoload

A lightweight php namespace aware autoload generator and phar archive builder
Other
388 stars 47 forks source link

Array to string conversion on parsing composer.json #98

Closed FelixJacobi closed 3 years ago

FelixJacobi commented 3 years ago

Hi,

Consider the following psr-4 autoload definition in a composer.json:

    "autoload": {
        "psr-4": {
            "": ["../src/", "modules/"],
            "MyApp\\": "src/"
        }
    },

The first definition contains an array of the paths to search in. For Composer this is a valid configuration. phpab throws an array to string conversion warning when parsing such a file:

PHP Warning:  Array to string conversion in phar:///home/VERTRIEB/felix.jacobi/.phive/phars/phpab-1.26.0.phar/phpab/ComposerIterator.php on line 50
PHP Stack trace:
PHP   1. {main}() /home/VERTRIEB/felix.jacobi/.phive/phars/phpab-1.26.0.phar:0
PHP   2. TheSeer\Autoload\CLI->run() /home/VERTRIEB/felix.jacobi/.phive/phars/phpab-1.26.0.phar:155
PHP   3. TheSeer\Autoload\Application->run() phar:///home/VERTRIEB/felix.jacobi/.phive/phars/phpab-1.26.0.phar/phpab/CLI.php:101
PHP   4. TheSeer\Autoload\Application->runCollector() phar:///home/VERTRIEB/felix.jacobi/.phive/phars/phpab-1.26.0.phar/phpab/Application.php:53
PHP   5. TheSeer\Autoload\Config->getDirectories() phar:///home/VERTRIEB/felix.jacobi/.phive/phars/phpab-1.26.0.phar/phpab/Application.php:86
PHP   6. TheSeer\Autoload\ComposerIterator->__construct($composerFile = class SplFileInfo { private $pathName = 'root/git/projects/vendor/web/composer.json'; private $fileName = 'composer.json' }) phar:///home/VERTRIEB/felix.jacobi/.phive/phars/phpab-1.26.0.phar/phpab/Config.php:394
PHP   7. TheSeer\Autoload\ComposerIterator->processAutoload($baseDir = '/home/VERTRIEB/unencrypted/felix.jacobi/,y-project/root/git/projects/vendor/web', $map = ['psr-4' => ['' => [...], 'MyApp\' => 'src/']]) phar:///home/VERTRIEB/felix.jacobi/.phive/phars/phpab-1.26.0.phar/phpab/ComposerIterator.php:33
theseer commented 3 years ago

Nice catch.

theseer commented 3 years ago

Fixed with Release 1.26.1.

FelixJacobi commented 3 years ago

Works fine for me. Thanks!