php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74253 Unqualified function name doesn't always get resolved correctly
Submitted: 2017-03-15 20:08 UTC Modified: 2017-03-15 20:17 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: losborn at jnrcorp dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 5.6.30 OS: Ubuntu 16.04.2 / macOS 10.12.3
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: losborn at jnrcorp dot com
New email:
PHP Version: OS:

 

 [2017-03-15 20:08 UTC] losborn at jnrcorp dot com
Description:
------------
Unqualified function calls are supposed to resolve to functions within their namespace if they exist. This doesn't always happen if the in-namespace function doesn't exist when the calling function is defined.

Seen issue on 5.6.28, 5.6.30, 7.1.2

More verbose example: https://paste.laravel.io/9qgML

Test script:
---------------
<?php
namespace NotGlobalNamespace;
eval('namespace F\\o\\o; function bar($marker) { echo "$marker => " . rand() . "\n"; }');
\F\o\o\bar(1);
eval('function bar($m) { return \F\o\o\bar($m); }');
bar(2);
eval('namespace F\\o\\o; function rand() { return "*** INTERCEPTED ***"; }');
\F\o\o\bar(3);
bar(4);
eval('namespace F\\o\\o; function baz($marker) { echo "$marker => " . rand() . "\n"; }');
\F\o\o\baz(5);
eval('function baz($m) { return \F\o\o\baz($m); }');
baz(6);
bar(7);

Expected result:
----------------
1 => 1059777682 (random)
2 => 1332050858 (random)
3 => *** INTERCEPTED ***
4 => *** INTERCEPTED ***
5 => *** INTERCEPTED ***
6 => *** INTERCEPTED ***
7 => *** INTERCEPTED ***


Actual result:
--------------
1 => 1059777682 (random)
2 => 1332050858 (random)
3 => 1123318855 (random)
4 => 1146230506 (random)
5 => *** INTERCEPTED ***
6 => *** INTERCEPTED ***
7 => 360960634 (random)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-15 20:17 UTC] requinix@php.net
-Status: Open +Status: Duplicate -Package: Testing related +Package: *General Issues
 [2017-03-15 20:17 UTC] requinix@php.net
Duplicate of bug #64346.
 [2017-03-15 20:23 UTC] losborn at jnrcorp dot com
Yes, I confirmed this is a duplicate bug #64346 ... It didn't come up in my searches. Thanks for finding it.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Apr 02 21:01:29 2025 UTC