<?php
class A {
public $foo;
function setFoo($foo) {
$this->foo = $foo;
}
function getFoo($foo) {
return $this->foo;
}
}
class B {
function setObj(A $a, $value) {
$a->setFoo($value);
}
}
$a = new A();
$b = new B();
$a->setFoo(1);
echo $a->getFoo(), PHP_EOL;
$b->setObj($a, 5);
echo $a->getFoo(), PHP_EOL;
Fatal error: Uncaught ArgumentCountError: Too few arguments to function A::getFoo(), 0 passed in /in/WPu9M on line 22 and exactly 1 expected in /in/WPu9M:7
Stack trace:
#0 /in/WPu9M(22): A->getFoo()
#1 {main}
thrown in /in/WPu9M on line 7
Process exited with code 255.
Warning: Missing argument 1 for A::getFoo(), called in /in/WPu9M on line 22 and defined in /in/WPu9M on line 7
1
Warning: Missing argument 1 for A::getFoo(), called in /in/WPu9M on line 25 and defined in /in/WPu9M on line 7
5
Output for 5.0.2 - 5.0.5
Warning: Missing argument 1 for A::getFoo() in /in/WPu9M on line 7
1
Warning: Missing argument 1 for A::getFoo() in /in/WPu9M on line 7
5
Output for 5.0.0 - 5.0.1
Warning: Missing argument 1 for A::getFoo() in /in/WPu9M on line 7
1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/WPu9M on line 22
PHP_EOL
Warning: Missing argument 1 for A::getFoo() in /in/WPu9M on line 7
5
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/WPu9M on line 25
PHP_EOL
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/WPu9M on line 3
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/WPu9M on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/WPu9M on line 3
Process exited with code 255.