php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69223 passing extra parameters in function/method call
Submitted: 2015-03-11 20:06 UTC Modified: 2017-08-05 04:52 UTC
From: php at w3x4 dot com Assigned:
Status: Suspended Package: Scripting Engine problem
PHP Version: 5.6.6 OS: W7 64
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-03-11 20:06 UTC] php at w3x4 dot com
Description:
------------
/* Using Visual Studio 2013 with Devsense PHP Tools, or
 * Using UEStudio 15:
 * 
 * 1) Set breakpoint on the 3 lines containing: $c=2
 * 
 * 2) Examine Locals window to confirm that $a does not appear when a static call or a function call passes more variables than the called method/function expects.
 * 
 * 3) Examine the error log to confirm that php does not throw an error or report a warning.
 * 
 * 4) Note that the existence of a reference to $a in Class Two results in $a being displayed in the Locals window.  Note also that removing '$b=1' will result in $a being displayed in Locals window.
 * 
 * I suggest that PHP should throw a fatal error when passing more parameters than the function/method expects; it seems some other (related) php problem is the cause of $a not being displayed in Locals window.
 * 
 * 
 * <SAA>
*/


Test script:
---------------
$xyz = new Class1;
class Class1 {
    public function __construct() { $this->_callHook(); }
	function _callHook(){
        $ret = One::f1('a');
        $ret = f1('b');
        $ret = Two::f1('a');
    }
}
class One{
    static function f1(){ $a=1; $b=1;
        $c=2;
    }
}
function f1(){ $a=1; $b=1;
        $c=2;
    }
class Two{
    static function f1(){ $a=1; $b=1;
        $c=2; echo $a;
    }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-11 20:09 UTC] aharvey@php.net
-Type: Bug +Type: Feature/Change Request -Package: Unknown/Other Function +Package: Scripting Engine problem
 [2015-03-11 20:09 UTC] aharvey@php.net
This is supported because PHP 5.5 and earlier used this for variadic functions, so at present this is expected behaviour.

There's an open RFC at present which would address this: https://wiki.php.net/rfc/strict_argcount. I'll move this to a feature request pending the outcome of that RFC.
 [2015-03-11 20:17 UTC] php at w3x4 dot com
Thanks- I'm in support of the RFC.

However, this still leaves the matter of why $a is not displayed during breakpoint.  As I think more about it, maybe that's an xdebug issue?
 [2015-03-11 20:20 UTC] aharvey@php.net
Yeah, that feels like an IDE and/or xdebug issue rather than a PHP one.
 [2017-08-05 04:52 UTC] stas@php.net
-Status: Open +Status: Suspended
 [2017-08-05 04:52 UTC] stas@php.net
Thank you for your interest in PHP and for submitting a feature request. Please be aware that due to the magnitude of change this request requires, it would be necessary to discuss it on PHP Internals list (internals@lists.php.net) as an RFC. Please read the guide about creating RFCs here:
https://wiki.php.net/rfc/howto
If you haven't had experience with writing RFCs before, it is advised to seek guidance on the Internals list (http://php.net/mailing-lists.php) and/or solicit help from one of the experienced developers. 

Please to not consider this comment as a negative view on the merits of your proposal - every proposal which requires changes of certain magnitude, even the very successful and widely supported ones, must be done through the RFC process. This helps make the process predictable, transparent and accessible to all developers.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 12:01:29 2024 UTC