private function getLatestDownloadUrl()
{
$version = $this->getApplication()->getVersion();
$changelogFile = __DIR__ . '/../../../CHANGELOG.md';
if (is_file($changelogFile)) {
$currentMajor = (int) $version;
$changelog = file_get_contents($changelogFile);
for ($i = $currentMajor; $i > 0; --$i) {
preg_match('/Changelog for v(' . $i . '.\\d+.\\d+)/', $changelog, $matches);
if (2 === count($matches)) {
$version = $matches[1];
break;
}
}
if (null === $version) {
throw new \RuntimeException('Invalid changelog data!');
}
}
return sprintf('https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v%s/php-cs-fixer.phar', $version);
}