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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 05:01:33 2025 UTC