Bug #72846 [NEW]: getConstant for a array constant with constant values returns NULL/NFC/UKNOWN
| From: | info at nepda dot eu | Date: | Mon, 15 Aug 2016 15:01:12 +0000 |
| Subject: | Bug #72846 [NEW]: getConstant for a array constant with constant values returns NULL/NFC/UKNOWN | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-203295@lists.php.net to get a copy of this message | ||
From: info at nepda dot eu
Operating system: Linux
PHP version: 7.0.9
Package: Reflection related
Bug Type: Bug
Bug description:getConstant for a array constant with constant values returns NULL/NFC/UKNOWN
Description:
------------
If you have any namespace (e.g. "Some") and a (abstract or concrete)
class (e.g. "A") with some constants in it and a class (e.g. "B")
extending "A", the reflection class is not able to get the constant
values of an array constant with constant values in it.
See example code.
Output with PHP 7.0.9:
see "Actual result:"
with PHP 5.6.24 it's working:
see "Expected result:"
Without the namespace, it's working on both versions.
Test script:
---------------
<?php
namespace Some {
abstract class A
{
const ONE = '1';
const TWO = '2';
const CONST_NUMBERS = [
self::ONE,
self::TWO,
];
const NUMBERS = [
'1',
'2',
];
}
class B extends A
{
}
$ref = new \ReflectionClass('Some\B');
var_dump($ref->getConstant('ONE'));
var_dump($ref->getConstant('CONST_NUMBERS'));
var_dump($ref->getConstant('NUMBERS'));
}
Expected result:
----------------
string(1) "1"
array(2) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
}
array(2) {
[0]=>
int(10)
[1]=>
int(11)
}
Actual result:
--------------
string(1) "1"
UNKNOWN:0
array(2) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=72846&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72846&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72846&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72846&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72846&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72846&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72846&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72846&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72846&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72846&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72846&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72846&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72846&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72846&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72846&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72846&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72846&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72846&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72846&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72846&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72846&r=mysqlcfg