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

Use static for more specific return type in persistent

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.3
    • Fix Version/s: 3.8
    • Component/s: Documentation
    • Labels:

      Description

      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]);
      }
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                18/Nov/19

                Time Tracking

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