WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #14671, comment 27


Ignore:
Timestamp:
01/21/2013 10:27:41 AM (9 years ago)
Author:
SergeyBiryukov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #14671, comment 27

    initial v1  
    55
    661. For internal PHP functions, if you pass more arguments than the function is defined to take, it will issue a warning, for example: `PHP Warning:  strtoupper() expects exactly 1 parameter, 3 given`.
    7 2. For user-defined functions that have optional arguments, sometimes they are designed to behave differently when additional arguments are supplied. If the developer is not aware of a filter being supplied extra arguments, they may assume that any argument defaults they define in their function will be used, only to be surprised when any extra arguments for the filter get supplied the function's optional arguments. This is the point that jacobsantos makes above: http://core.trac.wordpress.org/ticket/14671?replyto=26#comment:7
     72. For user-defined functions that have optional arguments, sometimes they are designed to behave differently when additional arguments are supplied. If the developer is not aware of a filter being supplied extra arguments, they may assume that any argument defaults they define in their function will be used, only to be surprised when any extra arguments for the filter get supplied the function's optional arguments. This is the point that jacobsantos makes above: comment:7
    88
    99The 2nd point above would actually be a potential issue with my patch because it uses Reflection's `getNumberOfParameters` method instead of `getNumberOfRequiredParameters`. Perhaps the latter would be a more suitable default. In any case, if the default is not correct, the developer may supply the 4th argument.