|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #69475 Not clear get_class function behavior
Submitted: 2015-04-17 10:12 UTC Modified: 2015-05-03 04:22 UTC
From: sergey-1987 at yandex dot ru Assigned:
Status: No Feedback Package: Reflection related
PHP Version: 5.4.40 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: sergey-1987 at yandex dot ru
New email:
PHP Version: OS:


 [2015-04-17 10:12 UTC] sergey-1987 at yandex dot ru
From manual page:

Its not clear that get_class($someClassInstance) will return wrapper class name, instead of FALSE in case $someClassInstance = null.

Test script:
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();

Expected result:
View name = 

Actual result:
View name = Controller


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-20 01:07 UTC]
-Status: Open +Status: Feedback
 [2015-04-20 01:07 UTC]
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.
 [2015-05-03 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Mar 29 03:03:40 2023 UTC