From 26badc759e50e182e1ef83b913972fc0a9fde3f6 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Mon, 14 Mar 2022 21:31:30 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=20Conditional=20PHP=205.6=20suppor?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Common/PHP/PHP Version/PhpEnv.swift | 8 +++++++- phpmon/Domain/Integrations/Valet/Valet.swift | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/phpmon/Common/PHP/PHP Version/PhpEnv.swift b/phpmon/Common/PHP/PHP Version/PhpEnv.swift index 571b762..66b2a7e 100644 --- a/phpmon/Common/PHP/PHP Version/PhpEnv.swift +++ b/phpmon/Common/PHP/PHP Version/PhpEnv.swift @@ -124,6 +124,12 @@ class PhpEnv { ) -> [String] { var output : [String] = [] + var supported = Constants.SupportedPhpVersions + + if !Valet.enabled(feature: .supportForPhp56) { + supported.removeAll { $0 == "5.6" } + } + versions.filter { (version) -> Bool in // Omit everything that doesn't start with php@ // (e.g. something-php@8.0 won't be detected) @@ -133,7 +139,7 @@ class PhpEnv { // Only append the version if it doesn't already exist (avoid dupes), // is supported and where the binary exists (avoids broken installs) if !output.contains(version) - && Constants.SupportedPhpVersions.contains(version) + && supported.contains(version) && (checkBinaries ? Filesystem.fileExists("\(Paths.optPath)/php@\(version)/bin/php") : true) { output.append(version) diff --git a/phpmon/Domain/Integrations/Valet/Valet.swift b/phpmon/Domain/Integrations/Valet/Valet.swift index 02ae679..691f173 100644 --- a/phpmon/Domain/Integrations/Valet/Valet.swift +++ b/phpmon/Domain/Integrations/Valet/Valet.swift @@ -11,7 +11,8 @@ import Foundation class Valet { enum FeatureFlag { - case isolatedSites + case isolatedSites, + supportForPhp56 } static let shared = Valet() @@ -37,6 +38,13 @@ class Valet { self.sites = [] } + /** + Check if a particular feature is enabled. + */ + public static func enabled(feature: FeatureFlag) -> Bool { + return self.shared.features.contains(feature) + } + /** We don't want to load the initial config.json file as soon as the class is initialised. Instead, we'll defer the loading of the configuration file once the initial app checks @@ -91,9 +99,11 @@ class Valet { */ public func validateVersion() -> Void { if version.versionCompare("3.0") == .orderedAscending { - Log.warn("This version of Valet does not support isolation yet. Disabling isolation checks.") + Log.info("This version of Valet does not support isolation yet. Disabling isolation checks.") + self.features.append(.supportForPhp56) } else { - self.features.append(FeatureFlag.isolatedSites) + Log.info("This version of Valet does not support PHP 5.6.") + self.features.append(.isolatedSites) } if version.versionCompare(Constants.MinimumRecommendedValetVersion) == .orderedAscending {