classServerVersion
final class ServerVersion
@visibility public.A supported database release, named by the version tag the sql-* packages share.
\SqlFixture\Version\ServerVersion::resolve('mysql')->tag // => 'mysql-8.4.7'\SqlFixture\Version\ServerVersion::fromServer('mysql', '8.0.36-0ubuntu0.22.04.1')->tag // => 'mysql-8.0.44'Properties§
public string $dialectpublic string $tagpublic string $numberMethods§
public function __construct(public string $dialect, public string $tag, public string $number)Parameters
$dialect | string | Dialect the release belongs to: `mysql`, `pgsql` or `sqlite` |
$tag | string | Version tag such as `mysql-8.4.7` |
$number | string | Release number such as `8.4.7` |
public static function resolve(string $dialect, string|null $tag = null): selfResolves a version tag, the default of the dialect when none is given.
Parameters
$dialect | string | Dialect to look in |
$tag | string|null | Version tag such as `mysql-8.4.7`, or null for the default |
Returns
selfThrows
UnsupportedVersionException When the dialect has no releases or the tag is not one of themTest cases 8
MySqlReleaseRoundTripTest::testRowGeneratedFromTheReportedSchemaIsAcceptedcallsServerVersionTest::testIdNumbersTheReleaseLikeMysqlcallsServerVersionTest::testIsAtLeastComparesNumberscallsServerVersionTest::testResolveNamesTheDefaultOfEachDialectcallsServerVersionTest::testResolveReadsTheNumberOfATagcallsServerVersionTest::testResolveRejectsAnUnknownDialectcallsServerVersionTest::testResolveRejectsATagOfAnotherDialectcallsServerVersionTest::testSeriesDropsTheLastNumbercalls
Called from 2
Calls 5
- new Releases line 40
- method-call Releases::defaultTag() line 41
- method-call Releases::numbers() line 42
- new UnsupportedVersionException line 42
- new
selfline 44
public static function fromServer(string $dialect, string $reported): selfMatches 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
$dialect | string | Dialect of the server |
$reported | string | Version string of the server, such as `8.0.36-0ubuntu0.22.04.1` |
Returns
selfThrows
UnsupportedVersionException When the dialect has no releases or the string holds no version numberTest cases 2
Called from 1
Calls 7
- static-call ReleaseNumber::fromReported() line 62
- new UnsupportedVersionException line 62
- static-call ServerVersion::all() line 63
- function-call
array_filterline 64 - method-call
self::series()line 64 - function-call
endline 66 - method-call
self::id()line 68
public static function all(string $dialect): non-empty-list<self>Lists the releases of a dialect, oldest first.
Parameters
$dialect | string |
Returns
non-empty-list<self>Throws
UnsupportedVersionException When the dialect has no releasesTest cases 2
Called from 1
Calls 3
- method-call Releases::numbers() line 83
- new Releases line 83
- new
selfline 84
public static function tags(string $dialect): non-empty-list<string>Lists the version tags of a dialect, oldest first.
Parameters
$dialect | string |
Returns
non-empty-list<string>Throws
UnsupportedVersionException When the dialect has no releasesTest cases 1
Called from 1
Calls 3
- function-call
array_keysline 99 - method-call Releases::numbers() line 99
- new Releases line 99
public function isDefault(): boolReports whether this is the default release of its dialect.
Returns
boolTest cases 1
Calls 2
- method-call Releases::defaultTag() line 107
- new Releases line 107
public function id(): intNumbers the release as MySQL numbers its own, as in MYSQL_VERSION_ID.
Returns
int Major times ten thousand plus minor times a hundred plus patchCalled from 1
Calls 2
- method-call ReleaseNumber::id() line 117
- new ReleaseNumber line 117
public function series(): stringNames the series of the release: every number but the last.
Returns
string `8.0` for `8.0.44`, `17` for `17.2`Calls 2
- method-call ReleaseNumber::series() line 127
- new ReleaseNumber line 127
public function isAtLeast(string $number): boolReports whether the release is the given number or newer.
Parameters
$number | string | Release number such as `5.7.8` |
Returns
boolCalls 3
- method-call ServerVersion::id() line 137
- method-call ReleaseNumber::id() line 137
- new ReleaseNumber line 137
Test cases 17§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 12
ServerVersionTest::testAllListsTheReleasesOldestFirstcallsServerVersionTest::testFromServerMatchesTheClosestReleasecallsServerVersionTest::testFromServerRejectsAStringWithoutANumbercallsServerVersionTest::testIdNumbersTheReleaseLikeMysqlcallsServerVersionTest::testIsAtLeastComparesNumberscallsServerVersionTest::testIsDefaultMarksOneReleasePerDialectcallsServerVersionTest::testResolveNamesTheDefaultOfEachDialectcallsServerVersionTest::testResolveReadsTheNumberOfATagcallsServerVersionTest::testResolveRejectsAnUnknownDialectcallsServerVersionTest::testResolveRejectsATagOfAnotherDialectcallsServerVersionTest::testSeriesDropsTheLastNumbercallsServerVersionTest::testTagsMatchTheOtherSqlPackagescalls
Other tests reaching this symbol 5
Relations§
Static calls 4
- static-call SqlFixture\Provider\PlatformFactory::resolveVersion() packages/sql-fixture/src/Provider/PlatformFactory.php:121
- static-call SqlFixture\Provider\PlatformFactory::detectVersion() packages/sql-fixture/src/Provider/PlatformFactory.php:163
- static-call SqlFixture\Provider\PlatformFactory::detectVersion() packages/sql-fixture/src/Provider/PlatformFactory.php:171
- static-call SqlFixture\Provider\PlatformFactory::getSupportedVersions() packages/sql-fixture/src/Provider/PlatformFactory.php:201
Type declarations 5
- type SqlFixture\Provider\DatabaseFixtureProvider packages/sql-fixture/src/Provider/DatabaseFixtureProvider.php:39
- type SqlFixture\Provider\FileFixtureProvider packages/sql-fixture/src/Provider/FileFixtureProvider.php:27
- type SqlFixture\Provider\FixtureProvider packages/sql-fixture/src/Provider/FixtureProvider.php:47
- type SqlFixture\Provider\PlatformFactory packages/sql-fixture/src/Provider/PlatformFactory.php:115
- type SqlFixture\Provider\PlatformFactory packages/sql-fixture/src/Provider/PlatformFactory.php:159