Last active
June 25, 2019 01:29
-
-
Save hdvianna/2e6d3e6e5e28960fd9b7abe212011d07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ParentClass { | |
private $descendant; | |
public function setDescendant($descendant) { | |
$this->descendant = $descendant; | |
return $this; | |
} | |
public function showDescendantValue() { | |
echo $this->descendant->value.PHP_EOL; | |
} | |
} | |
class DescendantClass extends ParentClass { | |
protected $value = "DescendantClass value"; | |
} | |
$parentClass = new ParentClass(); | |
$parentClass | |
->setDescendant(new DescendantClass()) | |
->showDescendantValue(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment