Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-50260

Remove unnecessary check in optional_param()

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.0
    • Component/s: Other
    • Labels:

      Description

      function optional_param($parname, $default, $type) {
          if (func_num_args() != 3 or empty($parname) or empty($type)) {
              throw new coding_exception('optional_param requires $parname, $default + $type to be specified (parameter: '.$parname.')');
          }
          if (!isset($default)) {
              $default = null;
          }
      

      The check

          if (!isset($default)) {
      

      is not needed there, there is no way $default can be undefined since we check func_num_args() != 3 .

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tmuras Tomasz Muras
              Reporter:
              tmuras Tomasz Muras
              Peer reviewer:
              Ankit Agarwal
              Integrator:
              Dan Poltawski
              Tester:
              Dan Poltawski
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                16/Nov/15