Skip to content

Commit

Permalink
Fix Issue #98
Browse files Browse the repository at this point in the history
  • Loading branch information
theseer committed Jun 14, 2021
1 parent a760231 commit d5888cf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/ComposerIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
12 changes: 12 additions & 0 deletions tests/ComposerIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

}
13 changes: 13 additions & 0 deletions tests/_data/composer-array-issue-98/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "issue/98",
"require": {
"php": ">= 5.5.9",
"bar/foo": "0.0"
},
"autoload": {
"psr-4": {
"": ["../src/", "modules/"],
"MyApp\\": "src/"
}
}
}

0 comments on commit d5888cf

Please sign in to comment.