diff --git a/src/Optimizely/DecisionService/DecisionService.php b/src/Optimizely/DecisionService/DecisionService.php index cb8f6bd6..6b7d9259 100644 --- a/src/Optimizely/DecisionService/DecisionService.php +++ b/src/Optimizely/DecisionService/DecisionService.php @@ -81,9 +81,9 @@ class DecisionService * DecisionService constructor. * * @param LoggerInterface $logger - * @param UserProfileServiceInterface $userProfileService + * @param ?UserProfileServiceInterface $userProfileService */ - public function __construct(LoggerInterface $logger, UserProfileServiceInterface $userProfileService = null) + public function __construct(LoggerInterface $logger, ?UserProfileServiceInterface $userProfileService = null) { $this->_logger = $logger; $this->_bucketer = new Bucketer($logger); diff --git a/src/Optimizely/Event/Dispatcher/DefaultEventDispatcher.php b/src/Optimizely/Event/Dispatcher/DefaultEventDispatcher.php index b5b4b7c3..a45a1074 100644 --- a/src/Optimizely/Event/Dispatcher/DefaultEventDispatcher.php +++ b/src/Optimizely/Event/Dispatcher/DefaultEventDispatcher.php @@ -36,7 +36,7 @@ class DefaultEventDispatcher implements EventDispatcherInterface */ private $httpClient; - public function __construct(HttpClient $httpClient = null) + public function __construct(?HttpClient $httpClient = null) { $this->httpClient = $httpClient ?: new HttpClient(); } diff --git a/src/Optimizely/Optimizely.php b/src/Optimizely/Optimizely.php index 69833f56..968e1a0a 100644 --- a/src/Optimizely/Optimizely.php +++ b/src/Optimizely/Optimizely.php @@ -119,24 +119,24 @@ class Optimizely * Optimizely constructor for managing Feature Experimentation PHP projects. * * @param $datafile string JSON string representing the project. - * @param $eventDispatcher EventDispatcherInterface - * @param $logger LoggerInterface - * @param $errorHandler ErrorHandlerInterface + * @param $eventDispatcher ?EventDispatcherInterface + * @param $logger ?LoggerInterface + * @param $errorHandler ?ErrorHandlerInterface * @param $skipJsonValidation boolean representing whether JSON schema validation needs to be performed. - * @param $userProfileService UserProfileServiceInterface - * @param $configManager ProjectConfigManagerInterface provides ProjectConfig through getConfig method. - * @param $notificationCenter NotificationCenter + * @param $userProfileService ?UserProfileServiceInterface + * @param $configManager ?ProjectConfigManagerInterface provides ProjectConfig through getConfig method. + * @param $notificationCenter ?NotificationCenter * @param $sdkKey string uniquely identifying the datafile corresponding to project and environment combination. Must provide at least one of datafile or sdkKey. */ public function __construct( $datafile, - EventDispatcherInterface $eventDispatcher = null, - LoggerInterface $logger = null, - ErrorHandlerInterface $errorHandler = null, + ?EventDispatcherInterface $eventDispatcher = null, + ?LoggerInterface $logger = null, + ?ErrorHandlerInterface $errorHandler = null, $skipJsonValidation = false, - UserProfileServiceInterface $userProfileService = null, - ProjectConfigManagerInterface $configManager = null, - NotificationCenter $notificationCenter = null, + ?UserProfileServiceInterface $userProfileService = null, + ?ProjectConfigManagerInterface $configManager = null, + ?NotificationCenter $notificationCenter = null, $sdkKey = null, array $defaultDecideOptions = [] ) { diff --git a/src/Optimizely/OptimizelyConfig/OptimizelyConfigService.php b/src/Optimizely/OptimizelyConfig/OptimizelyConfigService.php index c8d22c36..d6463ee2 100644 --- a/src/Optimizely/OptimizelyConfig/OptimizelyConfigService.php +++ b/src/Optimizely/OptimizelyConfig/OptimizelyConfigService.php @@ -85,7 +85,7 @@ class OptimizelyConfigService private ProjectConfigInterface $projectConfig; - public function __construct(ProjectConfigInterface $projectConfig, LoggerInterface $logger = null) + public function __construct(ProjectConfigInterface $projectConfig, ?LoggerInterface $logger = null) { $this->experiments = $projectConfig->getAllExperiments(); $this->featureFlags = $projectConfig->getFeatureFlags(); diff --git a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php index 83e5f839..5e56935e 100644 --- a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php +++ b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php @@ -89,9 +89,9 @@ public function __construct( $fetchOnInit = true, $datafile = null, $skipJsonValidation = false, - LoggerInterface $logger = null, - ErrorHandlerInterface $errorHandler = null, - NotificationCenter $notificationCenter = null, + ?LoggerInterface $logger = null, + ?ErrorHandlerInterface $errorHandler = null, + ?NotificationCenter $notificationCenter = null, $datafileAccessToken = null ) { $this->_skipJsonValidation = $skipJsonValidation; diff --git a/src/Optimizely/Utils/Validator.php b/src/Optimizely/Utils/Validator.php index ff2f1c5b..803bc25b 100644 --- a/src/Optimizely/Utils/Validator.php +++ b/src/Optimizely/Utils/Validator.php @@ -31,7 +31,7 @@ class Validator * * @return boolean Representing whether schema is valid or not. */ - public static function validateJsonSchema($datafile, LoggerInterface $logger = null) + public static function validateJsonSchema($datafile, ?LoggerInterface $logger = null) { $data = json_decode($datafile); diff --git a/src/Optimizely/Utils/VariableTypeUtils.php b/src/Optimizely/Utils/VariableTypeUtils.php index a6e534ef..faa9a1ea 100644 --- a/src/Optimizely/Utils/VariableTypeUtils.php +++ b/src/Optimizely/Utils/VariableTypeUtils.php @@ -24,7 +24,7 @@ class VariableTypeUtils { - public static function castStringToType($value, $variableType, LoggerInterface $logger = null) + public static function castStringToType($value, $variableType, ?LoggerInterface $logger = null) { if ($variableType == FeatureVariable::STRING_TYPE) { return $value;