php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72222 ReflectionClass::export doesn't handle array constants
Submitted: 2016-05-16 10:51 UTC Modified: 2016-07-13 19:55 UTC
From: inefedor at gmail dot com Assigned: nikic
Status: Closed Package: Reflection related
PHP Version: Irrelevant OS: any
Private report: No CVE-ID:
 [2016-05-16 10:51 UTC] inefedor at gmail dot com
Description:
------------
ReflectionClass::export doesn't handle array constants and results in a Notice error being thrown. (because of direct call to `zval_get_string()` in reflection  ext) https://3v4l.org/X4EN0


Test script:
---------------
class A {
    const FOO = [1];
}
ReflectionClass::export("A");


Expected result:
----------------
Class [ <user> class A ] {
  @@ /in/X4EN0 3-5

  - Constants [1] {
    Constant [ array FOO ] { Array }
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [0] {
  }

  - Methods [0] {
  }
}

Actual result:
--------------
Notice: Array to string conversion in /in/X4EN0 on line 6
Class [ <user> class A ] {
  @@ /in/X4EN0 3-5

  - Constants [1] {
    Constant [ array FOO ] { Array }
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [0] {
  }

  - Methods [0] {
  }
}

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-16 11:36 UTC] inefedor at gmail dot com
I have created two PRs targeted at master and PHP-5.6 branches with fixes
 [2016-07-13 19:55 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Fri May 26 01:01:38 2017 UTC