tempest-framework icon indicating copy to clipboard operation
tempest-framework copied to clipboard

Colliding class names in view imports

Open brendt opened this issue 6 months ago • 5 comments

Let's say one view imports App\Book and another view imports App\Models\Book. Both imports will be combined in the final rendered view, and will then collide. The solution is for the user to import one or both as aliases, but there should also be a clear error explaining them what to do

brendt avatar Jul 08 '25 06:07 brendt

How about adding a self-healing feature, optionally enabling Tempest's view renderer to automatically generate aliases for any conflicting classes based on their FQCN? Not sure whether this should be enabled or disabled by default, though.

xHeaven avatar Jul 09 '25 19:07 xHeaven

I very much like @xHeaven's solution

innocenzi avatar Jul 09 '25 19:07 innocenzi

I'm playing with that idea as well, I'm not sure how easy it would be and how many edge cases we'd run into, but it might be worth exploring. I don't think it should be opt-in though.

Another idea I had is instead of combining imports at the top of each file, to open a new scope for every component and view and keep the imports scoped to that scope. But apparently, namespaces cannot be nested :(

brendt avatar Jul 10 '25 05:07 brendt

I'm playing with that idea as well, I'm not sure how easy it would be and how many edge cases we'd run into, but it might be worth exploring. I don't think it should be opt-in though.

Another idea I had is instead of combining imports at the top of each file, to open a new scope for every component and view and keep the imports scoped to that scope. But apparently, namespaces cannot be nested :(

I don't think it'd be hard, I made a PoC yesterday, I can make it into a viable MVP and open a PR if needed.

xHeaven avatar Jul 10 '25 07:07 xHeaven

Sure, sounds great!

brendt avatar Jul 10 '25 07:07 brendt