php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #53399
Patch strict-required-opt2.patch revision 2010-11-25 01:27 UTC by jbafford at zort dot net
Patch strict-required-opt.patch revision 2010-11-24 15:27 UTC by jbafford at zort dot net

Patch strict-required-opt.patch for Scripting Engine problem Bug #53399

Patch version 2010-11-24 15:27 UTC

Return to Bug #53399 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions:

Developer: jbafford@zort.net

Index: Zend/zend_compile.c
===================================================================
--- Zend/zend_compile.c	(revision 305718)
+++ Zend/zend_compile.c	(working copy)
@@ -1504,6 +1504,10 @@
 	if (op == ZEND_RECV_INIT) {
 		opline->op2 = *initialization;
 	} else {
+		if(CG(active_op_array)->required_num_args != CG(active_op_array)->num_args - 1) {
+			zend_error(E_STRICT, "Declaration of required function parameter after optional parameter");
+		}
+		
 		CG(active_op_array)->required_num_args = CG(active_op_array)->num_args;
 		SET_UNUSED(opline->op2);
 	}
Index: Zend/tests/func_optarg1.phpt
===================================================================
--- Zend/tests/func_optarg1.phpt	(revision 0)
+++ Zend/tests/func_optarg1.phpt	(revision 0)
@@ -0,0 +1,14 @@
+--TEST--
+Declaration of required function parameter after optional parameter E_STRICT warning
+--CREDITS--
+John Bafford
+http://bafford.com
+--INI--
+error_reporting=E_STRICT
+--FILE--
+<?php
+function foo($bar, $baz = true, $quux)
+{
+}
+--EXPECTF--
+Strict Standards: Declaration of required function parameter after optional parameter in %s on line %d
Index: Zend/tests/func_optarg2.phpt
===================================================================
--- Zend/tests/func_optarg2.phpt	(revision 0)
+++ Zend/tests/func_optarg2.phpt	(revision 0)
@@ -0,0 +1,13 @@
+--TEST--
+Declaration of required function parameter after optional parameter E_STRICT warning (E_STRICT disabled)
+--CREDITS--
+John Bafford
+http://bafford.com
+--INI--
+error_reporting=E_ALL
+--FILE--
+<?php
+function foo($bar, $baz = true, $quux)
+{
+}
+--EXPECT--
Index: Zend/tests/call_user_func_005.phpt
===================================================================
--- Zend/tests/call_user_func_005.phpt	(revision 305718)
+++ Zend/tests/call_user_func_005.phpt	(working copy)
@@ -10,7 +10,7 @@
 	}
 	
 	public function teste() {
-		return foo::x(function &($a=1,$b) { });
+		return foo::x(function &($a,$b) { });
 	}
 }
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 03:01:27 2024 UTC