mirror of
https://github.com/danog/class-finder.git
synced 2025-01-23 06:11:26 +01:00
Refactor to account for psr4 namespaces from dependencies
This commit is contained in:
parent
387434def0
commit
f0423a39d4
@ -66,15 +66,12 @@ class AppConfig
|
||||
*/
|
||||
public function getPSR4Namespaces()
|
||||
{
|
||||
$appRoot = $this->getAppRoot();
|
||||
$this->throwIfInvalidAppRoot($appRoot);
|
||||
$namespaces = $this->getUserDefinedPSR4Namespaces();
|
||||
|
||||
$composerJsonPath = $appRoot. 'composer.json';
|
||||
$composerConfig = json_decode(file_get_contents($composerJsonPath));
|
||||
// This is broken.
|
||||
// $vendorNamespaces = require($this->getAppRoot() . 'vendor/composer/autoload_psr4.php');
|
||||
|
||||
//Apparently PHP doesn't like hyphens, so we use variable variables instead.
|
||||
$psr4 = "psr-4";
|
||||
return (array) $composerConfig->autoload->$psr4;
|
||||
return $namespaces;
|
||||
}
|
||||
|
||||
|
||||
@ -97,4 +94,20 @@ class AppConfig
|
||||
{
|
||||
$this->appRoot = $appRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getUserDefinedPSR4Namespaces()
|
||||
{
|
||||
$appRoot = $this->getAppRoot();
|
||||
$this->throwIfInvalidAppRoot($appRoot);
|
||||
|
||||
$composerJsonPath = $appRoot . 'composer.json';
|
||||
$composerConfig = json_decode(file_get_contents($composerJsonPath));
|
||||
|
||||
//Apparently PHP doesn't like hyphens, so we use variable variables instead.
|
||||
$psr4 = "psr-4";
|
||||
return (array)$composerConfig->autoload->$psr4;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user