-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing][Translation] Assert return value for PHP configuration #23522
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
Conversation
Q | A |
---|---|
Branch? | 2.7 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #23518 |
License | MIT |
Doc PR | symfony/symfony-docs#... |
@@ -37,6 +37,10 @@ public function load($resource, $locale, $domain = 'messages') | |||
|
|||
$messages = require $resource; | |||
|
|||
if (!is_array($messages)) { | |||
throw new \UnexpectedValueException(sprintf('PHP routing configuration must return an array, got "%s" in "%s".', is_object($messages) ? get_class($messages) : gettype($messages), $resource)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo. It's not about routing
here 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was faster.. was i?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do any of the other PHP config file loaders have the same behaviour and could profit from such a change too? |
Think we're good. Serializer/Validator dont have php file loaders. DI doesnt rely on any return value (strictly it could assert null though, but i dont think we should :)) |
I'm 👎 on this one. We don't do such check anywhere else in the code and we rejected similar PRs (not on this specific use case) in the past. The linked ticket is about something very different anyway. The |
It doesnt hurt.. but i see your point. It's a safeguard for sure. I do like the better error though, given it contains a clear file ref. But that can be found in trace as well. Closing for now as the issue is fixed. |
@ro0NL you closed this PR too fast. I'd love to discuss about this a bit more :( Adding features for DX is tricky. Let me show you two quick examples:
Which format should we show in the Symfony Docs? Both? Very verbose! Only one of them? But which one !? Moreover, people will start using any of those solutions interchangeably, so applications will use both formats and will be a bit more confusing. Besides, this adds another problem: can I mix both formats in the same file? If yes, it may be confusing. If no, why not? etc.
|
Fair points! For this PR, i closed it for the same reason as #19960. We dont really have to care, that's reasonable :) For #22176, i hope we can settle with it as is. Errors are annoying, lets try not to add them :P for the end user it doesnt matter at least. Besides it works the same as DI service tags in yaml. I personally favor short notation, and use long if needed. So i would do that in docs; not saying we should update all current docs - we could though - but we do need to mention it somewhere in 3.4 i guess. |