original_string: protected function detectMetadataDriver($dir, ContainerBuilder $container)
      {
          $configPath = $this->getMappingResourceConfigDirectory();
          $extension = $this->getMappingResourceExtension();
  
          if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) {
              $driver = 'xml';
          } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) {
              $driver = 'yml';
          } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) {
              $driver = 'php';
          } else {
              // add the closest existing directory as a resource
              $resource = $dir.'/'.$configPath;
              while (!is_dir($resource)) {
                  $resource = \dirname($resource);
              }
              $container->fileExists($resource, false);
  
              return $container->fileExists($dir.'/'.$this->getMappingObjectDefaultName(), false) ? 'annotation' : null;
          }
          $container->fileExists($dir.'/'.$configPath, false);
  
          return $driver;
      }
code: protected function detectMetadataDriver($dir, ContainerBuilder $container)
      {
          $configPath = $this->getMappingResourceConfigDirectory();
          $extension = $this->getMappingResourceExtension();
  
          if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) {
              $driver = 'xml';
          } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) {
              $driver = 'yml';
          } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) {
              $driver = 'php';
          } else {
              // add the closest existing directory as a resource
              $resource = $dir.'/'.$configPath;
              while (!is_dir($resource)) {
                  $resource = \dirname($resource);
              }
              $container->fileExists($resource, false);
  
              return $container->fileExists($dir.'/'.$this->getMappingObjectDefaultName(), false) ? 'annotation' : null;
          }
          $container->fileExists($dir.'/'.$configPath, false);
  
          return $driver;
      }
code_tokens: protected function detectMetadataDriver ( $ dir , ContainerBuilder $ container ) { $ configPath = $ this -> getMappingResourceConfigDirectory ( ) ; $ extension = $ this -> getMappingResourceExtension ( ) ; if ( glob ( $ dir . '/' . $ configPath . '/*.' . $ extension . '.xml' ) ) { $ driver = 'xml' ; } elseif ( glob ( $ dir . '/' . $ configPath . '/*.' . $ extension . '.yml' ) ) { $ driver = 'yml' ; } elseif ( glob ( $ dir . '/' . $ configPath . '/*.' . $ extension . '.php' ) ) { $ driver = 'php' ; } else { // add the closest existing directory as a resource $ resource = $ dir . '/' . $ configPath ; while ( ! is_dir ( $ resource ) ) { $ resource = \ dirname ( $ resource ) ; } $ container -> fileExists ( $ resource , false ) ; return $ container -> fileExists ( $ dir . '/' . $ this -> getMappingObjectDefaultName ( ) , false ) ? 'annotation' : null ; } $ container -> fileExists ( $ dir . '/' . $ configPath , false ) ; return $ driver ; }
docstring: Detects what metadata driver to use for the supplied directory.
  
  @param string           $dir       A directory path
  @param ContainerBuilder $container A ContainerBuilder instance
  
  @return string|null A metadata driver short name, if one can be detected
docstring_tokens: Detects what metadata driver to use for the supplied directory .