Skip to content

Commit

Permalink
Merge pull request #28 from maximilian-walter/master
Browse files Browse the repository at this point in the history
Bugfix for commands with a namespace
  • Loading branch information
keywan-ghadami-oxid authored Jan 17, 2020
2 parents 56caf47 + 05568dd commit eaae78b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Core/CommandCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Composer\Repository\InstalledFilesystemRepository;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\Module\ModuleList;
use ReflectionClass;
use ReflectionException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -275,7 +277,15 @@ private function getAllClassesFromPhpFile($pathToPhpFile)
//this avoids warnings when module developer use there own command base class, that is not instantiable
$name = basename($pathToPhpFile, '.php');
foreach ($newClasses as $newClass) {
if ($newClass == $name) {
// The filename does not contain the namespace of a class, so use the short-name of the class for
// comparison
try {
$newClassWithoutNamespace = (new ReflectionClass($newClass))->getShortName();
} catch (ReflectionException $exception) {
$newClassWithoutNamespace = $newClass;
}

if ($newClassWithoutNamespace == $name) {
return [$newClass];
}
}
Expand Down

0 comments on commit eaae78b

Please sign in to comment.