diff --git a/.github/ISSUE_TEMPLATE/1_Bug_report.md b/.github/ISSUE_TEMPLATE/1_Bug_report.md index 5ea3ac3..4bbf5b7 100644 --- a/.github/ISSUE_TEMPLATE/1_Bug_report.md +++ b/.github/ISSUE_TEMPLATE/1_Bug_report.md @@ -14,10 +14,10 @@ labels: Bug ### Additional Info -| Q | A -|------------------| --- -| Package Version | x.y.z -| PHP version | x.y.z -| Operating system | Linux +| Q | A | +|------------------|-----------------------------------------------| +| Package Version | x.y.z | +| PHP version | x.y.z | +| Operating system | Linux | diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8c0643a..7d0c40e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,10 +1,10 @@ -| Q | A -| ------------- | --- -| Bugfix? | ✔️/❌ -| Breaks BC? | ✔️/❌ -| New feature? | ✔️/❌ -| Issues | #... -| Docs PR | spiral/docs#... +| Q | A | +|--------------|-------------------------------------------------------------------------------------------------------------------------| +| Bugfix? | ✔️/❌ | +| Breaks BC? | ✔️/❌ | +| New feature? | ✔️/❌ | +| Issues | #... | +| Docs PR | spiral/docs#... | diff --git a/src/Environment.php b/src/Environment.php index d1eef55..1af6963 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -9,9 +9,10 @@ /** * @psalm-import-type ModeType from Mode * @psalm-type EnvironmentVariables = array{ - * RR_MODE?: ModeType|string, - * RR_RELAY?: string, - * RR_RPC?: string, + * RR_MODE?: ModeType|string, + * RR_RELAY?: string, + * RR_RPC?: string, + * RR_VERSION?: string, * }|array * @see Mode */ @@ -27,7 +28,7 @@ public function __construct( public function getMode(): string { - return $this->get('RR_MODE', ''); + return $this->get('RR_MODE'); } public function getRelayAddress(): string @@ -40,6 +41,11 @@ public function getRPCAddress(): string return $this->get('RR_RPC', 'tcp://127.0.0.1:6001'); } + public function getVersion(): string + { + return $this->get('RR_VERSION'); + } + /** * @template TDefault of string * diff --git a/src/EnvironmentInterface.php b/src/EnvironmentInterface.php index 4219db9..a659a45 100644 --- a/src/EnvironmentInterface.php +++ b/src/EnvironmentInterface.php @@ -12,6 +12,7 @@ * * @psalm-import-type ModeType from Mode * @see Mode + * @method string getVersion() */ interface EnvironmentInterface { diff --git a/src/Worker.php b/src/Worker.php index ca7bd92..16a7281 100644 --- a/src/Worker.php +++ b/src/Worker.php @@ -276,11 +276,10 @@ public static function createFromEnvironment( ); } - private function sendProcessId(): static + private function sendProcessId(): void { $frame = new Frame($this->encode(['pid' => \getmypid()]), [], Frame::CONTROL); $this->sendFrame($frame); - return $this; } private function haveToPing(): void diff --git a/tests/Unit/EnvironmentTest.php b/tests/Unit/EnvironmentTest.php index 93040cf..e5a5648 100644 --- a/tests/Unit/EnvironmentTest.php +++ b/tests/Unit/EnvironmentTest.php @@ -45,15 +45,23 @@ public function testGetRPCAddressWithValue(): void $this->assertEquals('rpc_value', $env->getRPCAddress()); } + public function testGetVersionWithValue(): void + { + $env = new Environment(['RR_VERSION' => '2024.1.3']); + $this->assertEquals('2024.1.3', $env->getVersion()); + } + public function testFromGlobals(): void { $_ENV['RR_MODE'] = 'global_mode'; $_SERVER['RR_RELAY'] = 'global_relay'; + $_SERVER['RR_VERSION'] = 'global_version'; $env = Environment::fromGlobals(); $this->assertEquals('global_mode', $env->getMode()); $this->assertEquals('global_relay', $env->getRelayAddress()); + $this->assertEquals('global_version', $env->getVersion()); $this->assertEquals('tcp://127.0.0.1:6001', $env->getRPCAddress()); } } \ No newline at end of file