Skip to content

Commit bc92fb0

Browse files
committed
Allow creation of classes with the same name as PHP native classes
1 parent dcd2260 commit bc92fb0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Generator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ public function createClassNameDetails(string $name, string $namespacePrefix, st
188188
$className = Str::asClassName($name, $suffix);
189189

190190
try {
191-
Validator::classDoesNotExist($className);
192191
$className = rtrim($fullNamespacePrefix, '\\').'\\'.$className;
192+
Validator::classDoesNotExist($className);
193193
} catch (RuntimeCommandException) {
194194
}
195195
}

tests/Maker/MakeEntityTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,19 @@ public function getTestDetails(): \Generator
762762
$this->runEntityTest($runner);
763763
}),
764764
];
765+
766+
yield 'its_can_create_classes_with_native_class_name' => [$this->createMakeEntityTest()
767+
->run(function (MakerTestRunner $runner) {
768+
$runner->runMaker([
769+
// entity class name
770+
'Directory',
771+
// add not additional fields
772+
'',
773+
]);
774+
775+
$this->runEntityTest($runner);
776+
}),
777+
];
765778
}
766779

767780
/** @param array<string, mixed> $data */

0 commit comments

Comments
 (0)