<?php
$foo = function($this)
{
var_dump($this); // this will work!
};
$foo('bar');
// now an object:
class Test
{
public $foo = 'bar';
}
$test = new Test;
// and another closure:
$ouch = function($this)
{
var_dump($this->bar); // this will blow up
};
$ouch($test);
Fatal error: Cannot use $this as parameter in /in/upv7i on line 3
Process exited with code 255.
Output for 7.0.0 - 7.0.6
string(3) "bar"
Fatal error: Uncaught Error: Using $this when not in object context in /in/upv7i:23
Stack trace:
#0 /in/upv7i(26): {closure}(Object(Test))
#1 {main}
thrown in /in/upv7i on line 23
Process exited with code 255.