php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43719 Confusing behaviour of "use" with functions
Submitted: 2007-12-31 14:34 UTC Modified: 2008-01-01 16:13 UTC
From: sebastian@php.net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-12-31 (CVS) OS: Irrelevant
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: sebastian@php.net
New email:
PHP Version: OS:

 

 [2007-12-31 14:34 UTC] sebastian@php.net
Description:
------------
sb@vmware ~ % cat a.php             
<?php
namespace a;

function b() {}


sb@vmware ~ % cat b.php && php b.php
<?php
require 'a.php';

use a;
b();

Warning: The use statement with non-compound name 'a' has no effect in /home/sb/b.php on line 4

Fatal error: Call to undefined function b() in /home/sb/b.php on line 5


sb@vmware ~ % cat b.php && php b.php
<?php
require 'a.php';

use a::b;
b();

Fatal error: Call to undefined function b() in /home/sb/b.php on line 5

Expected result:
----------------
Not sure.

Actual result:
--------------
See above.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-01 16:13 UTC] johannes@php.net
use a;
This would use the class "a" as "a". The Warning tells you that this statement has no effect.

or the second case:
It was a design decision that functions can't be "use"d, see a recent post from Stas on internals on that.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Dec 13 20:00:01 2025 UTC