php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28114 Reflection API doesn't return parameter data for built-in methods
Submitted: 2004-04-23 01:42 UTC Modified: 2005-01-10 20:05 UTC
Votes:6
Avg. Score:4.3 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:4 (80.0%)
From: adam at trachtenberg dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5CVS-2005-01-10 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-04-23 01:42 UTC] adam at trachtenberg dot com
Description:
------------
The Reflection API doesn't return parameter information 
for built-in classes, like it does for user-defined 
classes.

Reproduce code:
---------------
// userland class
class ReflectionTest {
  function test($foo, $bar) {}
}

Reflection::export(
  new ReflectionClass('ReflectionTest'));

// example of a system class
Reflection::export(new ReflectionClass('Exception'));

Expected result:
----------------
The "methods" section of "Exception" should look like 
similar to the "methods" section of "ReflectionTest"

In other words, there should be a "Parameters" block for 
methods, like __construct(), that take parameters. This 
doesn't just apply to Exception, but all classes written 
in C.

Actual result:
--------------
ReflectionTest:

  - Methods [1] {
    Method [ <user> public method test ] {
      @@ /www/reflection.php 9 - 9

      - Parameters [2] {
        Parameter #0 [ $foo ]
        Parameter #1 [ $bar ]
      }
    }

Exception: 

  - Methods [9] {
    Method [ <internal> final private method __clone ] {
    }

    Method [ <internal> <ctor> method __construct ] {
    }

    Method [ <internal> final public method getMessage ] 
{
    }

    Method [ <internal> final public method getCode ] {
    }

    Method [ <internal> final public method getFile ] {
    }

    Method [ <internal> final public method getLine ] {
    }

    Method [ <internal> final public method getTrace ] {
    }

    Method [ <internal> final public method 
getTraceAsString ] {
    }

    Method [ <internal> public method __toString ] {
    }

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-23 01:50 UTC] helly@php.net
This is a known issue for several internal classes.

Btw, why don't you use:
php -r 'ReflectionClass::export($argv[1]);' ?
 [2004-04-23 05:49 UTC] adam at trachtenberg dot com
Your example is shorter, but I wanted to make it clear 
that things worked okay for user defined classes. BTW, I 
didn't know this was a known issue.
 [2005-01-10 15:23 UTC] sniper@php.net
Still an issue?

 [2005-01-10 18:08 UTC] adam at trachtenberg dot com
Yes. For example:

php -r 'ReflectionClass::export(ReflectionClass);'

None of the methods have parameters, and I know some of them (__construct, export, etc.) definitely do.
 [2005-01-10 20:05 UTC] helly@php.net
It is impossible to get the values of the default parameters.

Getting the types for the parameters depends on the developers of the classes. The classes i did should all have that information.

For the rest i set the report to won't fix because i don't suppose you can convince the developers to add that information. Or you do it yourself :-)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 16:01:31 2024 UTC