#45765 [NEW]: ReflectionObject with default parameters of self:xxx cause an error.

[email protected] ("RQuadling at GMail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
From:             RQuadling at GMail dot com
Operating system: Windows XP SP2
PHP version:      5.3CVS-2008-08-08 (snap)
PHP Bug Type:     SPL related
Bug description:  ReflectionObject with default parameters of self:xxx cause an error.

Description:
------------
If you have a method with a parameter whose default is a local class
constant, the ReflectionObject throws a Fatal Error.

Reproduce code:
---------------
<?php
class foo {
 const BAR = "foo's bar";

 function test ($s_Text = self::BAR) {
  echo $s_Text, PHP_EOL;
 }

}

$o_Foo = new foo();

ReflectionObject::export($o_Foo);

Expected result:
----------------
Object of class [ <user> class foo ] {
  @@ C:\tr.php 2-9

  - Constants [1] {
    Constant [ string BAR ] { foo's bar }
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [0] {
  }

  - Dynamic properties [0] {
  }

  - Methods [1] {
    Method [ <user> public method test ] {
      @@ C:\tr.php 5 - 7

      - Parameters [1] {
        Parameter #0 [ <optional> $s_Text = self::BAR]
      }
    }
  }
}

Actual result:
--------------
Fatal error: Undefined class constant 'self::BAR' in C:\tr.php on line 13

-- 
Edit bug report at http://bugs.php.net/?id=45765&edit=1
-- 
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45765&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45765&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45765&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45765&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=45765&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45765&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45765&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45765&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45765&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45765&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=45765&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=45765&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45765&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45765&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45765&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45765&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45765&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45765&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45765&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45765&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.