Bug #73632 [Opn->Ver]: Wrong return of ReflectionParameter::getDefaultValueConstantName()

From: Date: Thu, 01 Dec 2016 17:14:56 +0000
Subject: Bug #73632 [Opn->Ver]: Wrong return of ReflectionParameter::getDefaultValueConstantName()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205721@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
 Updated by:         cmb@php.net
 Reported by:        fishdrowned at gmail dot com
 Summary:            Wrong return of
                     ReflectionParameter::getDefaultValueConstantName()
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            Reflection related
 Operating System:   Ubuntu 14.04
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Confirmed: <https://3v4l.org/WqdX9>.


Previous Comments:
------------------------------------------------------------------------
[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


Thread (4 messages)

« previous php.bugs (#205721) next »