original_string: public static function get_component_classes_in_namespace($component = null, $namespace = '') {
  
          $classes = array();
  
          // Only look for components if a component name is set or a namespace is set.
          if (isset($component) || !empty($namespace)) {
  
              // If a component parameter value is set we only want to look in that component.
              // Otherwise we want to check all components.
              $component = (isset($component)) ? self::normalize_componentname($component) : '\w+';
              if ($namespace) {
  
                  // We will add them later.
                  $namespace = trim($namespace, '\\');
  
                  // We need add double backslashes as it is how classes are stored into self::$classmap.
                  $namespace = implode('\\\\', explode('\\', $namespace));
                  $namespace = $namespace . '\\\\';
              }
              $regex = '|^' . $component . '\\\\' . $namespace . '|';
              $it = new RegexIterator(new ArrayIterator(self::$classmap), $regex, RegexIterator::GET_MATCH, RegexIterator::USE_KEY);
  
              // We want to be sure that they exist.
              foreach ($it as $classname => $classpath) {
                  if (class_exists($classname)) {
                      $classes[$classname] = $classpath;
                  }
              }
          }
  
          return $classes;
      }
code: public static function get_component_classes_in_namespace($component = null, $namespace = '') {
  
          $classes = array();
  
          // Only look for components if a component name is set or a namespace is set.
          if (isset($component) || !empty($namespace)) {
  
              // If a component parameter value is set we only want to look in that component.
              // Otherwise we want to check all components.
              $component = (isset($component)) ? self::normalize_componentname($component) : '\w+';
              if ($namespace) {
  
                  // We will add them later.
                  $namespace = trim($namespace, '\\');
  
                  // We need add double backslashes as it is how classes are stored into self::$classmap.
                  $namespace = implode('\\\\', explode('\\', $namespace));
                  $namespace = $namespace . '\\\\';
              }
              $regex = '|^' . $component . '\\\\' . $namespace . '|';
              $it = new RegexIterator(new ArrayIterator(self::$classmap), $regex, RegexIterator::GET_MATCH, RegexIterator::USE_KEY);
  
              // We want to be sure that they exist.
              foreach ($it as $classname => $classpath) {
                  if (class_exists($classname)) {
                      $classes[$classname] = $classpath;
                  }
              }
          }
  
          return $classes;
      }
code_tokens: public static function get_component_classes_in_namespace ( $ component = null , $ namespace = '' ) { $ classes = array ( ) ; // Only look for components if a component name is set or a namespace is set. if ( isset ( $ component ) || ! empty ( $ namespace ) ) { // If a component parameter value is set we only want to look in that component. // Otherwise we want to check all components. $ component = ( isset ( $ component ) ) ? self :: normalize_componentname ( $ component ) : '\w+' ; if ( $ namespace ) { // We will add them later. $ namespace = trim ( $ namespace , '\\' ) ; // We need add double backslashes as it is how classes are stored into self::$classmap. $ namespace = implode ( '\\\\' , explode ( '\\' , $ namespace ) ) ; $ namespace = $ namespace . '\\\\' ; } $ regex = '|^' . $ component . '\\\\' . $ namespace . '|' ; $ it = new RegexIterator ( new ArrayIterator ( self :: $ classmap ) , $ regex , RegexIterator :: GET_MATCH , RegexIterator :: USE_KEY ) ; // We want to be sure that they exist. foreach ( $ it as $ classname => $ classpath ) { if ( class_exists ( $ classname ) ) { $ classes [ $ classname ] = $ classpath ; } } } return $ classes ; }
docstring: Returns all classes in a component matching the provided namespace.
  
  It checks that the class exists.
  
  e.g. get_component_classes_in_namespace('mod_forum', 'event')
  
  @param string|null $component A valid moodle component (frankenstyle) or null if searching all components
  @param string $namespace Namespace from the component name or empty string if all $component classes.
  @return array The full class name as key and the class path as value, empty array if $component is `null`
  and $namespace is empty.
docstring_tokens: Returns all classes in a component matching the provided namespace .