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

Use static for more specific return type in persistent

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.8
    • 3.6.3
    • Documentation

      The methods in the persistent class that return an object of the class, or an array of them, should use "static" instead of "persistent" in the phpdoc return type. This will improve understanding of the code by IDEs and static analysis tools.

      In particular, code like this fails the "Incompatible return type" inspection in PhpStorm:

      /**
       * @return mypersistentclass[]
       */
      public static function get_records_for_user($userid) {
          return self::get_records(['userid' => $userid]);
      }
      

            maherne Michael Aherne
            maherne Michael Aherne
            Andrew Lyons Andrew Lyons
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Nobody Nobody (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 15 minutes
                15m

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