laravel-goto-controller icon indicating copy to clipboard operation
laravel-goto-controller copied to clipboard

Error: Cannot read substring of undefined exception when using app() helper inside a route file

Open weidmaster opened this issue 3 years ago • 3 comments

Hello @stef-k

I just happened to stumble uppon this error when checking a route file from a project and another one that is almost the exact copy of the same file, and one works and the other doesn'nt. Going to the developer tools inside Vscode gives the error and line number to check into.

I will attach the relevant screenshots, showing the code that makes the extension stopping working and the output of the console error.

Faulty line in web.php error_parsing_controllers_app_resolve

Log showing error in substring log_from_extension_error_substring

Relevant line from log relevant_code_from_log

Removing the faulty line makes it work again removing_app_resolve_makes_work

I think that to solve this it is just a matter of the parser to skip and keep going checking the file, without throwing the exception. It would work as intended, as the app() helper do indeed use the class qualifier, but is not a controller route.

Thanks in advance and I am happy to contribute with your amazing work, as always.

weidmaster avatar Sep 16 '21 12:09 weidmaster

@weidmaster The latest update [0.0.14 - Sep, 19 2021] should fix this.

I am closing this as fixed.

Feel free to report if the fix not working; Be sure to ping @ my name if it does not work.

stef-k avatar Sep 19 '21 06:09 stef-k

It seems the fix is causing bigger issues see #26, falling back until a better solution is found.

stef-k avatar Sep 19 '21 16:09 stef-k

It seems the fix is causing bigger issues see #26, falling back until a better solution is found.

Oh my! That is not good. The extension was working fine. Well, that is how technology is sometimes, we think the problem is kinda easy to solve, but fixing it causes more trouble later. I hope we can get it working soon. I would love to help tackle the issue, but I don't know Typescript and how to debug a live extension.

weidmaster avatar Sep 20 '21 17:09 weidmaster