Bug #72846 [Opn]: getConstant for a array constant with constant values returns NULL/NFC/UKNOWN
| From: | info at nepda dot eu | Date: | Mon, 15 Aug 2016 15:15:39 +0000 |
| Subject: | Bug #72846 [Opn]: getConstant for a array constant with constant values returns NULL/NFC/UKNOWN | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203297@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72846&edit=1
ID: 72846
User updated by: info at nepda dot eu
Reported by: info at nepda dot eu
Summary: getConstant for a array constant with constant
values returns NULL/NFC/UKNOWN
Status: Open
Type: Bug
Package: Reflection related
Operating System: Linux
PHP Version: 7.0.9
Block user comment: N
Private report: N
New Comment:
With PHP 7.1*beta* it's working too.
Previous Comments:
------------------------------------------------------------------------
[2016-08-15 15:01:10] info at nepda dot eu
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 this bug report at https://bugs.php.net/bug.php?id=72846&edit=1