@@ -278,15 +278,20 @@ private function downloadPhar(
278278 ): void
279279 {
280280 $ currentVersion = null ;
281+ $ branch = 'master ' ;
281282 if (is_file ($ pharPath ) && is_file ($ infoPath )) {
282283 /** @var array{version: string, date: string} $currentInfo */
283284 $ currentInfo = Json::decode (FileReader::read ($ infoPath ), Json::FORCE_ARRAY );
284285 $ currentVersion = $ currentInfo ['version ' ];
286+ $ currentBranch = $ currentInfo ['branch ' ] ?? 'master ' ;
285287 $ currentDate = DateTime::createFromFormat (DateTime::ATOM , $ currentInfo ['date ' ]);
286288 if ($ currentDate === false ) {
287289 throw new ShouldNotHappenException ();
288290 }
289- if ((new DateTimeImmutable ('' , new DateTimeZone ('UTC ' ))) <= $ currentDate ->modify ('+24 hours ' )) {
291+ if (
292+ $ currentBranch === $ branch
293+ && (new DateTimeImmutable ('' , new DateTimeZone ('UTC ' ))) <= $ currentDate ->modify ('+24 hours ' )
294+ ) {
290295 return ;
291296 }
292297
@@ -311,9 +316,9 @@ private function downloadPhar(
311316 /**
312317 * @var array{url: string, version: string} $latestInfo
313318 */
314- $ latestInfo = Json::decode ((string ) await ($ client ->get (sprintf ('https://fixer-download-api.phpstan.com/latest?%s ' , http_build_query (['phpVersion ' => PHP_VERSION_ID ]))))->getBody (), Json::FORCE_ARRAY );
319+ $ latestInfo = Json::decode ((string ) await ($ client ->get (sprintf ('https://fixer-download-api.phpstan.com/latest?%s ' , http_build_query (['phpVersion ' => PHP_VERSION_ID , ' branch ' => $ branch ]))))->getBody (), Json::FORCE_ARRAY );
315320 if ($ currentVersion !== null && $ latestInfo ['version ' ] === $ currentVersion ) {
316- $ this ->writeInfoFile ($ infoPath , $ latestInfo ['version ' ]);
321+ $ this ->writeInfoFile ($ infoPath , $ latestInfo ['version ' ], $ branch );
317322 $ output ->writeln ('<fg=green>You \'re running the latest PHPStan Pro!</> ' );
318323 return ;
319324 }
@@ -354,7 +359,7 @@ private function downloadPhar(
354359 $ output ->writeln ('' );
355360 $ output ->writeln ('' );
356361
357- $ this ->writeInfoFile ($ infoPath , $ latestInfo ['version ' ]);
362+ $ this ->writeInfoFile ($ infoPath , $ latestInfo ['version ' ], $ branch );
358363 }
359364
360365 private function printDownloadError (OutputInterface $ output , Throwable $ e ): void
@@ -370,10 +375,11 @@ private function printDownloadError(OutputInterface $output, Throwable $e): void
370375 $ output ->writeln ('' );
371376 }
372377
373- private function writeInfoFile (string $ infoPath , string $ version ): void
378+ private function writeInfoFile (string $ infoPath , string $ version, string $ branch ): void
374379 {
375380 FileWriter::write ($ infoPath , Json::encode ([
376381 'version ' => $ version ,
382+ 'branch ' => $ branch ,
377383 'date ' => (new DateTimeImmutable ('' , new DateTimeZone ('UTC ' )))->format (DateTime::ATOM ),
378384 ]));
379385 }
0 commit comments