Bug #72846 [Opn->Csd]: getConstant for a array constant with constant values returns NULL/NFC/UKNOWN
| From: | laruence@php.net | Date: | Mon, 15 Aug 2016 15:25:33 +0000 |
| Subject: | Bug #72846 [Opn->Csd]: 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-203296@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
Updated by: laruence@php.net
Reported by: info at nepda dot eu
Summary: getConstant for a array constant with constant
values returns NULL/NFC/UKNOWN
-Status: Open
+Status: Closed
Type: Bug
Package: Reflection related
Operating System: Linux
PHP Version: 7.0.9
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=60de74ebdae5cf8b14f85d6e60f519c9e8b966f9
Log: Fixed bug #72846 (getConstant for a array constant with constant values returns
NULL/NFC/UKNOWN)
Previous Comments:
------------------------------------------------------------------------
[2016-08-15 15:15:38] info at nepda dot eu
With PHP 7.1*beta* it's working too.
------------------------------------------------------------------------
[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