php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #28787 get_class_methods() and get_class_vars() behaviour should be changed
Submitted: 2004-06-15 07:28 UTC Modified: 2004-06-15 21:37 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: frzzman at yahoo dot com Assigned: helly (profile)
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.0.0RC3 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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: frzzman at yahoo dot com
New email:
PHP Version: OS:

 

 [2004-06-15 07:28 UTC] frzzman at yahoo dot com
Description:
------------
When get_class_vars() return every properties of the class, private and protected members are mark with [Class Name] and * before its name, well it better being mark with + or - or # (like UML standard).

Also, this function shouldn't return value of the property as private and protected can only be expose in the scope that have access permission.

Next, get_class_methods() also return every methods the class have, without any marking method?!?! What's the point doing that if I can't figure out if I can access the class's method or not.

I suggest these two function should return all attributes and methods with its access marking.

And another function, maybe get_class_vars_value() to expose default value of attributes in the class, this function should return value of accessible attribute, too.

Reproduce code:
---------------
<?php
class ClassA
{
    private $PrivateVar = null;
    protected $ProtectedVar = null;
    public $PublicVar = null;

    private function PrivateFunc()
    {}
    protected function ProtectedFunc()
    {}
    public function PublicFunc()
    {}
}

var_dump(get_class_vars('ClassA'));
var_dump(get_class_methods('ClassA'));
?>

Expected result:
----------------
array(3) {
  ["PrivateVar"] => string(1) -
  [" * ProtectedVar"] => string(1) #
  ["PublicVar"] => string(1) +
}
array(3) {
  ["PrivateFunc"] => string(1) -
  ["ProtectedFunc"] => string(1) #
  ["PublicFunc"] => string(1) +
}

Actual result:
--------------
array(3) {
  [" ClassA PrivateVar"] => NULL
  [" * ProtectedVar"] => NULL
  ["PublicVar"] => NULL
}
array(3) {
  [0]=> string(11) "PrivateFunc"
  [1]=> string(13) "ProtectedFunc"
  [2]=> string(10) "PublicFunc"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-15 09:25 UTC] frzzman at yahoo dot com
I forgot to include that these function should return the modifier of the member too, to know that public final static AFunction() is a function that can be statically access by public and it doesn't want to be overriden is very useful too.
 [2004-06-15 21:37 UTC] helly@php.net
Use reflection_API.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 11:01:34 2024 UTC