Skip to content

Generator example from DocBlock will not work #1371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Antarian opened this issue Oct 12, 2023 · 1 comment
Closed

Generator example from DocBlock will not work #1371

Antarian opened this issue Oct 12, 2023 · 1 comment
Labels

Comments

@Antarian
Copy link
Contributor

* $gen->createClassNameDetails('Cool\\Stuff\\Balloon', 'Controller', 'Controller');

In current implementation name either needs to be absolute, or to make it work generator code needs to change.
E.g. change line 150

$className = rtrim($fullNamespacePrefix, '\\').'\\'.Str::asClassName($name, $suffix);

to:

try {
    Validator::classDoesNotExist($name);
    $className = rtrim($fullNamespacePrefix, '\\').'\\'.Str::asClassName($name, $suffix);
} catch (RuntimeCommandException $e) {
    $className = $name;
}

This would have edge case if there is match with class even if $name value is only partial. But that should be very rare.
Like Prototype\\DummyEntity may exist and we really want "App\Entity\Prototype\DummyEntity".

@weaverryan
Copy link
Member

I'm open to a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants