Ai
5 Star 7 Fork 2

Gitee 极速下载/phpDocumentor2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/phpDocumentor/phpDocumentor2.git
克隆/下载
Version.php 1.71 KB
一键复制 编辑 原始数据 按行查看 历史
Jaapio 提交于 2024-12-21 04:53 +08:00 . Fix version display
<?php
declare(strict_types=1);
namespace phpDocumentor;
use Jean85\PrettyVersions;
use OutOfBoundsException;
use function explode;
use function file_get_contents;
use function ltrim;
use function sprintf;
use function strpos;
use function trim;
final class Version
{
private const VERSION = '@package_version@';
/** @var string */
private $version;
public function __construct()
{
$this->version = $this->detectVersion();
}
private function detectVersion(): string
{
$version = self::VERSION;
// prevent replacing the version by the PEAR building
if (sprintf('%s%s%s', '@', 'package_version', '@') === self::VERSION) {
$version = trim(file_get_contents(__DIR__ . '/../../VERSION'));
// @codeCoverageIgnoreStart
try {
$packageVersion = PrettyVersions::getRootPackageVersion();
if ($packageVersion->getPrettyVersion() === $version) {
return $version;
}
$version = sprintf(
'%s-%s+%s',
$version,
$packageVersion->getShortVersion(),
$packageVersion->getShortReference(),
);
} catch (OutOfBoundsException) {
}
// @codeCoverageIgnoreEnd
}
return $version;
}
public function getVersion(): string
{
return ltrim($this->version, 'v');
}
public function getExtensionVersion(): string
{
if (strpos($this->version, '-') !== false) {
$version = explode('-', $this->version)[0];
return $version . '-dev';
}
return $this->version;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/mirrors/phpDocumentor2.git
git@gitee.com:mirrors/phpDocumentor2.git
mirrors
phpDocumentor2
phpDocumentor2
master

搜索帮助