/** * Increment the version number * @param string $what One of 'major', 'minor', 'patch' or 'prerelease' * @return \vierbergenlars\SemVer\version * @throws LogicException When an invalid increment value is given */ public function inc($what) { $this->version->inc($what); return $this; }
public function parse(string $comp) { $r = $this->loose ? Exports::$re[COMPARATORLOOSE] : Exports::$re[COMPARATOR]; $m = $comp->match($r); if (!$m) { throw new \RuntimeException('Invalid comparator: ' . $comp); } $this->operator = $m[1]; if (!$m[2]) { $this->semver = null; } else { $this->semver = new SemVer($m[2], $this->loose); // <1.2.3-rc DOES allow 1.2.3-beta (has prerelease) // >=1.2.3 DOES NOT allow 1.2.3-beta // <=1.2.3 DOES allow 1.2.3-beta // However, <1.2.3 does NOT allow 1.2.3-beta, // even though `1.2.3-beta < 1.2.3` // The assumption is that the 1.2.3 version has something you // *don't* want, so we push the prerelease down to the minimum. if ($this->operator->valueOf() === '<' && !$this->semver->prerelease->length) { $this->semver->prerelease = new JSArray(array(0)); $this->semver->format(); } } }