Bug #73632 [Com]: Wrong return of ReflectionParameter::getDefaultValueConstantName()
| From: | bloginteriorhome at gmail dot com | Date: | Tue, 11 Apr 2023 11:49:41 +0000 |
| Subject: | Bug #73632 [Com]: Wrong return of ReflectionParameter::getDefaultValueConstantName() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-244170@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73632&edit=1
ID: 73632
Comment by: bloginteriorhome at gmail dot com
Reported by: fishdrowned at gmail dot com
Summary: Wrong return of
ReflectionParameter::getDefaultValueConstantName()
Status: Verified
Type: Bug
Package: Reflection related
Operating System: Ubuntu 14.04
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Home Create Designs are sharing latest news about home improvement, gadening, decoration, design,
renovate, real estate etc. More info to visit: (https://homecreatedesigns.com)github.com
Previous Comments:
------------------------------------------------------------------------
[2018-02-11 18:38:37] carusogabriel34 at gmail dot com
This an addendum: if the constant is root namespaced, it works!
https://3v4l.org/t149E
------------------------------------------------------------------------
[2016-12-01 17:14:55] cmb@php.net
Confirmed: <https://3v4l.org/WqdX9>.
------------------------------------------------------------------------
[2016-12-01 06:38:24] fishdrowned at gmail dot com
Description:
------------
ReflectionParameter::getDefaultValueConstantName() returns wrong value in namespace context,
in particular, invocated in a namespace, it returns wrong value for global constants
Test script:
---------------
<?php
namespace {
define('SOME_CONSTANT', 1);
}
namespace Some\Name\Space {
use ReflectionFunction;
$reflection = new ReflectionFunction(function ($const = PHP_EOL, $const2 = SOME_CONSTANT) {
});
echo $reflection->getParameters()[0]->getDefaultValueConstantName() . PHP_EOL;
echo $reflection->getParameters()[1]->getDefaultValueConstantName() . PHP_EOL;
}
Expected result:
----------------
PHP_EOL
SOME_CONSTANT
Actual result:
--------------
Some\Name\Space\PHP_EOL
Some\Name\Space\SOME_CONSTANT
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73632&edit=1