From 55b5b92b457b9ffe72d255173055e941ea9cfcd6 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 5 Apr 2016 19:58:51 +0200 Subject: [PATCH] SmartObject: removed deprecated features --- src/Utils/ObjectMixin.php | 14 +-- src/Utils/SmartObject.php | 115 +----------------- .../Utils/SmartObject.arrayProperty.old.phpt | 33 ----- tests/Utils/SmartObject.closureProperty.phpt | 68 ----------- tests/Utils/SmartObject.extensionMethod.phpt | 51 -------- ...artObject.extensionMethodViaInterface.phpt | 59 --------- .../Utils/SmartObject.magicMethod.errors.phpt | 69 ----------- .../SmartObject.magicMethod.inheritance.phpt | 47 ------- tests/Utils/SmartObject.magicMethod.phpt | 62 ---------- .../Utils/SmartObject.magicMethod.types.phpt | 65 ---------- tests/Utils/SmartObject.methodGetter.phpt | 68 ----------- tests/Utils/SmartObject.property.old.phpt | 114 ----------------- tests/Utils/SmartObject.property.phpt | 4 - .../SmartObject.referenceProperty.old.phpt | 35 ------ tests/Utils/SmartObject.reflection.phpt | 27 ---- 15 files changed, 7 insertions(+), 824 deletions(-) delete mode 100644 tests/Utils/SmartObject.arrayProperty.old.phpt delete mode 100644 tests/Utils/SmartObject.closureProperty.phpt delete mode 100644 tests/Utils/SmartObject.extensionMethod.phpt delete mode 100644 tests/Utils/SmartObject.extensionMethodViaInterface.phpt delete mode 100644 tests/Utils/SmartObject.magicMethod.errors.phpt delete mode 100644 tests/Utils/SmartObject.magicMethod.inheritance.phpt delete mode 100644 tests/Utils/SmartObject.magicMethod.phpt delete mode 100644 tests/Utils/SmartObject.magicMethod.types.phpt delete mode 100644 tests/Utils/SmartObject.methodGetter.phpt delete mode 100644 tests/Utils/SmartObject.property.old.phpt delete mode 100644 tests/Utils/SmartObject.referenceProperty.old.phpt delete mode 100644 tests/Utils/SmartObject.reflection.phpt diff --git a/src/Utils/ObjectMixin.php b/src/Utils/ObjectMixin.php index 317d17fc9..99ea9958a 100644 --- a/src/Utils/ObjectMixin.php +++ b/src/Utils/ObjectMixin.php @@ -312,14 +312,6 @@ public static function getMagicProperties(string $class): array } - /** @internal */ - public static function getMagicProperty(string $class, string $name) - { - $props = self::getMagicProperties($class); - return isset($props[$name]) ? $props[$name] : NULL; - } - - /********************* magic @methods ****************d*g**/ @@ -554,9 +546,8 @@ public static function hasProperty(string $class, string $name) /** * Returns array of public (static, non-static and magic) methods. * @return array - * @internal */ - public static function &getMethods(string $class): array + private static function &getMethods(string $class): array { static $cache; if (!isset($cache[$class])) { @@ -569,8 +560,7 @@ public static function &getMethods(string $class): array } - /** @internal */ - public static function getSource() + private static function getSource() { foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $item) { if (isset($item['file']) && dirname($item['file']) !== __DIR__) { diff --git a/src/Utils/SmartObject.php b/src/Utils/SmartObject.php index cd3e49d31..3390b8a80 100644 --- a/src/Utils/SmartObject.php +++ b/src/Utils/SmartObject.php @@ -19,7 +19,6 @@ * - access to undeclared members throws exceptions * - support for @property annotations * - support for calling event handlers stored in $onEvent via onEvent() - * - compatible with Nette\Object */ trait SmartObject { @@ -31,12 +30,8 @@ trait SmartObject public function __call($name, $args) { $class = get_class($this); - $isProp = ObjectMixin::hasProperty($class, $name); - if ($name === '') { - throw new MemberAccessException("Call to class '$class' method without name."); - - } elseif ($isProp === 'event') { // calling event handlers + if (ObjectMixin::hasProperty($class, $name) === 'event') { // calling event handlers if (is_array($this->$name) || $this->$name instanceof \Traversable) { foreach ($this->$name as $handler) { Callback::invokeArgs($handler, $args); @@ -45,35 +40,6 @@ public function __call($name, $args) throw new UnexpectedValueException("Property $class::$$name must be array or NULL, " . gettype($this->$name) . ' given.'); } - } elseif ($isProp && $this->$name instanceof \Closure) { // closure in property - trigger_error("Invoking closure in property via \$obj->$name() is deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED); - return call_user_func_array($this->$name, $args); - - } elseif (($methods = &ObjectMixin::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) { // magic @methods - trigger_error("Magic methods such as $class::$name() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED); - list($op, $rp, $type) = $methods[$name]; - if (count($args) !== ($op === 'get' ? 0 : 1)) { - throw new InvalidArgumentException("$class::$name() expects " . ($op === 'get' ? 'no' : '1') . ' argument, ' . count($args) . ' given.'); - - } elseif ($type && $args && !ObjectMixin::checkType($args[0], $type)) { - throw new InvalidArgumentException("Argument passed to $class::$name() must be $type, " . gettype($args[0]) . ' given.'); - } - - if ($op === 'get') { - return $rp->getValue($this); - } elseif ($op === 'set') { - $rp->setValue($this, $args[0]); - } elseif ($op === 'add') { - $val = $rp->getValue($this); - $val[] = $args[0]; - $rp->setValue($this, $val); - } - return $this; - - } elseif ($cb = ObjectMixin::getExtensionMethod($class, $name)) { // extension methods - trigger_error("Extension methods such as $class::$name() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED); - return Callback::invoke($cb, $this, ...$args); - } else { ObjectMixin::strictCall($class, $name); } @@ -97,43 +63,18 @@ public static function __callStatic($name, $args) public function &__get($name) { $class = get_class($this); - $uname = ucfirst($name); - if ($prop = ObjectMixin::getMagicProperty($class, $name)) { // property getter + if ($prop = ObjectMixin::getMagicProperties($class)[$name] ?? NULL) { // property getter if (!($prop & 0b0001)) { throw new MemberAccessException("Cannot read a write-only property $class::\$$name."); } - $m = ($prop & 0b0010 ? 'get' : 'is') . $uname; + $m = ($prop & 0b0010 ? 'get' : 'is') . $name; if ($prop & 0b0100) { // return by reference return $this->$m(); } else { $val = $this->$m(); return $val; } - - } elseif ($name === '') { - throw new MemberAccessException("Cannot read a class '$class' property without name."); - - } elseif (($methods = &ObjectMixin::getMethods($class)) && isset($methods[$m = 'get' . $uname]) || isset($methods[$m = 'is' . $uname])) { // old property getter - trigger_error("Add annotation @property for $class::\$$name or use $m()" . ObjectMixin::getSource(), E_USER_DEPRECATED); - if ($methods[$m] === 0) { - $methods[$m] = (new \ReflectionMethod($class, $m))->returnsReference(); - } - if ($methods[$m] === TRUE) { - return $this->$m(); - } else { - $val = $this->$m(); - return $val; - } - - } elseif (isset($methods[$name])) { // public method as closure getter - trigger_error("Accessing methods as properties via \$obj->$name is deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED); - $val = Callback::closure($this, $name); - return $val; - - } elseif (isset($methods['set' . $uname])) { // property getter - throw new MemberAccessException("Cannot read a write-only property $class::\$$name."); - } else { ObjectMixin::strictGet($class, $name); } @@ -147,27 +88,16 @@ public function &__get($name) public function __set($name, $value) { $class = get_class($this); - $uname = ucfirst($name); if (ObjectMixin::hasProperty($class, $name)) { // unsetted property $this->$name = $value; - } elseif ($prop = ObjectMixin::getMagicProperty($class, $name)) { // property setter + } elseif ($prop = ObjectMixin::getMagicProperties($class)[$name] ?? NULL) { // property setter if (!($prop & 0b1000)) { throw new MemberAccessException("Cannot write to a read-only property $class::\$$name."); } $this->{'set' . $name}($value); - } elseif ($name === '') { - throw new MemberAccessException("Cannot write to a class '$class' property without name."); - - } elseif (($methods = &ObjectMixin::getMethods($class)) && isset($methods[$m = 'set' . $uname])) { // old property setter - trigger_error("Add annotation @property for $class::\$$name or use $m()" . ObjectMixin::getSource(), E_USER_DEPRECATED); - $this->$m($value); - - } elseif (isset($methods['get' . $uname]) || isset($methods['is' . $uname])) { // property setter - throw new MemberAccessException("Cannot write to a read-only property $class::\$$name."); - } else { ObjectMixin::strictSet($class, $name); } @@ -192,42 +122,7 @@ public function __unset($name) */ public function __isset($name) { - $uname = ucfirst($name); - return ObjectMixin::getMagicProperty(get_class($this), $name) - || ($name !== '' && ($methods = ObjectMixin::getMethods(get_class($this))) && (isset($methods['get' . $uname]) || isset($methods['is' . $uname]))); - } - - - /** - * @return Reflection\ClassType|\ReflectionClass - * @deprecated - */ - public static function getReflection(): \ReflectionClass - { - trigger_error(get_called_class() . '::getReflection() is deprecated' . ObjectMixin::getSource(), E_USER_DEPRECATED); - $class = class_exists(Reflection\ClassType::class) ? Reflection\ClassType::class : \ReflectionClass::class; - return new $class(get_called_class()); - } - - - /** - * @return mixed - * @deprecated use Nette\Utils\ObjectMixin::setExtensionMethod() - */ - public static function extensionMethod(string $name, $callback = NULL) - { - if (strpos($name, '::') === FALSE) { - $class = get_called_class(); - } else { - list($class, $name) = explode('::', $name); - $class = (new \ReflectionClass($class))->getName(); - } - trigger_error("Extension methods such as $class::$name() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED); - if ($callback === NULL) { - return ObjectMixin::getExtensionMethod($class, $name); - } else { - ObjectMixin::setExtensionMethod($class, $name, $callback); - } + return isset(ObjectMixin::getMagicProperties(get_class($this))[$name]); } } diff --git a/tests/Utils/SmartObject.arrayProperty.old.phpt b/tests/Utils/SmartObject.arrayProperty.old.phpt deleted file mode 100644 index 5db76a841..000000000 --- a/tests/Utils/SmartObject.arrayProperty.old.phpt +++ /dev/null @@ -1,33 +0,0 @@ -items; - } - - public function setItems(array $value) - { - $this->items = $value; - } - -} - - -$obj = new TestClass; -@$obj->items[] = 'test'; -Assert::same(['test'], @$obj->items); diff --git a/tests/Utils/SmartObject.closureProperty.phpt b/tests/Utils/SmartObject.closureProperty.phpt deleted file mode 100644 index 2870c1442..000000000 --- a/tests/Utils/SmartObject.closureProperty.phpt +++ /dev/null @@ -1,68 +0,0 @@ -public = $this->onPublic = $this->protected = $this->private = $func; - } - -} - - -Assert::error(function () { - $obj = new TestClass(function () {}); - $obj->public(1, 2); -}, E_USER_DEPRECATED, 'Invoking closure in property via $obj->public() is deprecated in ' . __FILE__ . ':' . (__LINE__ - 1)); - - -(function () { - $obj = new TestClass(function ($a, $b) { - return "$a $b"; - }); - - Assert::same('1 2', @$obj->public(1, 2)); -})(); - - -(function () { - Assert::exception(function () { - $obj = new TestClass(123); - $obj->onPublic = function () {}; // accidentally forgotten [] - $obj->onPublic(1, 2); - }, Nette\UnexpectedValueException::class, 'Property TestClass::$onPublic must be array or NULL, object given.'); - - - Assert::exception(function () { - $obj = new TestClass(123); - $obj->public(); - }, Nette\MemberAccessException::class, 'Call to undefined method TestClass::public().'); - - - Assert::exception(function () { - $obj = new TestClass(function () {}); - $obj->protected(); - }, Nette\MemberAccessException::class, 'Call to undefined method TestClass::protected().'); - - - Assert::exception(function () { - $obj = new TestClass(function () {}); - $obj->private(); - }, Nette\MemberAccessException::class, 'Call to undefined method TestClass::private().'); -})(); diff --git a/tests/Utils/SmartObject.extensionMethod.phpt b/tests/Utils/SmartObject.extensionMethod.phpt deleted file mode 100644 index b2ab12f81..000000000 --- a/tests/Utils/SmartObject.extensionMethod.phpt +++ /dev/null @@ -1,51 +0,0 @@ -foo . $separator . $that->bar; -}; - -Assert::error(function () use ($func) { - TestClass::extensionMethod('join', $func); -}, E_USER_DEPRECATED, 'Extension methods such as TestClass::join() are deprecated in ' . __FILE__ . ':' . (__LINE__ - 1)); - -Assert::error(function () { - $obj = new TestClass; - $obj->join('*'); -}, E_USER_DEPRECATED, 'Extension methods such as TestClass::join() are deprecated in ' . __FILE__ . ':' . (__LINE__ - 1)); - - -$obj = new TestClass; -Assert::same('Hello*World', @$obj->join('*')); - - -Assert::same( - ['join' => $func], - Nette\Utils\ObjectMixin::getExtensionMethods(TestClass::class) -); - -Assert::same( - [], - Nette\Utils\ObjectMixin::getExtensionMethods(Nette\SmartObject::class) -); - -Assert::exception(function () { - $obj = new TestClass; - $obj->joi(); -}, Nette\MemberAccessException::class, 'Call to undefined method TestClass::joi().'); diff --git a/tests/Utils/SmartObject.extensionMethodViaInterface.phpt b/tests/Utils/SmartObject.extensionMethodViaInterface.phpt deleted file mode 100644 index 9f7863768..000000000 --- a/tests/Utils/SmartObject.extensionMethodViaInterface.phpt +++ /dev/null @@ -1,59 +0,0 @@ -foo . $separator . $that->bar; -} - - -function ISecond_join(ISecond $that, $separator) -{ - return __METHOD__ . ' says ' . $that->foo . $separator . $that->bar; -} - - -@SmartObject::extensionMethod('ISecond::join', 'ISecond_join'); -@SmartObject::extensionMethod('IFirst::join', 'IFirst_join'); - -$obj = new TestClass; -Assert::same('ISecond_join says Hello*World', @$obj->join('*')); - -Assert::same( - ['join' => 'ISecond_join'], - Nette\Utils\ObjectMixin::getExtensionMethods(TestClass::class) -); - -Assert::same( - ['join' => 'IFirst_join'], - Nette\Utils\ObjectMixin::getExtensionMethods(IFirst::class) -); - -Assert::exception(function () { - $obj = new TestClass; - $obj->joi(); -}, Nette\MemberAccessException::class, 'Call to undefined method TestClass::joi().'); diff --git a/tests/Utils/SmartObject.magicMethod.errors.phpt b/tests/Utils/SmartObject.magicMethod.errors.phpt deleted file mode 100644 index b12a9f229..000000000 --- a/tests/Utils/SmartObject.magicMethod.errors.phpt +++ /dev/null @@ -1,69 +0,0 @@ -setAbc(); -}, Nette\MemberAccessException::class, 'Call to undefined method TestClass::setAbc(), did you mean getAbc()?'); - -Assert::exception(function () { - $obj = new TestClass; - $obj->abc(); -}, Nette\MemberAccessException::class, 'Call to undefined method parent::abc().'); - -Assert::exception(function () { - $obj = new TestClass; - $obj->adItem(); -}, Nette\MemberAccessException::class, 'Call to undefined method TestClass::adItem(), did you mean addItem()?'); - - -// Wrong parameters count -Assert::exception(function () { - $obj = new TestClass; - @$obj->setItems(); -}, Nette\InvalidArgumentException::class, 'TestClass::setItems() expects 1 argument, 0 given.'); - -Assert::exception(function () { - $obj = new TestClass; - @$obj->setItems(1, 2); -}, Nette\InvalidArgumentException::class, 'TestClass::setItems() expects 1 argument, 2 given.'); - -Assert::exception(function () { - $obj = new TestClass; - @$obj->getItems(1); -}, Nette\InvalidArgumentException::class, 'TestClass::getItems() expects no argument, 1 given.'); - -Assert::exception(function () { - $obj = new TestClass; - @$obj->addItem(); -}, Nette\InvalidArgumentException::class, 'TestClass::addItem() expects 1 argument, 0 given.'); diff --git a/tests/Utils/SmartObject.magicMethod.inheritance.phpt b/tests/Utils/SmartObject.magicMethod.inheritance.phpt deleted file mode 100644 index 404ffadbb..000000000 --- a/tests/Utils/SmartObject.magicMethod.inheritance.phpt +++ /dev/null @@ -1,47 +0,0 @@ -setA('hello'); -Assert::same('hello', @$obj->getA()); - -Assert::exception(function () use ($obj) { - $obj->setC(123); -}, Nette\MemberAccessException::class, 'Call to undefined method ChildClass::setC(), did you mean setB()?'); - - -Assert::exception(function () use ($obj) { - $obj->setB(123); -}, Nette\MemberAccessException::class, 'Call to undefined method ChildClass::setB(), did you mean getB()?'); diff --git a/tests/Utils/SmartObject.magicMethod.phpt b/tests/Utils/SmartObject.magicMethod.phpt deleted file mode 100644 index 80209434b..000000000 --- a/tests/Utils/SmartObject.magicMethod.phpt +++ /dev/null @@ -1,62 +0,0 @@ -setName('hello'); -}, E_USER_DEPRECATED, 'Magic methods such as TestClass::setName() are deprecated in ' . __FILE__ . ':' . (__LINE__ - 1)); - - -$obj = new TestClass; - -// public -Assert::same($obj, @$obj->setName('hello')); -Assert::same('hello', @$obj->name); -Assert::same('hello', @$obj->getName()); - -// protected -Assert::same($obj, @$obj->setEnabled(11)); -Assert::same(11, @$obj->isEnabled()); - -// magic accessors for magic methods -@$obj->enabled = 22; -Assert::same(22, @$obj->enabled); - -// adder -Assert::same($obj, @$obj->addItem('world')); -Assert::same(['world'], @$obj->items); -Assert::same(['world'], @$obj->getItems()); - -Assert::same($obj, @$obj->setItems([])); -Assert::same([], @$obj->items); -Assert::same([], @$obj->getItems()); diff --git a/tests/Utils/SmartObject.magicMethod.types.phpt b/tests/Utils/SmartObject.magicMethod.types.phpt deleted file mode 100644 index 643fbdf17..000000000 --- a/tests/Utils/SmartObject.magicMethod.types.phpt +++ /dev/null @@ -1,65 +0,0 @@ -setName(123); -Assert::same('123', @$obj->name); - - -@$obj->setEnabled(1); -Assert::same(TRUE, @$obj->enabled); - -Assert::exception(function () use ($obj) { - @$obj->setEnabled(new stdClass); -}, Nette\InvalidArgumentException::class, 'Argument passed to Test\TestClass::setEnabled() must be bool, object given.'); - - -@$obj->setItems([new TestClass]); -Assert::equal([new TestClass], @$obj->items); - -Assert::exception(function () use ($obj) { - @$obj->setItems([1]); -}, Nette\InvalidArgumentException::class, 'Argument passed to Test\TestClass::setItems() must be Test\TestClass[], array given.'); - - -@$obj->addItem(new TestClass); -Assert::equal([new TestClass, new TestClass], @$obj->items); - -Assert::exception(function () use ($obj) { - @$obj->addItem(1); -}, Nette\InvalidArgumentException::class, 'Argument passed to Test\TestClass::addItem() must be Test\TestClass, integer given.'); diff --git a/tests/Utils/SmartObject.methodGetter.phpt b/tests/Utils/SmartObject.methodGetter.phpt deleted file mode 100644 index e49781efa..000000000 --- a/tests/Utils/SmartObject.methodGetter.phpt +++ /dev/null @@ -1,68 +0,0 @@ -id = $id; - } - - public function publicMethod($a, $b) - { - return "$this->id $a $b"; - } - - protected function protectedMethod() - { - } - - private function privateMethod() - { - } - - public function getWithoutParameters() - {} - -} - - -// deprecated -Assert::error(function () { - $obj = new TestClass; - $obj->publicMethod; -}, E_USER_DEPRECATED, 'Accessing methods as properties via $obj->publicMethod is deprecated in ' . __FILE__ . ':' . (__LINE__ - 1)); - - -$obj1 = new TestClass(1); -$method = @$obj1->publicMethod; -Assert::same("1 2 3", $method(2, 3)); - -$rm = new ReflectionFunction($method); -Assert::same($obj1, $rm->getClosureThis()); -Assert::same('publicMethod', $rm->getName()); -Assert::same(2, $rm->getNumberOfParameters()); - - -Assert::exception(function () { - $obj = new TestClass; - $method = $obj->protectedMethod; -}, Nette\MemberAccessException::class, 'Cannot read an undeclared property TestClass::$protectedMethod.'); - - -Assert::exception(function () { - $obj = new TestClass; - $method = $obj->privateMethod; -}, Nette\MemberAccessException::class, 'Cannot read an undeclared property TestClass::$privateMethod.'); diff --git a/tests/Utils/SmartObject.property.old.phpt b/tests/Utils/SmartObject.property.old.phpt deleted file mode 100644 index 1c1191de4..000000000 --- a/tests/Utils/SmartObject.property.old.phpt +++ /dev/null @@ -1,114 +0,0 @@ -foo = $foo; - $this->bar = $bar; - } - - public function foo() - { // method getter has lower priority than getter - } - - public function getFoo() - { - return $this->foo; - } - - public function setFoo($foo) - { - $this->foo = $foo; - } - - public function getBar() - { - return $this->bar; - } - - public function setBazz($value) - { - $this->bar = $value; - } - - public function gets() // or setupXyz, settle... - { - echo __METHOD__; - return 'ERROR'; - } - -} - - -Assert::error(function () { - $obj = new TestClass; - $obj->foo = 'hello'; -}, E_USER_DEPRECATED, 'Add annotation @property for TestClass::$foo or use setFoo() in ' . __FILE__ . ':' . (__LINE__ - 1)); - -Assert::error(function () { - $obj = new TestClass; - $val = $obj->foo; -}, E_USER_DEPRECATED, 'Add annotation @property for TestClass::$foo or use getFoo() in ' . __FILE__ . ':' . (__LINE__ - 1)); - - -$obj = new TestClass; -@$obj->foo = 'hello'; -Assert::same('hello', @$obj->foo); -Assert::same('hello', @$obj->Foo); - - -@$obj->foo .= ' world'; -Assert::same('hello world', @$obj->foo); - - -// Undeclared property writing -Assert::exception(function () use ($obj) { - $obj->undeclared = 'value'; -}, Nette\MemberAccessException::class, 'Cannot write to an undeclared property TestClass::$undeclared, did you mean $declared?'); - - -// Undeclared property reading -Assert::false(isset($obj->S)); -Assert::false(isset($obj->s)); -Assert::false(isset($obj->undeclared)); - -Assert::exception(function () use ($obj) { - $val = $obj->undeclared; -}, Nette\MemberAccessException::class, 'Cannot read an undeclared property TestClass::$undeclared, did you mean $declared?'); - - -// Read-only property -$obj = new TestClass('Hello', 'World'); -Assert::true(isset($obj->bar)); -Assert::same('World', @$obj->bar); - -Assert::exception(function () use ($obj) { - $obj->bar = 'value'; -}, Nette\MemberAccessException::class, 'Cannot write to a read-only property TestClass::$bar.'); - - -// write-only property -$obj = new TestClass; -Assert::false(isset($obj->bazz)); -@$obj->bazz = 'World'; -Assert::same('World', @$obj->bar); - -Assert::exception(function () use ($obj) { - $val = $obj->bazz; -}, Nette\MemberAccessException::class, 'Cannot read a write-only property TestClass::$bazz.'); diff --git a/tests/Utils/SmartObject.property.phpt b/tests/Utils/SmartObject.property.phpt index 379ce92ee..bc6cf50e6 100644 --- a/tests/Utils/SmartObject.property.phpt +++ b/tests/Utils/SmartObject.property.phpt @@ -67,10 +67,6 @@ class TestClass $obj = new TestClass; $obj->foo = 'hello'; Assert::same('hello', $obj->foo); -Assert::error(function () use ($obj) { - $val = $obj->Foo; -}, E_USER_DEPRECATED, 'Add annotation @property for TestClass::$Foo or use getFoo() in ' . __FILE__ . ':' . (__LINE__ - 1)); - $obj->foo .= ' world'; Assert::same('hello world', $obj->foo); diff --git a/tests/Utils/SmartObject.referenceProperty.old.phpt b/tests/Utils/SmartObject.referenceProperty.old.phpt deleted file mode 100644 index ec30775fa..000000000 --- a/tests/Utils/SmartObject.referenceProperty.old.phpt +++ /dev/null @@ -1,35 +0,0 @@ -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); diff --git a/tests/Utils/SmartObject.reflection.phpt b/tests/Utils/SmartObject.reflection.phpt deleted file mode 100644 index e8b607c84..000000000 --- a/tests/Utils/SmartObject.reflection.phpt +++ /dev/null @@ -1,27 +0,0 @@ -getReflection(); -}, E_USER_DEPRECATED, 'TestClass::getReflection() is deprecated in ' . __FILE__ . ':' . (__LINE__ - 1)); - - -$obj = new TestClass; -Assert::same('TestClass', @$obj->getReflection()->getName()); -Assert::same('TestClass', @$obj->Reflection->getName());