mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #3211 from kinglozzer/pulls/3210-duplicate-classes
FIX: ClassManifest errors if files contain duplicate class names (fixes #3210)
This commit is contained in:
commit
91afa4ac61
@ -391,14 +391,15 @@ class SS_ClassManifest {
|
|||||||
$extends = substr($extends, 1);
|
$extends = substr($extends, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists($name, $this->classes)) {
|
$lowercaseName = strtolower($name);
|
||||||
|
if (array_key_exists($lowercaseName, $this->classes)) {
|
||||||
throw new Exception(sprintf(
|
throw new Exception(sprintf(
|
||||||
'There are two files containing the "%s" class: "%s" and "%s"',
|
'There are two files containing the "%s" class: "%s" and "%s"',
|
||||||
$name, $this->classes[$name], $pathname
|
$name, $this->classes[$lowercaseName], $pathname
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->classes[strtolower($name)] = $pathname;
|
$this->classes[$lowercaseName] = $pathname;
|
||||||
|
|
||||||
if ($extends) {
|
if ($extends) {
|
||||||
$extends = strtolower($extends);
|
$extends = strtolower($extends);
|
||||||
|
@ -126,4 +126,14 @@ class ClassManifestTest extends SapphireTest {
|
|||||||
public function testManifestExcludeFilesPrefixedWithUnderscore() {
|
public function testManifestExcludeFilesPrefixedWithUnderscore() {
|
||||||
$this->assertNotContains('ignore', array_keys($this->manifest->getClasses()));
|
$this->assertNotContains('ignore', array_keys($this->manifest->getClasses()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assert that ClassManifest throws an exception when it encounters two files
|
||||||
|
* which contain classes with the same name
|
||||||
|
* @expectedException Exception
|
||||||
|
*/
|
||||||
|
public function testManifestWarnsAboutDuplicateClasses() {
|
||||||
|
$dummy = new SS_ClassManifest(dirname(__FILE__) . '/fixtures/classmanifest_duplicates', false, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
class TESTClass { }
|
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
class testCLASS { }
|
Loading…
x
Reference in New Issue
Block a user