jay Fri Mar 7 10:56:31 2003 EDT Added files: /php4/tests/lang type_hints_001.phpt /php4/tests/classes interfaces_001.phpt interfaces_002.phpt type_hinting_001.phpt Log: Added tests for interfaces and class type hinting.
Index: php4/tests/lang/type_hints_001.phpt +++ php4/tests/lang/type_hints_001.phpt --TEST-- ZE2 type hinting --SKIPIF-- <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> --FILE-- <?php class Foo { } class Bar { } function type_hint_foo(Foo $a) { } $foo = new Foo; $bar = new Bar; type_hint_foo($foo); type_hint_foo($bar); ?> --EXPECTF-- Fatal error: Argument 1 must be an instance of foo in %s on line %d Index: php4/tests/classes/interfaces_001.phpt +++ php4/tests/classes/interfaces_001.phpt --TEST-- ZE2 interfaces --SKIPIF-- <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> --FILE-- <?php interface Throwable { public function getMessage(); } class Exception implements Throwable { public $foo = "foo"; public function getMessage() { return $this->foo; } } $foo = new Exception; echo $foo->getMessage() . "\n"; ?> --EXPECT-- foo Index: php4/tests/classes/interfaces_002.phpt +++ php4/tests/classes/interfaces_002.phpt --TEST-- ZE2 interface with an unimplemented method --SKIPIF-- <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> --FILE-- <?php interface Throwable { public function getMessage(); public function getErrno(); } class Exception implements Throwable { public $foo = "foo"; public function getMessage() { return $this->foo; } } // this should die -- Exception class must be abstract... $foo = new Exception; echo $foo->getMessage() . "\n"; ?> --EXPECTF-- Fatal error: Class exception contains abstract methods and must be declared abstract in %s on line %d Index: php4/tests/classes/type_hinting_001.phpt +++ php4/tests/classes/type_hinting_001.phpt --TEST-- ZE2 class type hinting --SKIPIF-- <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> --FILE-- <?php interface Foo { function a(Foo $foo); } interface Bar { function b(Bar $bar); } class FooBar implements Foo, Bar { function a(Foo $foo) { // ... } function b(Bar $bar) { // ... } } class Blort { } $a = new FooBar; $b = new Blort; $a->a($b); $a->b($b); ?> --EXPECTF-- Fatal error: Argument 1 must implement interface foo in %s on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php