Open gtux opened 1 month ago
While I do see your point, I'm unsure if this should be something that we should fix or needs a fix. The Cookies
class is indeed meant to be used more as a service provider from what I understand. Meaning that the container needs to exist before you can make use of it.
As such the way you're making use of it is actually the correct approach. That or extending Cookies
and set the container in the constructor or initialize()
function.
Though I would have liked a more descriptive error message as well instead of
Uncaught RuntimeException: Trying to call method get on a non-object in test.php
Hi @raicabogdan
Yeah! You are right, this is not really a bug really indeed, because the reasons you already mentioned. What I mean, is could be a better approach capturing the errors and be more verbose about that. It could be stay like that? Yeah, it does not matters, as you mentioned: this is a service and must be used as it.
Description I need to work with a Cookies class in order to use their OOP approach. But, my code caused an error, after debugging I'd notice the method get could be more robust
To Reproduce Instance a Cookies service and then use the get method.
Steps to reproduce the behavior:
If you look at the Cookies class:
In order to avoid the error the instance must be setup with container before the call.
Expected behavior Maybe the code has the right behavior, but the container must be evaluated before the called to create a new Cookie or get the cookie and trigger a more informative error/exception.
Details
5.6 but the current version has the same code
)