mirror of
https://github.com/dg/dibi.git
synced 2025-08-30 09:19:48 +02:00
used PHP 7.1 features
- ::class - ... argument unpacking - removed call_user_func - operator ?? - list() - short <?=
This commit is contained in:
@@ -51,53 +51,53 @@ class TestChild extends TestClass
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
$obj->undeclared();
|
||||
}, 'LogicException', 'Call to undefined method TestClass::undeclared().');
|
||||
}, LogicException::class, 'Call to undefined method TestClass::undeclared().');
|
||||
|
||||
Assert::exception(function () {
|
||||
TestClass::undeclared();
|
||||
}, 'LogicException', 'Call to undefined static method TestClass::undeclared().');
|
||||
}, LogicException::class, 'Call to undefined static method TestClass::undeclared().');
|
||||
|
||||
Assert::exception(function () {
|
||||
$obj = new TestChild;
|
||||
$obj->callParent();
|
||||
}, 'LogicException', 'Call to undefined method parent::callParent().');
|
||||
}, LogicException::class, 'Call to undefined method parent::callParent().');
|
||||
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
$obj->publicMethodX();
|
||||
}, 'LogicException', 'Call to undefined method TestClass::publicMethodX(), did you mean publicMethod()?');
|
||||
}, LogicException::class, 'Call to undefined method TestClass::publicMethodX(), did you mean publicMethod()?');
|
||||
|
||||
Assert::exception(function () { // suggest static method
|
||||
$obj = new TestClass;
|
||||
$obj->publicMethodStaticX();
|
||||
}, 'LogicException', 'Call to undefined method TestClass::publicMethodStaticX(), did you mean publicMethodStatic()?');
|
||||
}, LogicException::class, 'Call to undefined method TestClass::publicMethodStaticX(), did you mean publicMethodStatic()?');
|
||||
|
||||
Assert::exception(function () { // suggest only public method
|
||||
$obj = new TestClass;
|
||||
$obj->protectedMethodX();
|
||||
}, 'LogicException', 'Call to undefined method TestClass::protectedMethodX().');
|
||||
}, LogicException::class, 'Call to undefined method TestClass::protectedMethodX().');
|
||||
|
||||
|
||||
// writing
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
$obj->undeclared = 'value';
|
||||
}, 'LogicException', 'Attempt to write to undeclared property TestClass::$undeclared.');
|
||||
}, LogicException::class, 'Attempt to write to undeclared property TestClass::$undeclared.');
|
||||
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
$obj->publicX = 'value';
|
||||
}, 'LogicException', 'Attempt to write to undeclared property TestClass::$publicX, did you mean $public?');
|
||||
}, LogicException::class, 'Attempt to write to undeclared property TestClass::$publicX, did you mean $public?');
|
||||
|
||||
Assert::exception(function () { // suggest only non-static property
|
||||
$obj = new TestClass;
|
||||
$obj->publicStaticX = 'value';
|
||||
}, 'LogicException', 'Attempt to write to undeclared property TestClass::$publicStaticX.');
|
||||
}, LogicException::class, 'Attempt to write to undeclared property TestClass::$publicStaticX.');
|
||||
|
||||
Assert::exception(function () { // suggest only public property
|
||||
$obj = new TestClass;
|
||||
$obj->protectedX = 'value';
|
||||
}, 'LogicException', 'Attempt to write to undeclared property TestClass::$protectedX.');
|
||||
}, LogicException::class, 'Attempt to write to undeclared property TestClass::$protectedX.');
|
||||
|
||||
|
||||
// property getter
|
||||
@@ -112,29 +112,29 @@ Assert::same(456, $obj->foo);
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
$val = $obj->undeclared;
|
||||
}, 'LogicException', 'Attempt to read undeclared property TestClass::$undeclared.');
|
||||
}, LogicException::class, 'Attempt to read undeclared property TestClass::$undeclared.');
|
||||
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
$val = $obj->publicX;
|
||||
}, 'LogicException', 'Attempt to read undeclared property TestClass::$publicX, did you mean $public?');
|
||||
}, LogicException::class, 'Attempt to read undeclared property TestClass::$publicX, did you mean $public?');
|
||||
|
||||
Assert::exception(function () { // suggest only non-static property
|
||||
$obj = new TestClass;
|
||||
$val = $obj->publicStaticX;
|
||||
}, 'LogicException', 'Attempt to read undeclared property TestClass::$publicStaticX.');
|
||||
}, LogicException::class, 'Attempt to read undeclared property TestClass::$publicStaticX.');
|
||||
|
||||
Assert::exception(function () { // suggest only public property
|
||||
$obj = new TestClass;
|
||||
$val = $obj->protectedX;
|
||||
}, 'LogicException', 'Attempt to read undeclared property TestClass::$protectedX.');
|
||||
}, LogicException::class, 'Attempt to read undeclared property TestClass::$protectedX.');
|
||||
|
||||
|
||||
// unset/isset
|
||||
Assert::exception(function () {
|
||||
$obj = new TestClass;
|
||||
unset($obj->undeclared);
|
||||
}, 'LogicException', 'Attempt to unset undeclared property TestClass::$undeclared.');
|
||||
}, LogicException::class, 'Attempt to unset undeclared property TestClass::$undeclared.');
|
||||
|
||||
Assert::false(isset($obj->undeclared));
|
||||
|
||||
|
Reference in New Issue
Block a user