note 103729 added to language.oop5.typehinting

From: Date: Sat, 30 Apr 2011 01:33:51 +0000
Subject: note 103729 added to language.oop5.typehinting
Groups: php.notes 
Request: Send a blank email to php-notes+get-179295@lists.php.net to get a copy of this message
i use eclipse ganymede as an IDE and it offers "intellisense" where it can, i.e. when variables are "declared" via type hinting or a "new"-statement . i found using the following pattern helps eclipse along as well: class MyClass{ public static function Cast(MyClass &$object=NULL){ return $object; } public method CallMe(){ } } $x=unserialize($someContent); $x=MyObject::Cast($x); $x->CallMe(); after calling Cast(), due to the type hinting, eclipse offers me the "CallMe" function in a dropdown when i type "$x->" in the code afterwards. i found this very practical und included the Cast() function in my code template for new classes. i've been wondering, if there is a drawback i oversaw, but i haven't noticed any negative effects so far... maybe some of you will find this just as handy as i do ;o) p.s. do note: when used in inherited classes a STRICT-notice comes up, because the function definition of the inherited class doesn't match the parent's definition (different type hinting) - but it works great! ---- Server IP: 69.147.83.197 Probable Submitter: 87.79.95.2 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.typehinting.php Edit -- https://master.php.net/note/edit/103729 Del: integrated -- https://master.php.net/note/delete/103729/integrated Del: useless -- https://master.php.net/note/delete/103729/useless Del: bad code -- https://master.php.net/note/delete/103729/bad+code Del: spam -- https://master.php.net/note/delete/103729/spam Del: non-english -- https://master.php.net/note/delete/103729/non-english Del: in docs -- https://master.php.net/note/delete/103729/in+docs Del: other reasons-- https://master.php.net/note/delete/103729 Reject -- https://master.php.net/note/reject/103729 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179295) next »