Closed panosru closed 5 years ago
Hi @panosru thanks for reaching out. This is due to the design of GoAop and how the composer autoloader is functioning.
As you maybe know, goaop creates a proxy class for your original one \Demo\MyApp
. This way if you try to instantiate this class, you won't directly instantiate your class, but the proxy one.
But this only happens after you called init()
on the ContractApplication
. This is the point where GoAop changes the autoloader to give you the proxy, not your class.
Long story short. You MUST call the ContractApplication::getInstance()->init()
before you create instances of your classes.
I hope I could help you out better understand what is happening behind the scenes :)
@icanhazstring Thanks for the explanation!
Yeap I read the source and more or less understood the process, I just thought maybe I might miss something and I could use the framework on the class itself, however, even so, it isn't much of an issue, just one class that won't have the functionality of the framework...
Thanks!
Hello again!
Nice progress on the framework!
I run in an issue today, I wanted to have an "App" class for an application I'm building and there to have a bootstrap method (run), but when I tried to apply contracts on that same app it didn't work.
MyApp.php file:
test file:
I got
5
as a result instead of an exception for contract violation:Thanks!