Skip to content
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

Not meaningful exception for syntax error #35602

Closed
Heyfara opened this issue Feb 5, 2020 · 2 comments
Closed

Not meaningful exception for syntax error #35602

Heyfara opened this issue Feb 5, 2020 · 2 comments
Labels

Comments

@Heyfara
Copy link

Heyfara commented Feb 5, 2020

Symfony version(s) affected: 4.4

Description
Until Symfony 4.4, when making a syntax error in a file, you would get a ParseError. But since 4.4, you get a LoaderLoadException saying :
Expected to find class "App/Controller/Controller" in file "/src/Controller/Controller.php" while importing services from resource "../src/*", but it was not found! Check the namespace prefix used with the resource in /config/services.yaml (which is loaded in resource "/config/services.yaml").

The message isn't very helpful. We can only know there is something wrong somewhere in the given class. As a developper, I would expect a meaningful exception message, just like in previous versions. I couldn't test this on version 5 though.

How to reproduce

  • Create a new project using latest 4.4 version
  • Create a simple controller class. Example here.
  • Make a syntax error : remove a semicolon, or omit a dollar sign in front of a variable name.
  • Referesh the page.
  • You should see the exception.

Additional context
Seems to affect autowired classes. If you make a syntax error in the Kernel.php file, the exception is a ParseError as expected.

@nicolas-grekas
Copy link
Member

Closing as duplicate of #35445 and #35256, fixed in #35557.
Thanks for reporting.

@Heyfara
Copy link
Author

Heyfara commented Feb 5, 2020

Oh, I couldn't find those duplicates!
I see it's been merged in 3.4 branch. So it will be available in the next 4.4 release?

@xabbuh xabbuh added the Config label Feb 10, 2020
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