# Question on "use" behavior

- Thread: https://externals.io/message/34164
- Original archive: https://news-web.php.net/php.internals/34164
- Started by Martin Alterisio on 2007-12-20T19:20:04+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #34164 — Martin Alterisio — 2007-12-20T19:20:04+00:00

URL: https://externals.io/message/34164#34164

Consider the following code:

test.php:
<?php
include 'foo.php';
use test::foo;
foo();
?>

foo.php:
<?php
namespace test;
function foo() { }
?>

Is it expected behavior that the scripts ends in:
Fatal error: Call to undefined function foo()
?

That's all for now.
Best regards,

Martin Alterisio

PS: Is there any benchmark that could be run to test out what's the impact
of the delayed name resolutions? I believe is not considerable but I'd like
to test in my machine and provide some feedback, and I don't know if what
I'm trying to do as benchmark is reliable ("time <phpscript>" and
shell-scripting for data compilation).

---

## #34185 — Greg Beaver — 2007-12-20T21:57:03+00:00

URL: https://externals.io/message/34164#34185 · In reply to: #34164

Martin Alterisio wrote:
> Consider the following code:
> 
> test.php:
> <?php
> include 'foo.php';
> use test::foo;
> foo();
> ?>
> 
> foo.php:
> <?php
> namespace test;
> function foo() { }
> ?>
> 
> Is it expected behavior that the scripts ends in:
> Fatal error: Call to undefined function foo()
> ?

Hi Martin,

No.  This is a bug, I was alluding to it in an earlier email, but you
know how time eats up one's life, so I haven't reported it and would
grateful if someone would (or Dmitry/Stas would just know why it is
broken and fix it :)

Greg

---

## #34187 — Martin Alterisio — 2007-12-20T23:09:39+00:00

URL: https://externals.io/message/34164#34187 · In reply to: #34185

2007/12/20, Greg Beaver <cellog@php.net>:
>
> Martin Alterisio wrote:
> > […]
>
> Hi Martin,
>
> No.  This is a bug, I was alluding to it in an earlier email, but you
> know how time eats up one's life, so I haven't reported it and would
> grateful if someone would (or Dmitry/Stas would just know why it is
> broken and fix it :)
>
> Greg
>

Thank you. Sorry I didn't read your mail about this bug. I'll look into it a
bit more and post a bug report.

Have you seen my post scriptum in the first mail about benchmarks? Any idea
of what I could use to test the performance of the unsolved name resolutions
that are pushed into the executer? I expect there won't be any considerable
performance penalty but just want to be completely sure.

---

## #34191 — Martin Alterisio — 2007-12-21T02:46:36+00:00

URL: https://externals.io/message/34164#34191 · In reply to: #34187

2007/12/20, Martin Alterisio <malterisio777@gmail.com>:
>
> 2007/12/20, Greg Beaver <cellog@php.net>:
> > […]
>
> Thank you. Sorry I didn't read your mail about this bug. I'll look into it
> a bit more and post a bug report.
>
> Have you seen my post scriptum in the first mail about benchmarks? Any
> idea of what I could use to test the performance of the unsolved name
> resolutions that are pushed into the executer? I expect there won't be any
> considerable performance penalty but just want to be completely sure.


Please, review the following patch against 5.3:

http://martinalterisio.com.ar/php5.3/use.function.patch

It should fix the use statement behavior so that aliases for namespaced
functions into global scope are recognized. The example code in the first
mail shouldn't fail and call test::foo(). I've tried some variations and run
the tests without finding any problem, but please check again if you can.

If nothing comes out, I'll post it in a bug report asap.

Best Regards,

Martin Alterisio
