Uploaded image for project: 'Moodle Community Sites'
  1. Moodle Community Sites
  2. MDLSITE-5972

Require type hints and return type declarations

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Done
    • Component/s: Coding style
    • Labels:
      None

      Description

      Policy: Type hints and return type declarations

      Since 10th Sep 2020, this rule applies:

      1. The uses of type hints and return type declarations is required in PHP in all possible locations for all new code.
      2. There will be necessary exclusions, such as code extending existing non-compliant code and implementing things where it is not available.
      3. It's NOT required to change all current old-style occurrences in the codebase. We'll follow a progressive approach here (new code and modified code)

       

      Type hints and return type declarations are available in all supported versions of PHP and we typically use them.

      This issue is about formalising the requirement of their use in all possible locations for all new code.

      To be clear, there will be necessary exclusions:

      1. code extending existing non-compliant code and implementing things where it is not available
      2. ... Hmm... maybe others too?

      Voting

      Option A
      • Require them for the new methods (except for the previous exclusions).
      Option B
      • Leave things as they are: use type hints and return type declarations is recommended, but still optional.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sarjona Sara Arjona (@sarjona)
              Reporter:
              dobedobedoh Andrew Nicols
              Participants:
              Component watchers:
              Marina Glancy, Eloy Lafuente (stronk7)
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: