Read that the following code is an example of \"unsafe construction\" as it allows this reference to escape. I couldn\'t quite get how \'this\' escapes. I am pretty new to t
I had the exact same doubt.
The thing is that every class that gets instantiated inside other class has a reference to the enclosing class in the variable $this
.
This is what java calls a synthetic, it's not something you define to be there but something java does for you automatically.
If you want to see this for yourself put a breakpoint in the doSomething(e)
line and check what properties EventListener
has.