note 77523 added to language.oop5.typehinting

From: Date: Sun, 02 Sep 2007 05:29:50 +0000
Subject: note 77523 added to language.oop5.typehinting
Groups: php.notes 
Request: Send a blank email to php-notes+get-130085@lists.php.net to get a copy of this message
1. It should certainly be added to the manual, that type hinting expects either the specified class, or its derivative (subclass). 2. What disturbs me is the fact that function with type hinting is executed nonetheless, even if type mismatch exception occurs: <?php $a = new B(); Test($a); class A { public $name = 'A'; public function show() { print($this->name); } } class B { public $name = 'B'; public function show() { print($this->name); } } function test(A $obj) { $obj->show(); } ?> The code above will produce fatal error, *and* will print 'B' anyway. Should type mismatch prevent function from execution? ---- Server IP: 69.147.83.197 Probable Submitter: 213.228.91.81 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.typehinting.php Edit -- https://master.php.net/note/edit/77523 Del: integrated -- https://master.php.net/note/delete/77523/integrated Del: useless -- https://master.php.net/note/delete/77523/useless Del: bad code -- https://master.php.net/note/delete/77523/bad+code Del: spam -- https://master.php.net/note/delete/77523/spam Del: non-english -- https://master.php.net/note/delete/77523/non-english Del: in docs -- https://master.php.net/note/delete/77523/in+docs Del: other reasons-- https://master.php.net/note/delete/77523 Reject -- https://master.php.net/note/reject/77523 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130085) next »