DummyOverloadableClass.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. class DummyOverloadableClass
  3. {
  4. protected $checkMe = 1;
  5. protected $properties = array('checkMeToo' => 1);
  6. function __construct($checkMe = 1)
  7. {
  8. $this->checkMe = "constructed: ".$checkMe;
  9. }
  10. public function helloWorld() {
  11. return "hello";
  12. }
  13. public function goodByeWorld() {
  14. return "good bye";
  15. }
  16. protected function notYourBusinessWorld()
  17. {
  18. return "goAway";
  19. }
  20. public function getCheckMe() {
  21. return $this->checkMe;
  22. }
  23. public function getCheckMeToo() {
  24. return $this->checkMeToo;
  25. }
  26. public function call() {
  27. $this->targetMethod();
  28. return true;
  29. }
  30. public function targetMethod() {
  31. return true;
  32. }
  33. public function exceptionalMethod() {
  34. throw new Exception('Catch it!');
  35. }
  36. public function __get($name) {
  37. //seeing as we're not implementing __set here, add check for __mocked
  38. $return = null;
  39. if ($name === '__mocked') {
  40. $return = isset($this->__mocked) ? $this->__mocked : null;
  41. } else {
  42. if ($this->__isset($name)) {
  43. $return = $this->properties[$name];
  44. }
  45. }
  46. return $return;
  47. }
  48. public function __isset($name) {
  49. return $this->isMagical($name) && isset($this->properties[$name]);
  50. }
  51. private function isMagical($name) {
  52. $reflectionClass = new \ReflectionClass($this);
  53. return !$reflectionClass->hasProperty($name);
  54. }
  55. }