- var_dump: documentation ( source)
<?php
class A {
protected $foo = 'initial';
public function get():string {return $this->foo; }
public function set(string $bar): A {$this->foo = $bar; return $this;}
}
class B extends A {
public function set(string $bar): B {$this->foo = $bar.'!'; return $this;}
}
$a = new A;
$b = new B;
$a->set('A');
$b->set('B');
var_dump([$a->get(), $b->get()]);