final class ServerVersion
Public API: explicitly declared with @visibility public.

A supported database release, named by the version tag the sql-* packages share.

Resolve the default release of a dialectdoctest
\SqlFixture\Version\ServerVersion::resolve('mysql')->tag // => 'mysql-8.4.7'
Match the release a server reportsdoctest
\SqlFixture\Version\ServerVersion::fromServer('mysql', '8.0.36-0ubuntu0.22.04.1')->tag // => 'mysql-8.0.44'

Properties§

public string $dialect
public string $tag
public string $number

Methods§

public function __construct(public string $dialect, public string $tag, public string $number)

Parameters

$dialectstringDialect the release belongs to: `mysql`, `pgsql` or `sqlite`
$tagstringVersion tag such as `mysql-8.4.7`
$numberstringRelease number such as `8.4.7`
public static function fromServer(string $dialect, string $reported): self

Matches the release closest to the version a server reports.

The release of the same series wins, where the series is every number but the last (8.0 for MySQL 8.0.36, 17 for PostgreSQL 17.2). Otherwise the newest release that is not newer than the server wins, and a server older than every release gets the oldest one.

Parameters

$dialectstringDialect of the server
$reportedstringVersion string of the server, such as `8.0.36-0ubuntu0.22.04.1`

Returns

self

Throws

UnsupportedVersionException When the dialect has no releases or the string holds no version number
Test cases 2
Called from 1
Calls 7
public static function all(string $dialect): non-empty-list<self>

Lists the releases of a dialect, oldest first.

Parameters

$dialectstring

Returns

non-empty-list<self>

Throws

UnsupportedVersionException When the dialect has no releases
Test cases 2
Called from 1
Calls 3
public static function tags(string $dialect): non-empty-list<string>

Lists the version tags of a dialect, oldest first.

Parameters

$dialectstring

Returns

non-empty-list<string>

Throws

UnsupportedVersionException When the dialect has no releases
Test cases 1
Called from 1
Calls 3
public function isDefault(): bool

Reports whether this is the default release of its dialect.

Returns

bool
Test cases 1
Calls 2
public function id(): int

Numbers the release as MySQL numbers its own, as in MYSQL_VERSION_ID.

Returns

int Major times ten thousand plus minor times a hundred plus patch
Called from 1
Calls 2
public function series(): string

Names the series of the release: every number but the last.

Returns

string `8.0` for `8.0.44`, `17` for `17.2`
Calls 2
public function isAtLeast(string $number): bool

Reports whether the release is the given number or newer.

Parameters

$numberstringRelease number such as `5.7.8`

Returns

bool
Calls 3

Test cases 17§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 12
Other tests reaching this symbol 5

Relations§

Static calls 4
Type declarations 5