php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36543 Reflection on exception returns too many methods
Submitted: 2006-02-27 14:55 UTC Modified: 2006-02-28 10:50 UTC
From: RQuadling at GMail dot COM Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.1.2 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: RQuadling at GMail dot COM
New email:
PHP Version: OS:

 

 [2006-02-27 14:55 UTC] RQuadling at GMail dot COM
Description:
------------
Creating a reflection on the inbuilt exception class returns an unexpected duplication of all the methods.


Reproduce code:
---------------
<?php
Reflection::export(new ReflectionClass('abstract_generic_exception'));
?>


Expected result:
----------------
Class [ <internal> class Exception ] {

  - Constants [0] {
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [6] {
    Property [ <default> protected $message ]
    Property [ <default> private $string ]
    Property [ <default> protected $code ]
    Property [ <default> protected $file ]
    Property [ <default> protected $line ]
    Property [ <default> private $trace ]
  }

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

    Method [ <internal, ctor> public method __construct ] {

      - Parameters [2] {
        Parameter #0 [ <required> $message ]
        Parameter #1 [ <required> $code ]
      }
    }

    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 ] {
    }
  }
}

Actual result:
--------------
Class [ <internal> class Exception ] {

  - Constants [0] {
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [6] {
    Property [ <default> protected $message ]
    Property [ <default> private $string ]
    Property [ <default> protected $code ]
    Property [ <default> protected $file ]
    Property [ <default> protected $line ]
    Property [ <default> private $trace ]
  }

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

    Method [ <internal, ctor> public method __construct ] {

      - Parameters [2] {
        Parameter #0 [ <required> $message ]
        Parameter #1 [ <required> $code ]
      }
    }

    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 ] {
    }

    Method [ <internal> public method __toString ] {
    }

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

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

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

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

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

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

    Method [ <internal, ctor> public method __construct ] {

      - Parameters [2] {
        Parameter #0 [ <required> $message ]
        Parameter #1 [ <required> $code ]
      }
    }

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



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-27 15:02 UTC] RQuadling at GMail dot COM
AMEND: Reflecting on any internal class reports duplicate methods.

<?php
foreach(get_declared_classes() as $s_class)
	{
	Reflection::export(new ReflectionClass($s_class));
	}
?>

Run the following code into a log file to see duplicates.
 [2006-02-27 15:03 UTC] RQuadling at GMail dot COM
Ha.

I disabled the Zend Optimizer (V3.0.0-Beta2) and the issue is resolved.
 [2006-02-27 15:04 UTC] johannes@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2006-02-27 15:05 UTC] johannes@php.net
.
 [2006-02-27 15:08 UTC] tony2001@php.net
There is no such class (where did you get it?) and I can't reproduce it with other exception classes.
 [2006-02-27 15:08 UTC] tony2001@php.net
Do not file bugs when you have Zend extensions (zend_extension=)
loaded. Examples are Zend Optimizer, Zend Debugger, Turck MM Cache,
APC, Xdebug and ionCube loader.  These extensions often modify engine
behavior which is not related to PHP itself.


 [2006-02-27 15:11 UTC] RQuadling at GMail dot COM
<?php
Reflection::export(new ReflectionClass('Exception'));
?>

Ah!

The Win32 builds are not working. Last available download from http://snaps.php.net/win32 is February 20th
 [2006-02-28 10:50 UTC] RQuadling at GMail dot COM
I got a response from Zend on this, so I'll put it here for completeness in case anyone else is looking for this.

"This behavior is intentional, and is not a bug. Zend Optimizer 3.0 does
this to accommodate for Zend SafeGuard 4.0's code obfuscation features.

If you want to override this, you can set this directive in php.ini:
zend_optimizer.obfuscation_level_support=0"

I've also confirmed that this works.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC