Arquivos
hhvm/hphp/test/slow/object_invoke_method/773.php
T
Paul Tarjan c2ec1c97c9 sortof format slow tests
A poor man's formatter since I didn't like any of the other ones I found. The original C++ source sometimes put newlines and sometimes not.

Codemods:

    codemod '([;{}])([^\n])' '\1\n\2'
    codemod -m '\s*<\?php\s+' '<?php\n\n'
    codemod '\t' '  '

I hand-fixed all the failing tests
2013-05-30 17:32:57 -07:00

39 linhas
629 B
PHP

<?php
abstract class A {
abstract public function __invoke($x);
}
interface IfaceInvoke {
public function __invoke($x);
}
class Test1 extends A {
public function __invoke($x) {
var_dump(__CLASS__);
var_dump($x);
}
}
class Test2 implements IfaceInvoke {
public function __invoke($x) {
var_dump(__CLASS__);
var_dump($x);
}
}
function f1($x, $y) {
$x($y);
$x->__invoke($y);
}
function f2(A $x, $y) {
$x($y);
$x->__invoke($y);
}
function f3(IfaceInvoke $x, $y) {
$x($y);
$x->__invoke($y);
}
$t1 = new Test1;
$t2 = new Test2;
f1($t1, 1);
f1($t2, 2);
f2($t1, 1);
f3($t2, 2);