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

PHP 8.2: ${var} string interpolation deprecated

    XMLWordPrintable

Details

    • MOODLE_402_STABLE
    • MOODLE_402_STABLE
    • MDL-76415-master
    • Hide

       Run:

      composer require --dev php-parallel-lint/php-parallel-lint && \
      vendor/bin/parallel-lint --show-deprecated --exclude 'vendor' .
      

      Verify that the error warning Deprecated: Using ${var} in strings is deprecated, use {$var} instead in.... does not exist.

      Show
       Run: composer require --dev php-parallel-lint/php-parallel-lint && \ vendor/bin/parallel-lint --show-deprecated --exclude 'vendor' . Verify that the error warning Deprecated: Using ${var} in strings is deprecated, use {$var} instead in.... does not exist.
    • 2
    • Team Hedgehog Sprint 1 review, Team Hedgehog Sprint 2.1

    Description

      Supported string interpolations:

      $name = 'PHP';
      echo "Hello $name"; // Hello PHP
      echo "Hello {$name}"; // Hello PHP
      

      The following will no longer be supported:

      $name = 'PHP';
      $var = 'name';
      echo "Hello ${name}"; // Dollar outside of curly braces deprecated
      echo "Hello $$var"; // Variable variables deprecated
      echo "Hello ${$var}"; // Variable variables deprecated
      echo "Hello $$object->getMethod()"; // Variable expressions deprecated
      

      The following can be used instead:

      echo "Hello {$name}"; // Dollar moved inside the braces
      echo "Hello {$$var}"; // Variable variables can be used inside braces
      echo "Hello {${$object->getMethod()}}"; // Variable expressions can be used inside braces
      

      https://php.watch/versions/8.2/$%7Bvar%7D-string-interpolation-deprecated

      Note: This is the opposite of JavaScript.

      Attachments

        Issue Links

          Activity

            People

              meirza.arson@moodle.com Meirza
              dobedobedoh Andrew Lyons
              Raquel Ortega Raquel Ortega
              Andrew Lyons Andrew Lyons
              Andrew Lyons Andrew Lyons
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 days, 34 minutes
                  2d 34m

                  Clockify

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