3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Bar { private $a; public function __construct($a) { $this->a = (bool) $a; } public function a() { return $this->a; } } function foo(callable $x) { $object = new Bar(false); $x($object); return $object->a(); } var_dump(\Closure::bind(function () { $this->a = true;} , 'Bar', 'Bar'));
based on qi1IW
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0rc3
Warning: Closure::bind() expects parameter 2 to be object, string given in /in/gYklr on line 27 NULL
Output for hhvm-3.22.0
Warning: bindto() expects parameter 1 to be object, string given in /in/gYklr on line -1 NULL
Output for hhvm-3.21.3
Warning: bindto() expects parameter 1 to be object, string given in /in/gYklr on line 27 NULL
Output for hhvm-3.18.5
Fatal error: Uncaught TypeError: Argument 1 to Closure::bindto() must be of type ?object, string given in /in/gYklr:27 Stack trace: #0 (): Closure->bindto() #1 /in/gYklr(27): Closure::bind() #2 {main}
Process exited with code 255.