function VersionGuesser::guessVersion
@phpstan-return Version|null
Parameters
array<string, mixed> $packageConfig:
string $path Path to guess into:
File
-
vendor/
composer/ composer/ src/ Composer/ Package/ Version/ VersionGuesser.php, line 73
Class
- VersionGuesser
- Try to guess the current version number based on different VCS configuration.
Namespace
Composer\Package\VersionCode
public function guessVersion(array $packageConfig, string $path) : ?array {
if (!function_exists('proc_open')) {
return null;
}
// bypass version guessing in bash completions as it takes time to create
// new processes and the root version is usually not that important
if (Platform::isInputCompletionProcess()) {
return null;
}
$versionData = $this->guessGitVersion($packageConfig, $path);
if (null !== $versionData['version']) {
return $this->postprocess($versionData);
}
$versionData = $this->guessHgVersion($packageConfig, $path);
if (null !== $versionData && null !== $versionData['version']) {
return $this->postprocess($versionData);
}
$versionData = $this->guessFossilVersion($path);
if (null !== $versionData['version']) {
return $this->postprocess($versionData);
}
$versionData = $this->guessSvnVersion($packageConfig, $path);
if (null !== $versionData && null !== $versionData['version']) {
return $this->postprocess($versionData);
}
return null;
}