Jelix 1.6.39

VersionComparator
in package

class to compare version numbers. it supports the following keywords: "pre", "-dev", "b", "beta", "a", "alpha".

It supports also the "*" wilcard. This wilcard must be the last part of the version number.

Table of Contents

compare()  : int
Compare two version objects.
compareVersion()  : int
Compare two version as string.
compareVersionRange()  : bool
serializeVersion()  : mixed
create a string representing a version number in a manner that it could be easily to be compared with an other serialized version. useful to do comparison in a database for example.
serializeVersion2()  : mixed
create a string representing a version number in a manner that it could be easily to be compared with an other serialized version. useful to do comparison in a database for example.
compileRange()  : VersionRangeOperatorInterface
normalizeVersionNumber()  : mixed

Methods

compare()

Compare two version objects.

public static compare(Version $version1, Version $version2) : int
Parameters
$version1 : Version
$version2 : Version
Return values
int
  • 0 if versions are equals
  • -1 if $version1 is lower than $version2
  • 1 if $version1 is higher than $version2

compareVersion()

Compare two version as string.

public static compareVersion(string $version1, string $version2) : int

It supports wildcard in one of the version

Parameters
$version1 : string
$version2 : string
Return values
int

0 if equal, -1 if $version1 < $version2, 1 if $version1 > $version2

compareVersionRange()

public static compareVersionRange(string $version, string $range) : bool
Parameters
$version : string

a version number

$range : string

a version expression respecting Composer range syntax

Return values
bool

true if the given version match the given range

serializeVersion()

create a string representing a version number in a manner that it could be easily to be compared with an other serialized version. useful to do comparison in a database for example.

public static serializeVersion(mixed $version, int $starReplacement[, mixed $pad = 4 ]) : mixed

It doesn't support all version notation. Use serializeVersion2 instead.

Parameters
$version : mixed
$starReplacement : int

1 if it should replace by max value, 0 for min value

$pad : mixed = 4
Tags
deprecated
Return values
mixed

serializeVersion2()

create a string representing a version number in a manner that it could be easily to be compared with an other serialized version. useful to do comparison in a database for example.

public static serializeVersion2(mixed $version, int $starReplacement[, mixed $maxpad = 10 ]) : mixed
Parameters
$version : mixed
$starReplacement : int

1 if it should replace '*' by max value, 0 for min value

$maxpad : mixed = 10
Return values
mixed

normalizeVersionNumber()

protected static normalizeVersionNumber(mixed &$n) : mixed
Parameters
$n : mixed
Return values
mixed

Search results