<?php
class A {
private $a;
public function getA() {
return $this->a;
}
public function setA($a) {
$this->a = $a;
}
}
$a = new A();
$a->setA("coucou");
echo $a->getA();
modifyA($ab);
echo $a->getA();
function modifyA(A $a) {
$a->setA('B');
}
coucou
Warning: Undefined variable $ab in /in/Q0ZdO on line 21
Fatal error: Uncaught TypeError: modifyA(): Argument #1 ($a) must be of type A, null given, called in /in/Q0ZdO on line 21 and defined in /in/Q0ZdO:28
Stack trace:
#0 /in/Q0ZdO(21): modifyA(NULL)
#1 {main}
thrown in /in/Q0ZdO on line 28
Process exited with code 255.
coucou
Notice: Undefined variable: ab in /in/Q0ZdO on line 21
Fatal error: Uncaught TypeError: Argument 1 passed to modifyA() must be an instance of A, null given, called in /in/Q0ZdO on line 21 and defined in /in/Q0ZdO:28
Stack trace:
#0 /in/Q0ZdO(21): modifyA(NULL)
#1 {main}
thrown in /in/Q0ZdO on line 28
Process exited with code 255.
Output for 7.3.32 - 7.3.33
coucou
Fatal error: Uncaught TypeError: Argument 1 passed to modifyA() must be an instance of A, null given, called in /in/Q0ZdO on line 21 and defined in /in/Q0ZdO:28
Stack trace:
#0 /in/Q0ZdO(21): modifyA(NULL)
#1 {main}
thrown in /in/Q0ZdO on line 28
Process exited with code 255.
coucou
Notice: Undefined variable: ab in /in/Q0ZdO on line 21
Catchable fatal error: Argument 1 passed to modifyA() must be an instance of A, null given, called in /in/Q0ZdO on line 21 and defined in /in/Q0ZdO on line 28
Process exited with code 255.