php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67133 Aliasing of aliased methods does not work
Submitted: 2014-04-26 00:56 UTC Modified: 2014-04-26 03:15 UTC
From: liranuna at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.6.0beta1 OS: Any
Private report: No CVE-ID: None
 [2014-04-26 00:56 UTC] liranuna at gmail dot com
Description:
------------
A new feature added in 5.6 allows functions to be imported and aliased.
It is possible to re-alias an already imported function but that does not seem to work.

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

namespace foo\bar {
  function baz() { return __FUNCTION__; }
}

namespace {
  use function foo\bar\baz as foobarbaz;
  use function foobarbaz as foobar;

  var_dump(foobar());
}

Expected result:
----------------
string(11) "foo\bar\baz"
string(11) "foo\bar\baz"

Actual result:
--------------
string(11) "foo\bar\baz"

Fatal error: Call to undefined function foobarbaz() in %s/test_case.php on line 12

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-26 01:43 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-04-26 01:43 UTC] requinix@php.net
> It is possible to re-alias an already imported function
It's not. Have you seen something suggesting that it is?
 [2014-04-26 02:56 UTC] liranuna at gmail dot com
Then the problem is in the line 

  use function foobarbaz as foobar;

It should have errored and disallowing the alias.
 [2014-04-26 03:15 UTC] requinix@php.net
As happens with class aliases, function aliases are resolved before the script even executes, and that's too early for PHP to check that the function has been defined. For all intents and purposes it's as if you had written var_dump(foobarbaz()) - and PHP won't warn you beforehand about that either.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 17:00:02 2026 UTC