<?php
declare(strict=1);
class A {
private function foo(float $bar) {
echo "This is private";
}
public function getClosure($bar) {
return function () use ($bar) { $this->foo($bar); };
}
}
class B extends A {
public function test(A $a, C $c) {
$aFN = $a->getClosure(42.5);
$bFN = $this->getClosure(42.5);
$cFN = $c->getClosure(42.5);
$aFN();
$bFN();
$cFN();
}
}
class C extends B {
public function foo(int $bar) {
echo "This is public";
}
public function getClosure($bar) {
return function () use ($bar) { $this->foo($bar); };
}
}
$a = new A;
$c = new c;
$obj = new B();
$obj->test($a, $c);
Warning: Unsupported declare 'strict' in /in/jrCWD on line 3
This is privateThis is private
Deprecated: Implicit conversion from float 42.5 to int loses precision in /in/jrCWD on line 28
This is public
Warning: Unsupported declare 'strict' in /in/jrCWD on line 3
This is privateThis is privateThis is public
Output for 7.0.0 - 7.0.6
Warning: Unsupported declare 'strict' in /in/jrCWD on line 3
Warning: Declaration of C::foo(int $bar) should be compatible with A::foo(float $bar) in /in/jrCWD on line 34
This is privateThis is privateThis is public
Output for 5.6.28
Warning: Unsupported declare 'strict' in /in/jrCWD on line 3
Catchable fatal error: Argument 1 passed to A::foo() must be an instance of float, double given, called in /in/jrCWD on line 11 and defined in /in/jrCWD on line 6
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.21
Warning: Unsupported declare 'strict' in /in/jrCWD on line 3
Strict Standards: Declaration of C::foo() should be compatible with A::foo(float $bar) in /in/jrCWD on line 34
Catchable fatal error: Argument 1 passed to A::foo() must be an instance of float, double given, called in /in/jrCWD on line 11 and defined in /in/jrCWD on line 6
Process exited with code 255.