original_string: protected static function discoverExtensionComponentDirectory($directory)
      {
          $components        = [];
          $directoryIterator = new \RecursiveDirectoryIterator($directory);
          $recursiveIterator = new \RecursiveIteratorIterator($directoryIterator);
          $regexIterator     = new \RegexIterator(
              $recursiveIterator,
              PATH_SEPARATOR.'^'.preg_quote($directory.DIRECTORY_SEPARATOR).'.+Component\.php$'.PATH_SEPARATOR,
              \RecursiveRegexIterator::GET_MATCH
          );
  
          // Run through all potential component files
          foreach ($regexIterator as $component) {
              // Run through all classes declared in the file
              foreach (self::discoverClassesInFile(file_get_contents($component[0])) as $className) {
                  // Test if this is a component class
                  $classReflection = new \ReflectionClass($className);
                  if ($classReflection->implementsInterface(ComponentInterface::class)) {
                      $components[] = self::addLocalConfiguration($component[0], self::discoverComponent($className));
                  }
              }
          }
  
          return $components;
      }
code: protected static function discoverExtensionComponentDirectory($directory)
      {
          $components        = [];
          $directoryIterator = new \RecursiveDirectoryIterator($directory);
          $recursiveIterator = new \RecursiveIteratorIterator($directoryIterator);
          $regexIterator     = new \RegexIterator(
              $recursiveIterator,
              PATH_SEPARATOR.'^'.preg_quote($directory.DIRECTORY_SEPARATOR).'.+Component\.php$'.PATH_SEPARATOR,
              \RecursiveRegexIterator::GET_MATCH
          );
  
          // Run through all potential component files
          foreach ($regexIterator as $component) {
              // Run through all classes declared in the file
              foreach (self::discoverClassesInFile(file_get_contents($component[0])) as $className) {
                  // Test if this is a component class
                  $classReflection = new \ReflectionClass($className);
                  if ($classReflection->implementsInterface(ComponentInterface::class)) {
                      $components[] = self::addLocalConfiguration($component[0], self::discoverComponent($className));
                  }
              }
          }
  
          return $components;
      }
code_tokens: protected static function discoverExtensionComponentDirectory ( $ directory ) { $ components = [ ] ; $ directoryIterator = new \ RecursiveDirectoryIterator ( $ directory ) ; $ recursiveIterator = new \ RecursiveIteratorIterator ( $ directoryIterator ) ; $ regexIterator = new \ RegexIterator ( $ recursiveIterator , PATH_SEPARATOR . '^' . preg_quote ( $ directory . DIRECTORY_SEPARATOR ) . '.+Component\.php$' . PATH_SEPARATOR , \ RecursiveRegexIterator :: GET_MATCH ) ; // Run through all potential component files foreach ( $ regexIterator as $ component ) { // Run through all classes declared in the file foreach ( self :: discoverClassesInFile ( file_get_contents ( $ component [ 0 ] ) ) as $ className ) { // Test if this is a component class $ classReflection = new \ ReflectionClass ( $ className ) ; if ( $ classReflection -> implementsInterface ( ComponentInterface :: class ) ) { $ components [ ] = self :: addLocalConfiguration ( $ component [ 0 ] , self :: discoverComponent ( $ className ) ) ; } } } return $ components ; }
docstring: Recursively scan a directory for components and return a component list
  
  @param string $directory Directory path
  
  @return array Components
docstring_tokens: Recursively scan a directory for components and return a component list