parent
6ff687e1da
commit
689b59bbda
6 changed files with 143 additions and 14 deletions
@ -0,0 +1,23 @@ |
|||||||
|
--TEST-- |
||||||
|
ZE2 interfaces |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
interface ThrowableInterface { |
||||||
|
public function getMessage(); |
||||||
|
} |
||||||
|
|
||||||
|
class Exception_foo implements ThrowableInterface { |
||||||
|
public $foo = "foo"; |
||||||
|
|
||||||
|
public function getMessage() { |
||||||
|
return $this->foo; |
||||||
|
} |
||||||
|
} |
||||||
|
function main() { |
||||||
|
$foo = new Exception_foo; |
||||||
|
echo $foo->getMessage() . "\n"; |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
foo |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
--TEST-- |
||||||
|
ZE2 interface with an unimplemented method |
||||||
|
--SKIPIF-- |
||||||
|
<?php die('skip'); ?> |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
interface ThrowableInterface { |
||||||
|
public function getMessage(); |
||||||
|
public function getErrno(); |
||||||
|
} |
||||||
|
|
||||||
|
class Exception_foo implements ThrowableInterface { |
||||||
|
public $foo = "foo"; |
||||||
|
|
||||||
|
public function getMessage() { |
||||||
|
return $this->foo; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main() { |
||||||
|
// this should die -- Exception class must be abstract... |
||||||
|
$foo = new Exception_foo; |
||||||
|
echo "Message: " . $foo->getMessage() . "\n"; |
||||||
|
} |
||||||
|
|
||||||
|
?> |
||||||
|
--EXPECTF-- |
||||||
|
Fatal error: Class Exception_foo contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (ThrowableInterface::getErrno) in %s on line %d |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
--TEST-- |
||||||
|
ZE2 interface and __construct |
||||||
|
--SKIPIF-- |
||||||
|
<?php die('skip'); ?> |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class MyObject {} |
||||||
|
|
||||||
|
interface MyInterface |
||||||
|
{ |
||||||
|
public function __construct(MyObject $o); |
||||||
|
} |
||||||
|
|
||||||
|
class MyTestClass implements MyInterface |
||||||
|
{ |
||||||
|
public function __construct(MyObject $o) |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
function main() { |
||||||
|
$obj = new MyTestClass; |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECTF-- |
||||||
|
Fatal error: Uncaught ArgumentCountError: Too few arguments to function MyTestClass::__construct(), 0 passed in %sinterfaces_003.php on line 17 and exactly 1 expected in %sinterfaces_003.php:12 |
||||||
|
Stack trace: |
||||||
|
#0 %s(%d): MyTestClass->__construct() |
||||||
|
#1 {main} |
||||||
|
thrown in %sinterfaces_003.php on line %d |
||||||
Loading…
Reference in new issue