Bug #67133 [Nab]: Aliasing of aliased methods does not work
| From: | requinix@php.net | Date: | Sat, 26 Apr 2014 03:15:13 +0000 |
| Subject: | Bug #67133 [Nab]: Aliasing of aliased methods does not work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185449@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67133&edit=1
ID: 67133
Updated by: requinix@php.net
Reported by: liranuna at gmail dot com
Summary: Aliasing of aliased methods does not work
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Any
PHP Version: 5.6.0beta1
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2014-04-26 02:56:56] 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 01:43:57] 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 00:56:54] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67133&edit=1