TestClassMagicGet.php 878 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
  11. class TestClassMagicGet
  12. {
  13. private $magicProperty;
  14. public $publicProperty;
  15. public function __construct($value)
  16. {
  17. $this->magicProperty = $value;
  18. }
  19. public function __set($property, $value)
  20. {
  21. if ('magicProperty' === $property) {
  22. $this->magicProperty = $value;
  23. }
  24. }
  25. public function __get($property)
  26. {
  27. if ('magicProperty' === $property) {
  28. return $this->magicProperty;
  29. }
  30. if ('constantMagicProperty' === $property) {
  31. return 'constant value';
  32. }
  33. }
  34. }