diff --git a/.dagger/src/PhpProject.php b/.dagger/src/PhpProject.php index b83e274..fee989f 100644 --- a/.dagger/src/PhpProject.php +++ b/.dagger/src/PhpProject.php @@ -20,14 +20,14 @@ #[Doc("PHP Code Quality functions")] class PhpProject { + private static string|null $version = null; + private function php( Directory $source, string $image = "php", string $variant = "cli", ): Container { - global $version; - - if (!isset($version)) { + if (self::$version === null) { $output = dag() ->container() ->from("composer:2") @@ -43,7 +43,7 @@ private function php( foreach (explode(PHP_EOL, $output) as $line) { if (preg_match('/^versions\D+(?(?\d+)\.(?\d+)\.(?\d+)).*/xms', $line, $matches)) { - $version = implode('.', [ + self::$version = implode('.', [ $matches['major'], $matches['minor'], ]); @@ -54,9 +54,9 @@ private function php( return dag() ->container() - ->from(match ($version ?? false) { - false => "{$image}:{$variant}", - default => "{$image}:{$version}-{$variant}" + ->from(match (self::$version) { + null => "{$image}:{$variant}", + default => "{$image}:{self::$version}-{$variant}" }) ; }