Bonsoir,
alors j'ai une question assez simple illustré par cet exemple
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| class Test
{
private $foo;
public function __construct($foo)
{
$this->fo = $foo;
}
private function bars()
{
echo 'Accès à la méthode privée.';
}
public function baz(Test $other)
{
// Nous pouvons modifier la propriété privée :
$other->fo = 'Bonjour';
var_dump($other->fo );
// Nous pouvons également appeler la méthode privée :
$other->bars();
}
}
$test = new Test('test');
$test->baz(new Test('other')); |
la question étant de connaitre la plu valu cette ligne
public function baz(Test $other)
grosso modo je comprends pas l'utilité de "déclarer" Test
merci à vous
Partager