Skip invalid PSR-0/4 classes from optimized autoloader, fixes #8403
parent
94e6cfc521
commit
24a5a0dacb
|
@ -110,8 +110,7 @@ class ClassMapGenerator
|
|||
|
||||
foreach ($classes as $class) {
|
||||
// skip classes not within the given namespace prefix
|
||||
// TODO enable in Composer v1.11 or 2.0 whichever comes first
|
||||
if (/* null === $autoloadType && */ null !== $namespace && '' !== $namespace && 0 !== strpos($class, $namespace)) {
|
||||
if (null === $autoloadType && null !== $namespace && '' !== $namespace && 0 !== strpos($class, $namespace)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -180,19 +179,15 @@ class ClassMapGenerator
|
|||
// warn only if no valid classes, else silently skip invalid
|
||||
if (empty($validClasses)) {
|
||||
foreach ($rejectedClasses as $class) {
|
||||
trigger_error(
|
||||
"Class $class located in ".preg_replace('{^'.preg_quote(getcwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. It will not autoload anymore in Composer v2.0.",
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
if ($io) {
|
||||
$io->writeError("<warning>Class $class located in ".preg_replace('{^'.preg_quote(getcwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO enable in Composer 2.0
|
||||
//return array();
|
||||
return array();
|
||||
}
|
||||
|
||||
// TODO enable in Composer 2.0 & unskip test in AutoloadGeneratorTest::testPSRToClassMapIgnoresNonPSRClasses
|
||||
//return $validClasses;
|
||||
return $classes;
|
||||
return $validClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -604,8 +604,6 @@ class AutoloadGeneratorTest extends TestCase
|
|||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
|
||||
$this->markTestSkipped('Skipped until ClassMapGenerator ignoring of invalid PSR-x classes is enabled');
|
||||
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('psr0_' => 'psr0/'),
|
||||
'psr-4' => array('psr4\\' => 'psr4/'),
|
||||
|
|
Loading…
Reference in New Issue