original_string: public function validate_pluginfo_format($data) {
  
          if (empty($data) or !is_object($data)) {
              return false;
          }
  
          $output = new remote_info();
  
          $rootproperties = array('id' => 1, 'name' => 1, 'component' => 1, 'source' => 0, 'doc' => 0,
              'bugs' => 0, 'discussion' => 0, 'version' => 0);
          foreach ($rootproperties as $property => $required) {
              if (!property_exists($data, $property)) {
                  return false;
              }
              if ($required and empty($data->$property)) {
                  return false;
              }
              $output->$property = $data->$property;
          }
  
          if (!empty($data->version)) {
              if (!is_object($data->version)) {
                  return false;
              }
              $versionproperties = array('id' => 1, 'version' => 1, 'release' => 0, 'maturity' => 0,
                  'downloadurl' => 1, 'downloadmd5' => 1, 'vcssystem' => 0, 'vcssystemother' => 0,
                  'vcsrepositoryurl' => 0, 'vcsbranch' => 0, 'vcstag' => 0, 'supportedmoodles' => 0);
              foreach ($versionproperties as $property => $required) {
                  if (!property_exists($data->version, $property)) {
                      return false;
                  }
                  if ($required and empty($data->version->$property)) {
                      return false;
                  }
              }
              if (!preg_match('|^https?://|i', $data->version->downloadurl)) {
                  return false;
              }
  
              if (!empty($data->version->supportedmoodles)) {
                  if (!is_array($data->version->supportedmoodles)) {
                      return false;
                  }
                  foreach ($data->version->supportedmoodles as $supportedmoodle) {
                      if (!is_object($supportedmoodle)) {
                          return false;
                      }
                      if (empty($supportedmoodle->version) or empty($supportedmoodle->release)) {
                          return false;
                      }
                  }
              }
          }
  
          return $output;
      }
code: public function validate_pluginfo_format($data) {
  
          if (empty($data) or !is_object($data)) {
              return false;
          }
  
          $output = new remote_info();
  
          $rootproperties = array('id' => 1, 'name' => 1, 'component' => 1, 'source' => 0, 'doc' => 0,
              'bugs' => 0, 'discussion' => 0, 'version' => 0);
          foreach ($rootproperties as $property => $required) {
              if (!property_exists($data, $property)) {
                  return false;
              }
              if ($required and empty($data->$property)) {
                  return false;
              }
              $output->$property = $data->$property;
          }
  
          if (!empty($data->version)) {
              if (!is_object($data->version)) {
                  return false;
              }
              $versionproperties = array('id' => 1, 'version' => 1, 'release' => 0, 'maturity' => 0,
                  'downloadurl' => 1, 'downloadmd5' => 1, 'vcssystem' => 0, 'vcssystemother' => 0,
                  'vcsrepositoryurl' => 0, 'vcsbranch' => 0, 'vcstag' => 0, 'supportedmoodles' => 0);
              foreach ($versionproperties as $property => $required) {
                  if (!property_exists($data->version, $property)) {
                      return false;
                  }
                  if ($required and empty($data->version->$property)) {
                      return false;
                  }
              }
              if (!preg_match('|^https?://|i', $data->version->downloadurl)) {
                  return false;
              }
  
              if (!empty($data->version->supportedmoodles)) {
                  if (!is_array($data->version->supportedmoodles)) {
                      return false;
                  }
                  foreach ($data->version->supportedmoodles as $supportedmoodle) {
                      if (!is_object($supportedmoodle)) {
                          return false;
                      }
                      if (empty($supportedmoodle->version) or empty($supportedmoodle->release)) {
                          return false;
                      }
                  }
              }
          }
  
          return $output;
      }
code_tokens: public function validate_pluginfo_format ( $ data ) { if ( empty ( $ data ) or ! is_object ( $ data ) ) { return false ; } $ output = new remote_info ( ) ; $ rootproperties = array ( 'id' => 1 , 'name' => 1 , 'component' => 1 , 'source' => 0 , 'doc' => 0 , 'bugs' => 0 , 'discussion' => 0 , 'version' => 0 ) ; foreach ( $ rootproperties as $ property => $ required ) { if ( ! property_exists ( $ data , $ property ) ) { return false ; } if ( $ required and empty ( $ data -> $ property ) ) { return false ; } $ output -> $ property = $ data -> $ property ; } if ( ! empty ( $ data -> version ) ) { if ( ! is_object ( $ data -> version ) ) { return false ; } $ versionproperties = array ( 'id' => 1 , 'version' => 1 , 'release' => 0 , 'maturity' => 0 , 'downloadurl' => 1 , 'downloadmd5' => 1 , 'vcssystem' => 0 , 'vcssystemother' => 0 , 'vcsrepositoryurl' => 0 , 'vcsbranch' => 0 , 'vcstag' => 0 , 'supportedmoodles' => 0 ) ; foreach ( $ versionproperties as $ property => $ required ) { if ( ! property_exists ( $ data -> version , $ property ) ) { return false ; } if ( $ required and empty ( $ data -> version -> $ property ) ) { return false ; } } if ( ! preg_match ( '|^https?://|i' , $ data -> version -> downloadurl ) ) { return false ; } if ( ! empty ( $ data -> version -> supportedmoodles ) ) { if ( ! is_array ( $ data -> version -> supportedmoodles ) ) { return false ; } foreach ( $ data -> version -> supportedmoodles as $ supportedmoodle ) { if ( ! is_object ( $ supportedmoodle ) ) { return false ; } if ( empty ( $ supportedmoodle -> version ) or empty ( $ supportedmoodle -> release ) ) { return false ; } } } } return $ output ; }
docstring: Makes sure the given data format match the expected output of the pluginfo service.
  
  Object validated by this method is guaranteed to contain all the data
  provided by the pluginfo.php version this client works with (self::APIVER).
  
  @param stdClass $data
  @return \core\update\remote_info|bool false if data are not valid, original data otherwise
docstring_tokens: Makes sure the given data format match the expected output of the pluginfo service .