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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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 Apr 18 11:01:28 2024 UTC