Skip to content

Commit

Permalink
SmartObject: better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 2, 2018
1 parent 8c97213 commit 1830698
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Utils/SmartObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function &__get($name)
}

} 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);
trigger_error("Accessing methods as properties via \$obj->$name is deprecated, use PHP callback [\$obj, '$name']" . ObjectMixin::getSource(), E_USER_DEPRECATED);
$val = Callback::closure($this, $name);
return $val;

Expand Down
2 changes: 1 addition & 1 deletion tests/Utils/SmartObject.methodGetter.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestClass
Assert::error(function () {
$obj = new TestClass;
$obj->publicMethod;
}, E_USER_DEPRECATED, 'Accessing methods as properties via $obj->publicMethod is deprecated in ' . __FILE__ . ':' . (__LINE__ - 1));
}, E_USER_DEPRECATED, 'Accessing methods as properties via $obj->publicMethod is deprecated, use PHP callback [$obj, \'publicMethod\'] in ' . __FILE__ . ':' . (__LINE__ - 1));


$obj1 = new TestClass(1);
Expand Down

0 comments on commit 1830698

Please sign in to comment.