MagicSetClass.php 765 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Doctrine\Tests\Common\Proxy;
  3. /**
  4. * Test asset class
  5. */
  6. class MagicSetClass
  7. {
  8. /**
  9. * @var string
  10. */
  11. public $id = 'id';
  12. /**
  13. * @var string
  14. */
  15. public $publicField = 'publicField';
  16. /**
  17. * @var string|null
  18. */
  19. public $testAttribute;
  20. /**
  21. * @param string $name
  22. * @param mixed $value
  23. *
  24. * @throws \BadMethodCallException
  25. */
  26. public function __set($name, $value)
  27. {
  28. if ($name === 'test') {
  29. $this->testAttribute = $value;
  30. }
  31. if ($name === 'publicField' || $name === 'id') {
  32. throw new \BadMethodCallException('Should never be called for "publicField" or "id"');
  33. }
  34. $this->testAttribute = $value;
  35. }
  36. }