MMOframework
Pourquoi l'IA Playground Bibliothèques Développeurs Agence
FR EN
Créer un projet en direct
Index

Version

MMO\admin\helpers · 1 symbole · générée le 30 Nov 2026

class

Version

Version.php:29

The version of one package -- the project, or a library it packages -- in the git repository its mmo.json is committed in: what it is, whether anything was committed since it was last increased, and the commit increasing it.

class MMO\admin\helpers\Version
Espace de noms
MMO\admin\helpers
A release is named after the project's version and packages each library under its own, so a version that was not increased names two different codes: `release` increases, before building, the version of every package with commits since its version last changed ([`ProductionController::prepareVersions`](https://mmoframework.fr/documentation/mmo.admin/php/controllers/ProductionController.md#productioncontroller-prepareversions)), and `version` increases one by hand. The commit holds the new version alone: mmo.json, and nothing else -- whatever else is staged stays staged. Only the value changes in the file ([`JsonEditor`](https://mmoframework.fr/documentation/mmo.admin/php/helpers/JsonEditor.md#jsoneditor)): its comments and its layout stay, and the diff is one line.
$version = new Version($manifest, new GitRepository(dirname($manifest->filename))); $version->getChanges(); // 4: commits since the version last changed $version->getNext('minor'); // '1.5.0' $version->increase('patch'); // '1.4.3', committed as "version 1.4.3"

Constantes1

PARTS

part => where it is in major.minor.patch.

const PARTS = ['patch' => 2, 'minor' => 1, 'major' => 0]

Propriétés4

changes

protected ?int $changes = null
Type
null | int

git

readonly
readonly MMO\git\helpers\Repository $git
Type
Repository

manifest

readonly
readonly MMO\core\helpers\PackageManifest $manifest
Type
PackageManifest

message

protected string $message
Type
string

Méthodes13

getBranch()

Version.php:80
function getBranch(): string
retournestringthe branch the commit would go on; '' when the repository is on no branch.

getChanges()

Version.php:86
function getChanges(): int
retourneinthow many commits were made since the version last changed: since the last commit changing the "version" line of mmo.json. 0: the code is the one this version names.

getMessage($version)

Version.php:109
function getMessage(string $version): string
$versionstring
retournestringthe message of the commit increasing the version to $version.

getNext($part)

Version.php:70
function getNext(string $part): string
$partstringmajor, minor or patch.
retournestringthe version once $part is increased: semver, what is below it starts again from 0.
lèvewhen $part is none of them, or the version is not major.minor.patch.

getNumbers()

Version.php:61
function getNumbers(): ?array
retournenull | array[major, minor, patch]; null when the version is not written major.minor.patch.

getPath()

Version.php:54
protected function getPath(): string
retournestringthe manifest, relative to its repository: what git is given.

getRefusal()

Version.php:98
function getRefusal(): ?string
retournenull | stringwhy the version cannot be increased by a commit now; null when it can.

increase($part, $with)

Version.php:121

Write the next version into mmo.json and commit it, on the current branch.

function increase(string $part, array $with = []): string
$partstringmajor, minor or patch.
$with = []arraymore paths of the repository the commit holds: the libraries' submodules a project records with its own version.
retournestringthe new version.
lèvewhen it cannot be increased (getRefusal), or the commit failed -- mmo.json is then as it was.

__construct($manifest, $git, $message)

Version.php:36
function __construct( MMO\core\helpers\PackageManifest $manifest, MMO\git\helpers\Repository $git, string $message = 'version {version}' )
$manifestPackageManifest
$gitRepository
$message = 'version {version}'string