From d5888cff3ff3ebba15ade6adda67cecbde7b69c6 Mon Sep 17 00:00:00 2001 From: Arne Blankerts Date: Mon, 14 Jun 2021 22:50:44 +0200 Subject: [PATCH] Fix Issue #98 --- CHANGELOG.md | 4 ++++ src/ComposerIterator.php | 7 +++++++ tests/ComposerIteratorTest.php | 12 ++++++++++++ tests/_data/composer-array-issue-98/composer.json | 13 +++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 tests/_data/composer-array-issue-98/composer.json diff --git a/CHANGELOG.md b/CHANGELOG.md index e50981e..84af350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Release 1.26.1 +* Fix Issue [#98](https://github.com/theseer/Autoload/issues/98): Array to string conversion on parsing composer.json + + ## Release 1.26.0 * Fix Issue [#95](https://github.com/theseer/Autoload/pull/95): Update Parser to work with PHP 8.0's new tokens * Fix Issue [#90](https://github.com/theseer/Autoload/pull/90): Warnings and Notices in ComposerIterator diff --git a/src/ComposerIterator.php b/src/ComposerIterator.php index 3c4bc8f..6f59a49 100644 --- a/src/ComposerIterator.php +++ b/src/ComposerIterator.php @@ -47,6 +47,13 @@ private function processAutoload($baseDir, array $map) { $this->addDirectory($baseDir); continue; } + if (is_array($dir)) { + foreach($dir as $d) { + $this->addDirectory($baseDir . '/' . $d); + } + + continue; + } $this->addDirectory($baseDir . '/' . $dir); } } diff --git a/tests/ComposerIteratorTest.php b/tests/ComposerIteratorTest.php index d8e0202..deee126 100644 --- a/tests/ComposerIteratorTest.php +++ b/tests/ComposerIteratorTest.php @@ -16,4 +16,16 @@ public function testRecursionIsHandledProperly() { } } + public function testPSR14ArrayIsSupported() { + $iterator = new ComposerIterator(new \SplFileInfo(__DIR__ . '/_data/composer-array-issue-98/composer.json')); + $expected = array( + __DIR__ . '/_data/composer-array-issue-98/../src', + __DIR__ . '/_data/composer-array-issue-98/modules', + __DIR__ . '/_data/composer-array-issue-98/src' + ); + foreach($iterator as $pos => $entry) { + $this->assertEquals($expected[$pos], $entry); + } + } + } diff --git a/tests/_data/composer-array-issue-98/composer.json b/tests/_data/composer-array-issue-98/composer.json new file mode 100644 index 0000000..4a2ce7e --- /dev/null +++ b/tests/_data/composer-array-issue-98/composer.json @@ -0,0 +1,13 @@ +{ + "name": "issue/98", + "require": { + "php": ">= 5.5.9", + "bar/foo": "0.0" + }, + "autoload": { + "psr-4": { + "": ["../src/", "modules/"], + "MyApp\\": "src/" + } + } +}