diff --git a/src/Validator.php b/src/Validator.php index 4682624f5..6dc611494 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -195,6 +195,9 @@ public static function classExists(string $className, string $errorMessage = '') { self::notBlank($className); + // normalize class name + $className = str_replace('\\\\', '\\', $className); + if (!class_exists($className)) { $errorMessage = $errorMessage ?: \sprintf('Class "%s" doesn\'t exist; please enter an existing full class name.', $className); @@ -247,7 +250,7 @@ public static function classIsUserInterface($userClassName): string public static function classIsBackedEnum($backedEnum): string { - self::classExists($backedEnum); + $backedEnum = self::classExists($backedEnum); if (!isset(class_implements($backedEnum)[\BackedEnum::class])) { throw new RuntimeCommandException(\sprintf('The class "%s" is not a valid BackedEnum.', $backedEnum)); diff --git a/tests/Maker/MakeEntityTest.php b/tests/Maker/MakeEntityTest.php index 54059bad3..95fb27add 100644 --- a/tests/Maker/MakeEntityTest.php +++ b/tests/Maker/MakeEntityTest.php @@ -762,6 +762,28 @@ public function getTestDetails(): \Generator $this->runEntityTest($runner); }), ]; + + yield 'it_does_not_throw_error_with_double_slashes' => [$this->createMakeEntityTest() + ->run(function (MakerTestRunner $runner) { + $this->copyEntity($runner, 'Enum/Role-basic.php'); + + $runner->runMaker([ + // entity class name + 'User', + // add additional field + 'role', + 'enum', + 'App\\\\Entity\\\\Enum\\\\Role', + '', + // nullable + 'y', + // finish adding fields + '', + ]); + + $this->runEntityTest($runner); + }), + ]; } /** @param array $data */