Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-7165

Codechecker complains about type-hinting in foreach loops

XMLWordPrintable

    • Hide

      Define a type for the array

      instead of:

      /** @var setting_dependency $dependency */
      foreach ($setting->get_dependencies() as $dependency)

      we can use

      /** @var setting_dependency[] $dependencies */
      $dependencies = $setting->get_dependencies();
      foreach ($dependencies as $dependency)

      not ideal but it works

      Show
      Define a type for the array instead of: /** @var setting_dependency $dependency */ foreach ($setting->get_dependencies() as $dependency) we can use /** @var setting_dependency[] $dependencies */ $dependencies = $setting->get_dependencies(); foreach ($dependencies as $dependency) not ideal but it works
    • MOODLE_34_STABLE
    • MOODLE_35_STABLE

      IMHO the following type-hint should be valid:

      /** @var classname $variable */
      foreach ($somearray as $variable)

      { // ... }

      but it gives error: Inline doc block type-hinting for '$variable'

            roperto Daniel Thee Roperto
            roperto Daniel Thee Roperto
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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