php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65244 function_exist() returns false when using imported namespace alias
Submitted: 2013-07-11 15:47 UTC Modified: 2013-07-12 13:00 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: strategycon at yahoo dot com Assigned:
Status: Wont fix Package: Reflection related
PHP Version: 5.3Git-2013-07-11 (snap) OS: Ubuntu
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: strategycon at yahoo dot com
New email:
PHP Version: OS:

 

 [2013-07-11 15:47 UTC] strategycon at yahoo dot com
Description:
------------
namespace mynamespace;

use Symfony\Component\Validator\Constraints as Assert;

class myClass
{
    function classExists($name == 'NotBlank')
    {
        return function_exists('Assert\\' . $name)
    }

    function classExistsExt($name == 'NotBlank')
    {
        return function_exists('Symfony\Component\Validator\Constraints\\' . 
$name)
    }
}

myClass::classExists()
// returns false

myClass::classExists()
// returns true



Expected result:
----------------
To fully benefit from namespace importing and "aliasing", I would expect that 
method to return true when namespace alias is used instead of full/original one.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-12 12:30 UTC] ab@php.net
Compile vs. execution phase is that.
 [2013-07-12 13:00 UTC] nikic@php.net
-Status: Open +Status: Wont fix
 [2013-07-12 13:00 UTC] nikic@php.net
Function names, class names and generally all names passed as strings are always fully qualified. For classes PHP 5.5 added the ::class syntax to easily get the FQCN from an alias.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 05:01:29 2024 UTC