original_string: public static function unpack_reference($str, $cleanparams = false) {
          $decoded = base64_decode($str, true);
          if ($decoded === false) {
              throw new file_reference_exception(null, $str, null, null, 'Invalid base64 format');
          }
          $params = @unserialize($decoded); // hide E_NOTICE
          if ($params === false) {
              throw new file_reference_exception(null, $decoded, null, null, 'Not an unserializeable value');
          }
          if (is_array($params) && $cleanparams) {
              $params = array(
                  'component' => is_null($params['component']) ? ''   : clean_param($params['component'], PARAM_COMPONENT),
                  'filearea'  => is_null($params['filearea'])  ? ''   : clean_param($params['filearea'], PARAM_AREA),
                  'itemid'    => is_null($params['itemid'])    ? 0    : clean_param($params['itemid'], PARAM_INT),
                  'filename'  => is_null($params['filename'])  ? null : clean_param($params['filename'], PARAM_FILE),
                  'filepath'  => is_null($params['filepath'])  ? null : clean_param($params['filepath'], PARAM_PATH),
                  'contextid' => is_null($params['contextid']) ? null : clean_param($params['contextid'], PARAM_INT)
              );
          }
          return $params;
      }
code: public static function unpack_reference($str, $cleanparams = false) {
          $decoded = base64_decode($str, true);
          if ($decoded === false) {
              throw new file_reference_exception(null, $str, null, null, 'Invalid base64 format');
          }
          $params = @unserialize($decoded); // hide E_NOTICE
          if ($params === false) {
              throw new file_reference_exception(null, $decoded, null, null, 'Not an unserializeable value');
          }
          if (is_array($params) && $cleanparams) {
              $params = array(
                  'component' => is_null($params['component']) ? ''   : clean_param($params['component'], PARAM_COMPONENT),
                  'filearea'  => is_null($params['filearea'])  ? ''   : clean_param($params['filearea'], PARAM_AREA),
                  'itemid'    => is_null($params['itemid'])    ? 0    : clean_param($params['itemid'], PARAM_INT),
                  'filename'  => is_null($params['filename'])  ? null : clean_param($params['filename'], PARAM_FILE),
                  'filepath'  => is_null($params['filepath'])  ? null : clean_param($params['filepath'], PARAM_PATH),
                  'contextid' => is_null($params['contextid']) ? null : clean_param($params['contextid'], PARAM_INT)
              );
          }
          return $params;
      }
code_tokens: public static function unpack_reference ( $ str , $ cleanparams = false ) { $ decoded = base64_decode ( $ str , true ) ; if ( $ decoded === false ) { throw new file_reference_exception ( null , $ str , null , null , 'Invalid base64 format' ) ; } $ params = @ unserialize ( $ decoded ) ; // hide E_NOTICE if ( $ params === false ) { throw new file_reference_exception ( null , $ decoded , null , null , 'Not an unserializeable value' ) ; } if ( is_array ( $ params ) && $ cleanparams ) { $ params = array ( 'component' => is_null ( $ params [ 'component' ] ) ? '' : clean_param ( $ params [ 'component' ] , PARAM_COMPONENT ) , 'filearea' => is_null ( $ params [ 'filearea' ] ) ? '' : clean_param ( $ params [ 'filearea' ] , PARAM_AREA ) , 'itemid' => is_null ( $ params [ 'itemid' ] ) ? 0 : clean_param ( $ params [ 'itemid' ] , PARAM_INT ) , 'filename' => is_null ( $ params [ 'filename' ] ) ? null : clean_param ( $ params [ 'filename' ] , PARAM_FILE ) , 'filepath' => is_null ( $ params [ 'filepath' ] ) ? null : clean_param ( $ params [ 'filepath' ] , PARAM_PATH ) , 'contextid' => is_null ( $ params [ 'contextid' ] ) ? null : clean_param ( $ params [ 'contextid' ] , PARAM_INT ) ) ; } return $ params ; }
docstring: Unpack reference field
  
  @param string $str
  @param bool $cleanparams if set to true, array elements will be passed through {@link clean_param()}
  @throws file_reference_exception if the $str does not have the expected format
  @return array
docstring_tokens: Unpack reference field