-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(s) affected: 5.0.0
Description
Error for invalid class namespace differs when you refresh the page after seeing it.
How to reproduce
Starting from an empty Symfony app (symfony new sfapp20191127 --full
), create two classes:
//src/Foo.php
namespace App;
class Foo
{
}
//src/Bar/Foo.php
namespace App/Bar;
class Foo
{
}
Run symfony serve
and open the homepage (https://127.0.0.1:8000/). Everything should be running OK.
Now change the namespace in src/Bar/Foo.php
to just namespace App;
and refresh the browser. You will get an error:
Error: Cannot declare class App\Foo, because the name is already in use
The surprising thing happens, when you refresh the browser again, you will get a more detailed error message:
Expected to find class "App\Bar\Foo" in file "C:\dev\htdocs\sfapp20191127\src/Bar\Foo.php" while importing services from resource "../src/*", but it was not found! Check the namespace prefix used with the resource in C:\dev\htdocs\sfapp20191127\config/services.yaml (which is loaded in resource "C:\dev\htdocs\sfapp20191127\config/services.yaml").
Without doubt, the second error message is much better and more developer-friendly, so it would be better to see it straight away. (and I suppose that nobody will try to refresh the browser to get a better error message).