rfc:too_few_args

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:too_few_args [2016/06/01 10:50] dmitryrfc:too_few_args [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 3: Line 3:
   * Date: 2016-06-01   * Date: 2016-06-01
   * Author: Dmitry Stogov, dmitry@zend.com   * Author: Dmitry Stogov, dmitry@zend.com
-  * Status: Under Discussion+  * Status: Accepted
   * First Published at: https://wiki.php.net/rfc/too_few_args   * First Published at: https://wiki.php.net/rfc/too_few_args
  
 ===== Introduction ===== ===== Introduction =====
-Historically, PHP allows calling functions with fewer actual parameters when required by function definition. These "non-passed" arguments lead to warning emission and continuation of function execution with uninitialized arguments.+Historically, PHP allows calling functions with fewer actual parameters than required by the function definition. These "non-passed" arguments lead to warning emission and continuation of function execution with uninitialized arguments.
  
 <code php> <code php>
 function foo($a) { function foo($a) {
-   var_dump($a);   // NULL + Warning: Undefind variable: a  +   var_dump($a);   // NULL + Warning: Undefined variable: a  
-   var_dump($a);   // NULL + Warning: Undefind variable: a+   var_dump($a);   // NULL + Warning: Undefined variable: a
 } }
 foo();             // Warning: Missing argument 1 for foo() foo();             // Warning: Missing argument 1 for foo()
Line 21: Line 21:
   * doesn't have real use cases (in any case, foo($a = null) is better)   * doesn't have real use cases (in any case, foo($a = null) is better)
   * may lead to warning bloating   * may lead to warning bloating
-  * disables obvious optimisation opportunists+  * disables obvious optimization opportunities
  
 ===== Proposal ===== ===== Proposal =====
-I propose to disable calling functions with insufficient actual parameters. PHP will throw "Error" exception insted.+I propose to disable calling "user" functions with insufficient actual parameters. PHP will throw an "Error" exception instead.
  
 <code php> <code php>
Line 34: Line 34:
 </code> </code>
  
-Using this approach, all attempts to call function with unexpected input data are going to be caught in first place.+Using this approach, all attempts to call functions with unexpected input data are going to be caught as soon as possible. 
 + 
 +Behavior of internal functions is not going to be changed.
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 43: Line 45:
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
-The vote is a straight Yes/No vote, that requires a 2/3 majority. +The vote is a straight Yes/No vote, that requires a 2/3 majority. 
 +The voting began on Jun 6 and will close on Jun 16. 
 +<doodle title="Replace "Missing argument" warning with "Too few arguments" exception?" auth="dmitry" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle> 
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
Line 51: Line 58:
 After the project is implemented, this section should contain  After the project is implemented, this section should contain 
   - the version(s) it was merged to   - the version(s) it was merged to
-  - a link to the git commit(s)+  - a link to the git commit [[http://git.php.net/?p=php-src.git;a=commitdiff;h=ff363e2e7c58353b7e2751d1ca4d7bf616862aae|ff363e2e7c58353b7e2751d1ca4d7bf616862aae]]
   - a link to the PHP manual entry for the feature   - a link to the PHP manual entry for the feature
  
rfc/too_few_args.1464778215.txt.gz · Last modified: 2017/09/22 13:28 (external edit)