php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75253 unable to call func_get_args() in a file required from within a function
Submitted: 2017-09-24 12:55 UTC Modified: 2017-09-24 17:12 UTC
From: Wes dot nospam at example dot org Assigned:
Status: Not a bug Package: *General Issues
PHP Version: Irrelevant OS:
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: Wes dot nospam at example dot org
New email:
PHP Version: OS:

 

 [2017-09-24 12:55 UTC] Wes dot nospam at example dot org
Description:
------------
This is disallowed: "called from the global scope"
but should be allowed.
the data is kind-of available anyway in debug_backtrace().

Test script:
---------------
file1.php:
<?php
function bar($a, $b, $c){ require("file2.php"); }
bar(1,2,3);

file2.php:
<?php
assert(func_get_args() === [1,2,3]); 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-09-24 17:12 UTC] jhdxr@php.net
-Status: Open +Status: Not a bug
 [2017-09-24 17:12 UTC] jhdxr@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Even if you can retrieve those info from `debug_backtrace()`, it doesn't prove this kind call of `func_get_args()` should be allow. Consider if it's allowed and  file1 is under namespace Foo, while file2 is non-namespaced. It will leads to an undefined behavior, see https://wiki.php.net/rfc/forbid_dynamic_scope_introspection for more info.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 03:01:33 2025 UTC