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

PHP 8.3: Dynamic class constant and Enum member fetch support

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor Minor
    • None
    • 4.4
    • General

      https://php.watch/versions/8.3/dynamic-class-const-enum-member-syntax-support

      PHP 8.3 and later supports fetching class constants and Enum objects with a variable name.

      class MyClass

      { public const MY_CONST = 42; }

      $constName = 'MY_CONST';

      echo MyClass::{$constName};
      Prior to PHP 8.3, the ClassName::{$varName} syntax of accessing class constants was not allowed, and resulted in a syntax error:

      Parse error: syntax error, unexpected token ";", expecting "(" in ... on line ...

      Required

      1. Confirm my assessment that no change is required

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Raquel Ortega Raquel Ortega
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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