| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- /**
- * Test: Nette\SmartObject reference to property.
- */
- declare(strict_types=1);
- use Tester\Assert;
- require __DIR__ . '/../bootstrap.php';
- /**
- * @property string $foo
- */
- class TestClass
- {
- use Nette\SmartObject;
- private $foo;
- public function getFoo()
- {
- return $this->foo;
- }
- public function setFoo($foo)
- {
- $this->foo = $foo;
- }
- }
- $obj = new TestClass;
- $obj->foo = 'hello';
- @$x = &$obj->foo;
- $x = 'changed by reference';
- Assert::same('hello', $obj->foo);
|