Skip to content

Commit

Permalink
Filter composer dependencies with empty namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosas authored Jun 29, 2020
1 parent 790e6de commit e6dbfbf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

## 0.7.1
* Fix composer dependencies with empty namespace selected as `*`

## 0.7.0
* Package name changed to `phpat/phpat`
* Add support for tests in YAML and XML files
Expand Down
15 changes: 8 additions & 7 deletions src/Parser/ComposerFileParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,17 @@ public function getDirectDependencies(bool $dev): array
*/
public function autoloadableNamespacesForRequirements(array $requirements)
{
$namespaces = [];

foreach ($requirements as $package) {
$namespaces = array_merge(
$namespaces,
$this->extractNamespaces($this->lockedPackages[ $package ], false)
);
$n = $this->extractNamespaces($this->lockedPackages[$package], false);
foreach ($n as $k => $v) {
if (empty($v)) {
unset($n[$k]);
}
}
$namespaces = array_merge($namespaces ?? [], $n);
}

return $namespaces;
return $namespaces ?? [];
}

public function getComposerFilePath(): string
Expand Down

0 comments on commit e6dbfbf

Please sign in to comment.