本文整理汇总了PHP中Version::normalize方法的典型用法代码示例。如果您正苦于以下问题:PHP Version::normalize方法的具体用法?PHP Version::normalize怎么用?PHP Version::normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Version
的用法示例。
在下文中一共展示了Version::normalize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* Collects versions.
*
* @return array[string]array
*/
private static function collect(\ICanBoogie\Core $core)
{
$versions = array();
$definitions = $core->registry->select('SUBSTR(name, LENGTH("thumbnailer.versions.") + 1) as name, value')->where('name LIKE ?', 'thumbnailer.versions.%')->pairs;
foreach ($definitions as $name => $options) {
if (!$options || !is_string($options) || $options[0] != '{') {
\ICanBoogie\log_error('Bad version: %name, :options', array('name' => $name, 'options' => $options));
continue;
}
$versions[$name] = Version::normalize(json_decode($options, true));
}
return $versions;
}
示例2: getOutdatedPackages
/**
* Get outdated packages with their current and latest version.
*
* @return array
*/
public function getOutdatedPackages()
{
// Get all installed and required packages.
$installed = $this->composer->getInstalledPackages();
$required = $this->composer->getRequiredPackages();
$outdated = [];
// Get the installed version number of the required packages.
$packages = array_intersect_key($installed, $required);
foreach ($packages as $name => $version) {
$package = new Package($name, Version::normalize($version), $required[$name]);
if ($package->isOutdated()) {
$outdated[] = $package;
}
}
return $outdated;
}
示例3: getOutdatedPackages
/**
* Get outdated packages with their current and latest version.
*
* @param array $excluded
*
* @return array
*/
public function getOutdatedPackages(array $excluded = [])
{
// Get all installed and required packages.
$installed = $this->composer->getInstalledPackages();
$required = $this->composer->getRequiredPackages();
$outdated = [];
// Get the installed version number of the required packages.
$packages = array_intersect_key($installed, $required);
foreach ($packages as $package) {
$name = $package['name'];
$version = Version::normalize($package['version']);
$prettyVersion = $required[$name]['version'];
$devDependency = $package['devDependency'];
if (in_array($name, $excluded)) {
continue;
}
$package = new Package($name, $version, $prettyVersion, $devDependency);
if ($package->isOutdated()) {
$outdated[] = $package;
}
}
return $outdated;
}
示例4: normalize
/**
* Normalizes a version string to the number of components given in the
* parameter $precision.
*
* A single digit release version and a single digit major version are
* contracted to a two digit release version. If no major version is given,
* it is substituted by zero.
*
* Examples:
*
* IcuVersion::normalize('1.2.3.4');
* // => '12.3.4'
*
* IcuVersion::normalize('1.2.3.4', 1);
* // => '12'
*
* IcuVersion::normalize('1.2.3.4', 2);
* // => '12.3'
*
* @param string $version An ICU version string
* @param int|null $precision The number of components to include. Pass
* NULL to return the version unchanged.
*
* @return string|null The normalized ICU version or NULL if it couldn't be
* normalized.
*/
public static function normalize($version, $precision)
{
$version = preg_replace('/^(\\d)\\.(\\d)/', '$1$2', $version);
if (1 === strlen($version)) {
$version .= '0';
}
return Version::normalize($version, $precision);
}