php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75157 function_exists() doesn't recognize imported functions
Submitted: 2017-09-04 17:27 UTC Modified: 2017-09-04 17:56 UTC
From: cmb@php.net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.0.23 OS: *
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: cmb@php.net
New email:
PHP Version: OS:

 

 [2017-09-04 17:27 UTC] cmb@php.net
Description:
------------
If a namespaced function is imported into the global scope it is
apparently not recognized by function_exists().


Test script:
---------------
<?php

namespace Foo {
    function bar() {
        echo 'I am there!';
    }
}

namespace {
    use function Foo\bar;

    var_dump(function_exists('bar'));
    bar();
}


Expected result:
----------------
bool(true)
I am there!


Actual result:
--------------
bool(false)
I am there!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-09-04 17:31 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2017-09-04 17:31 UTC] nikic@php.net
Just like with classes, function names in strings must always be fully qualified. "use function" is not a global reexport of the symbol, it's a local alias of the name.
 [2017-09-04 17:56 UTC] cmb@php.net
> "use function" is not a global reexport of the symbol, it's a
> local alias of the name.

Of course! Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC