<?php
class Test
{
private $x;
private $y;
public function __construct()
{
$this->x = 10;
$this->y = function (){ return $this->getToutesLesCommandes();};
}
public function getY($k)
{
return $this->$k;
}
public function getToutesLesCommandes()
{
//sleep(5);
echo "Et 5 tres longues secondes plus tard...";
return array('commande1' => 123456, 'commande2' => 456789);
}
}
$t = new Test();
//var_dump($t);
var_dump($t->getY());
var_dump($t->getY());
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Test::getY(), 0 passed in /in/iZQF5 on line 30 and exactly 1 expected in /in/iZQF5:14
Stack trace:
#0 /in/iZQF5(30): Test->getY()
#1 {main}
thrown in /in/iZQF5 on line 14
Process exited with code 255.
Output for 7.0.0 - 7.0.33
Warning: Missing argument 1 for Test::getY(), called in /in/iZQF5 on line 30 and defined in /in/iZQF5 on line 14
Notice: Undefined variable: k in /in/iZQF5 on line 16
Fatal error: Uncaught Error: Cannot access empty property in /in/iZQF5:16
Stack trace:
#0 /in/iZQF5(30): Test->getY()
#1 {main}
thrown in /in/iZQF5 on line 16
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Warning: Missing argument 1 for Test::getY(), called in /in/iZQF5 on line 30 and defined in /in/iZQF5 on line 14
Notice: Undefined variable: k in /in/iZQF5 on line 16
Fatal error: Cannot access empty property in /in/iZQF5 on line 16
Process exited with code 255.