Doc #69475 [Opn->Fbk]: Not clear get_class function behavior

From: Date: Mon, 20 Apr 2015 01:07:06 +0000
Subject: Doc #69475 [Opn->Fbk]: Not clear get_class function behavior
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12211@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69475&edit=1 ID: 69475 Updated by: danack@php.net Reported by: sergey-1987 at yandex dot ru Summary: Not clear get_class function behavior -Status: Open +Status: Feedback Type: Documentation Problem Package: Reflection related PHP Version: 5.4.40 Block user comment: N Private report: N New Comment: It says on the manual page: "NULL became the default value for object, so passing NULL to object now has the same result as not passing any value." and "If object is omitted when inside a class, the name of that class is returned." If that isn't clear enough please can you provide the text you think should be there, preferably as an edit to the manual, through clicking the edit button. Previous Comments: ------------------------------------------------------------------------ [2015-04-17 10:12:43] sergey-1987 at yandex dot ru Description: ------------ --- From manual page: http://www.php.net/function.get-class --- Its not clear that get_class($someClassInstance) will return wrapper class name, instead of FALSE in case $someClassInstance = null. Test script: --------------- <?php class ModelFactory { public static function create($type) { switch ($type) { case 'ModelA': return new ModelA(); break; case 'ModelB': return new ModelB(); break; case 'ModelC': return new ModelC(); break; default: return null; } } } class Controller { function render($type) { $model = ModelFactory::create($type); $view = get_class($model); echo "View name = ".$view; } } $controller = new Controller(); $controller->render('ModelD'); Expected result: ---------------- View name = Actual result: -------------- View name = Controller ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69475&edit=1

« previous php.doc.bugs (#12211) next »