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
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: 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

Pull Requests

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 Dec 27 03:01:28 2024 UTC