From ae819fcbaaeff44cde8b1a734bd3cb78f6d22cba Mon Sep 17 00:00:00 2001 From: Guilherme Cota <75252715+guilhermecotaGn@users.noreply.github.com> Date: Fri, 27 Oct 2023 15:55:05 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Fixed=20version=20validat?= =?UTF-8?q?ion=20of=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- migrationChecker.php | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/migrationChecker.php b/migrationChecker.php index 918b0fb..e0615ec 100644 --- a/migrationChecker.php +++ b/migrationChecker.php @@ -13,8 +13,8 @@ class MigrationChecker { private const REQUIRED_PACKAGES = [ - 'guzzlehttp/guzzle' => '7.4', - 'symfony/cache' => '^5.0', + 'guzzlehttp/guzzle' => '^7.4', + 'symfony/cache' => '^5.0 || ^6.0' ]; private const CORRECTIONS = [ @@ -23,7 +23,7 @@ class MigrationChecker 'new Gerencianet' => 'new EfiPay', 'Gerencianet::getInstance' => 'EfiPay::getInstance', 'catch (GerencianetException' => 'catch (EfiException', - 'oneStep' => 'createOneStepCharge', + 'oneStep(' => 'createOneStepCharge(', 'payCharge' => 'definePayMethod', 'resendBillet' => 'sendBilletEmail', 'chageLink' => 'defineLinkPayMethod', @@ -61,7 +61,7 @@ public function checkPHPVersion(): array $resultPhpVersion = []; $phpVersion = PHP_VERSION; $resultPhpVersion['version'] = $phpVersion; - if (version_compare($phpVersion, '7.2', '<')) { + if (version_compare($phpVersion, '7.2.5', '<')) { $resultPhpVersion['result'] = "A versão do PHP instalada NÃO ATENDE aos requisitos. Instale o PHP 7.2 ou superior."; $resultPhpVersion['icon'] = $this->getIcon('danger'); } else { @@ -133,9 +133,18 @@ private function getMissingPackages(): array foreach ($this->installedPackages['packages'] as $installedPackage) { if ($installedPackage['name'] === $package) { - if (version_compare($installedPackage['version'], $version, '>=')) { - $packageFound = true; - break; + $installedVersion = $installedPackage['version']; + + // Check if the installed version matches any of the allowed versions + $allowedVersions = explode(' || ', $version); + $installedVersion = $this->addVersionPrefix($installedVersion); // Adicionar 'v' se necessário + + foreach ($allowedVersions as $allowedVersion) { + $allowedVersion = $this->addVersionPrefix($allowedVersion); // Adicionar 'v' se necessário + if (version_compare($installedVersion, $allowedVersion, '>=')) { + $packageFound = true; + break; + } } } } @@ -148,6 +157,14 @@ private function getMissingPackages(): array return $missingPackages; } + public function addVersionPrefix($version) + { + if (strpos($version, 'v') === false) { + return 'v' . $version; + } + return $version; + } + public function checkCodeCorrections(): array { $corrections = $this->getCorrections(); @@ -600,4 +617,4 @@ classes e métodos que foram modificados na nova versão da SDK.