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

Remove unnecessary check in optional_param()

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.0
    • 3.0
    • Other

      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 .

            tmuras Tomasz Muras
            tmuras Tomasz Muras
            Ankit Agarwal Ankit Agarwal
            Dan Poltawski Dan Poltawski
            Dan Poltawski Dan Poltawski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.