php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #10172 get_class() doesn't return lowercase for DomX objects
Submitted: 2001-04-04 20:41 UTC Modified: 2002-06-08 11:13 UTC
From: colin at easydns dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0 Latest CVS (04/04/2001) OS: RH 7.0
Private report: No CVE-ID: None
 [2001-04-04 20:41 UTC] colin at easydns dot com
get_class() is documented to return the class/object name in lowercase.

This isn't the case for DomText, DomDocument, etc. objects.  In these cases, get_class() returns the StudyCaps version of the object name.

- Colin

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-21 19:35 UTC] mfischer@php.net
get_class() only returns user defined classes in lowercase.

Classes defined in extensions are returned in their original notation.

Making this a documentation problem.
 [2001-11-22 11:08 UTC] colin at easydns dot com
Well, I suppose it is a documentation problem of sorts ... but my preference would be for the get_class() function to be consistent, regardless of whether the class is user-defined or extention-defined.

Any reason why this shouldn't be consistent?

- Colin
 [2001-11-22 16:04 UTC] philip@php.net
Seems strange.  Docs have been updated to reflect current 
behavior.  Changing status to 'feedback'.

 [2001-11-22 16:52 UTC] colin at easydns dot com
I *really* don't think this should be a documentation fix, I think the get_class() function needs to be changed to always return lowercase.

Here is the required patch:


cmv@vincent:/usr/local/sources/php4/Zend$ diff -u zend_builtin_functions.c NEW.zend_builtin_functions.c 
--- zend_builtin_functions.c    Thu Nov 22 16:49:26 2001
+++ NEW.zend_builtin_functions.c        Thu Nov 22 16:51:30 2001
@@ -458,7 +458,8 @@
 {
        zval **arg;
        zend_class_entry *ce;
-
+       char *lcname;
+
        if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &arg)==FAILURE) {
                ZEND_WRONG_PARAM_COUNT();
        }
@@ -467,7 +468,10 @@
        }
 
        ce = Z_OBJCE_PP(arg);
-       RETURN_STRINGL(ce->name, ce->name_length, 1);
+       lcname = estrndup(ce->name, ce->name_length);
+       zend_str_tolower(lcname, ce->name_length);
+
+       RETURN_STRINGL(lcname, ce->name_length, 1);
 }
 /* }}} */


- Colin
 [2001-11-22 17:05 UTC] goba@php.net
OK, but this docfix was right, as this is the current
case, and it should be documented. If this patch goes
throuh, and it arrives in some version, we can add
a note, that this strange behaviour existed till eg.
4.1.0 and it is corrected after that release...
 [2002-06-08 11:13 UTC] mfischer@php.net
Has already been documented.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Sep 10 05:01:28 2024 UTC