original_string: public function findBestCandidate($packageName, $targetPackageVersion = null)
      {
          $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
          $candidates = $this->pool->whatProvides(strtolower($packageName), $constraint, true);
  
          if (!$candidates) {
              return false;
          }
  
          // select highest version if we have many
          $package = reset($candidates);
          foreach ($candidates as $candidate) {
              if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
                  $package = $candidate;
              }
          }
  
          return $package;
      }
code: public function findBestCandidate($packageName, $targetPackageVersion = null)
      {
          $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
          $candidates = $this->pool->whatProvides(strtolower($packageName), $constraint, true);
  
          if (!$candidates) {
              return false;
          }
  
          // select highest version if we have many
          $package = reset($candidates);
          foreach ($candidates as $candidate) {
              if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
                  $package = $candidate;
              }
          }
  
          return $package;
      }
code_tokens: public function findBestCandidate ( $ packageName , $ targetPackageVersion = null ) { $ constraint = $ targetPackageVersion ? $ this -> getParser ( ) -> parseConstraints ( $ targetPackageVersion ) : null ; $ candidates = $ this -> pool -> whatProvides ( strtolower ( $ packageName ) , $ constraint , true ) ; if ( ! $ candidates ) { return false ; } // select highest version if we have many $ package = reset ( $ candidates ) ; foreach ( $ candidates as $ candidate ) { if ( version_compare ( $ package -> getVersion ( ) , $ candidate -> getVersion ( ) , '<' ) ) { $ package = $ candidate ; } } return $ package ; }
docstring: Given a package name and optional version, returns the latest PackageInterface
  that matches.
  
  @param  string                $packageName
  @param  string                $targetPackageVersion
  @return PackageInterface|bool
docstring_tokens: Given a package name and optional version returns the latest PackageInterface that matches .