original_string: protected static function are_user_context_dependencies_expired(\context_user $context) : bool {
          // The context instanceid is the user's ID.
          if (isguestuser($context->instanceid) || is_siteadmin($context->instanceid)) {
              // This is an admin, or the guest and cannot expire.
              return false;
          }
  
          $courses = enrol_get_users_courses($context->instanceid, false, ['enddate']);
          $requireenddate = self::require_all_end_dates_for_user_deletion();
  
          $expired = true;
  
          foreach ($courses as $course) {
              if (empty($course->enddate)) {
                  // This course has no end date.
                  if ($requireenddate) {
                      // Course end dates are required, and this course has no end date.
                      $expired = false;
                      break;
                  }
  
                  // Course end dates are not required. The subsequent checks are pointless at this time so just
                  // skip them.
                  continue;
              }
  
              if ($course->enddate >= time()) {
                  // This course is still in the future.
                  $expired = false;
                  break;
              }
  
              // This course has an end date which is in the past.
              if (!self::is_course_expired($course)) {
                  // This course has not expired yet.
                  $expired = false;
                  break;
              }
          }
  
          return $expired;
      }
code: protected static function are_user_context_dependencies_expired(\context_user $context) : bool {
          // The context instanceid is the user's ID.
          if (isguestuser($context->instanceid) || is_siteadmin($context->instanceid)) {
              // This is an admin, or the guest and cannot expire.
              return false;
          }
  
          $courses = enrol_get_users_courses($context->instanceid, false, ['enddate']);
          $requireenddate = self::require_all_end_dates_for_user_deletion();
  
          $expired = true;
  
          foreach ($courses as $course) {
              if (empty($course->enddate)) {
                  // This course has no end date.
                  if ($requireenddate) {
                      // Course end dates are required, and this course has no end date.
                      $expired = false;
                      break;
                  }
  
                  // Course end dates are not required. The subsequent checks are pointless at this time so just
                  // skip them.
                  continue;
              }
  
              if ($course->enddate >= time()) {
                  // This course is still in the future.
                  $expired = false;
                  break;
              }
  
              // This course has an end date which is in the past.
              if (!self::is_course_expired($course)) {
                  // This course has not expired yet.
                  $expired = false;
                  break;
              }
          }
  
          return $expired;
      }
code_tokens: protected static function are_user_context_dependencies_expired ( \ context_user $ context ) : bool { // The context instanceid is the user's ID. if ( isguestuser ( $ context -> instanceid ) || is_siteadmin ( $ context -> instanceid ) ) { // This is an admin, or the guest and cannot expire. return false ; } $ courses = enrol_get_users_courses ( $ context -> instanceid , false , [ 'enddate' ] ) ; $ requireenddate = self :: require_all_end_dates_for_user_deletion ( ) ; $ expired = true ; foreach ( $ courses as $ course ) { if ( empty ( $ course -> enddate ) ) { // This course has no end date. if ( $ requireenddate ) { // Course end dates are required, and this course has no end date. $ expired = false ; break ; } // Course end dates are not required. The subsequent checks are pointless at this time so just // skip them. continue ; } if ( $ course -> enddate >= time ( ) ) { // This course is still in the future. $ expired = false ; break ; } // This course has an end date which is in the past. if ( ! self :: is_course_expired ( $ course ) ) { // This course has not expired yet. $ expired = false ; break ; } } return $ expired ; }
docstring: Determine whether the supplied user context's dependencies have expired.
  
  This checks whether courses have expired, and some other check, but does not check whether the user themself has expired.
  
  Although this seems unusual at first, each location calling this actually checks whether the user is elgible for
  deletion, irrespective if they have actually expired.
  
  For example, a request to delete the user only cares about course dependencies and the user's lack of expiry
  should not block their own request to be deleted; whilst the expiry eligibility check has already tested for the
  user being expired.
  
  @param   \context_user   $context
  @return  bool
docstring_tokens: Determine whether the supplied user context s dependencies have expired .