Skip to content

Instantly share code, notes, and snippets.

@acapps
Created February 3, 2017 06:44
Show Gist options
  • Save acapps/af3de9f24342d6be3938b91e8d155c91 to your computer and use it in GitHub Desktop.
Save acapps/af3de9f24342d6be3938b91e8d155c91 to your computer and use it in GitHub Desktop.
<?php
class Supervisor {
private $prop1;
private $prop2;
protected $key;
protected function set($key, $val) {
$this->$key = $val;
}
protected function get($key) {
return $this->$key;
}
}
class Child extends Supervisor {
private $childProp1;
private $childProp2;
public function doStuff() {
// work goes here
}
public function set($key, $val) {
parent::set($key, $val);
}
public function get($key) {
return parent::get($key);
}
}
$slave = new Child();
$slave->set('asdf', 'Timmy');
echo $slave->get('asdf') . PHP_EOL; // Timmy gets written out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment