php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73632 Wrong return of ReflectionParameter::getDefaultValueConstantName()
Submitted: 2016-12-01 06:38 UTC Modified: 2016-12-01 17:14 UTC
Votes:3
Avg. Score:3.7 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: fishdrowned at gmail dot com Assigned:
Status: Verified Package: Reflection related
PHP Version: Irrelevant OS: Ubuntu 14.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fishdrowned at gmail dot com
New email:
PHP Version: OS:

 

 [2016-12-01 06:38 UTC] 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-01 17:14 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2016-12-01 17:14 UTC] cmb@php.net
Confirmed: <https://3v4l.org/WqdX9>.
 [2018-02-11 18:38 UTC] carusogabriel34 at gmail dot com
This an addendum: if the constant is root namespaced, it works!

https://3v4l.org/t149E
 [2023-04-11 11:49 UTC] bloginteriorhome at gmail dot com
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
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 19:01:29 2024 UTC