original_string: public function listClasses($classType, $paths, $nameMethod = 'getName')
      {
          $results   = array();
          
          foreach ($paths as $prefix => $path) {
              $parts = explode('_', $prefix, 2);
              if ($name = reset($parts)) {
                  $name = ' (' . $name . ')';
              }
              
              try {
                  $globIter = new \GlobIterator($path . DIRECTORY_SEPARATOR . '*.php');
              } catch (\RuntimeException $e) {
                  // We skip invalid dirs
                  continue;
              }
              
              foreach($globIter as $fileinfo) {
                  $filename    = $fileinfo->getFilename();
                  $className   = $prefix . substr($filename, 0, -4);
                  $classNsName = '\\' . strtr($className, '_', '\\');
  
                  // Take care of double definitions
                  if (isset($results[$className])) {
                      continue;
                  }
                  
                  if (! (class_exists($className, false) || class_exists($classNsName, false))) {
                      include($path . DIRECTORY_SEPARATOR . $filename);
                  }
  
                  if ((! class_exists($className, false)) && class_exists($classNsName, false)) {
                      $className = $classNsName;
                  }
                  $class = new $className();
  
                  if ($class instanceof $classType) {
                      if ($class instanceof \MUtil_Registry_TargetInterface) {
                          $this->applySource($class);
                      }
  
                      $results[$className] = trim($class->$nameMethod()) . $name;
                  }
                  // \MUtil_Echo::track($eventName);
              }
              
          }
          natcasesort($results);
          return $results;
      }
code: public function listClasses($classType, $paths, $nameMethod = 'getName')
      {
          $results   = array();
          
          foreach ($paths as $prefix => $path) {
              $parts = explode('_', $prefix, 2);
              if ($name = reset($parts)) {
                  $name = ' (' . $name . ')';
              }
              
              try {
                  $globIter = new \GlobIterator($path . DIRECTORY_SEPARATOR . '*.php');
              } catch (\RuntimeException $e) {
                  // We skip invalid dirs
                  continue;
              }
              
              foreach($globIter as $fileinfo) {
                  $filename    = $fileinfo->getFilename();
                  $className   = $prefix . substr($filename, 0, -4);
                  $classNsName = '\\' . strtr($className, '_', '\\');
  
                  // Take care of double definitions
                  if (isset($results[$className])) {
                      continue;
                  }
                  
                  if (! (class_exists($className, false) || class_exists($classNsName, false))) {
                      include($path . DIRECTORY_SEPARATOR . $filename);
                  }
  
                  if ((! class_exists($className, false)) && class_exists($classNsName, false)) {
                      $className = $classNsName;
                  }
                  $class = new $className();
  
                  if ($class instanceof $classType) {
                      if ($class instanceof \MUtil_Registry_TargetInterface) {
                          $this->applySource($class);
                      }
  
                      $results[$className] = trim($class->$nameMethod()) . $name;
                  }
                  // \MUtil_Echo::track($eventName);
              }
              
          }
          natcasesort($results);
          return $results;
      }
code_tokens: public function listClasses ( $ classType , $ paths , $ nameMethod = 'getName' ) { $ results = array ( ) ; foreach ( $ paths as $ prefix => $ path ) { $ parts = explode ( '_' , $ prefix , 2 ) ; if ( $ name = reset ( $ parts ) ) { $ name = ' (' . $ name . ')' ; } try { $ globIter = new \ GlobIterator ( $ path . DIRECTORY_SEPARATOR . '*.php' ) ; } catch ( \ RuntimeException $ e ) { // We skip invalid dirs continue ; } foreach ( $ globIter as $ fileinfo ) { $ filename = $ fileinfo -> getFilename ( ) ; $ className = $ prefix . substr ( $ filename , 0 , - 4 ) ; $ classNsName = '\\' . strtr ( $ className , '_' , '\\' ) ; // Take care of double definitions if ( isset ( $ results [ $ className ] ) ) { continue ; } if ( ! ( class_exists ( $ className , false ) || class_exists ( $ classNsName , false ) ) ) { include ( $ path . DIRECTORY_SEPARATOR . $ filename ) ; } if ( ( ! class_exists ( $ className , false ) ) && class_exists ( $ classNsName , false ) ) { $ className = $ classNsName ; } $ class = new $ className ( ) ; if ( $ class instanceof $ classType ) { if ( $ class instanceof \ MUtil_Registry_TargetInterface ) { $ this -> applySource ( $ class ) ; } $ results [ $ className ] = trim ( $ class -> $ nameMethod ( ) ) . $ name ; } // \MUtil_Echo::track($eventName); } } natcasesort ( $ results ) ; return $ results ; }
docstring: Returns a list of selectable classes with an empty element as the first option.
  
  @param string $classType The class or interface that must me implemented
  @param array  $paths Array of prefix => path to search
  @param string $nameMEthod The method to call to get the name of the class
  @return [] array of classname => name
docstring_tokens: Returns a list of selectable classes with an empty element as the first option .