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

[email protected] ("RQuadling at GMail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               45765
 User updated by:  RQuadling at GMail dot com
 Reported By:      RQuadling at GMail dot com
 Status:           Open
 Bug Type:         SPL related
 Operating System: Windows XP SP2
 PHP Version:      5.3CVS-2008-08-08 (snap)
 New Comment:

If I change the default to a string, the output is (and I just noticed
that it is truncated) ...

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 = 'Replaced self::...' ]
      }
    }
  }
}


Previous Comments:
------------------------------------------------------------------------

[2008-08-08 15:16:21] RQuadling at GMail dot com

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 this bug report at http://bugs.php.net/?id=45765&edit=1
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.