Skip to content

Commit 52b8b07

Browse files
Tamara-Barumclaude
andauthored
[FSSDK-12610] Fix: PHP 8.4 implicit nullable parameter deprecation warnings (#296)
* [FSSDK-12610] Fix: PHP 8.4 implicit nullable parameter deprecation warnings Use explicit nullable types (?Type) instead of implicit nullable (Type $param = null) to resolve deprecation warnings on PHP 8.4. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [FSSDK-12610] Fix remaining implicit nullable parameters in Validator, VariableTypeUtils, DefaultEventDispatcher, OptimizelyConfigService Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [FSSDK-12610] Update PHPDoc to reflect explicit nullable parameter types Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8539381 commit 52b8b07

7 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/Optimizely/DecisionService/DecisionService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class DecisionService
8181
* DecisionService constructor.
8282
*
8383
* @param LoggerInterface $logger
84-
* @param UserProfileServiceInterface $userProfileService
84+
* @param ?UserProfileServiceInterface $userProfileService
8585
*/
86-
public function __construct(LoggerInterface $logger, UserProfileServiceInterface $userProfileService = null)
86+
public function __construct(LoggerInterface $logger, ?UserProfileServiceInterface $userProfileService = null)
8787
{
8888
$this->_logger = $logger;
8989
$this->_bucketer = new Bucketer($logger);

src/Optimizely/Event/Dispatcher/DefaultEventDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DefaultEventDispatcher implements EventDispatcherInterface
3636
*/
3737
private $httpClient;
3838

39-
public function __construct(HttpClient $httpClient = null)
39+
public function __construct(?HttpClient $httpClient = null)
4040
{
4141
$this->httpClient = $httpClient ?: new HttpClient();
4242
}

src/Optimizely/Optimizely.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,24 @@ class Optimizely
119119
* Optimizely constructor for managing Feature Experimentation PHP projects.
120120
*
121121
* @param $datafile string JSON string representing the project.
122-
* @param $eventDispatcher EventDispatcherInterface
123-
* @param $logger LoggerInterface
124-
* @param $errorHandler ErrorHandlerInterface
122+
* @param $eventDispatcher ?EventDispatcherInterface
123+
* @param $logger ?LoggerInterface
124+
* @param $errorHandler ?ErrorHandlerInterface
125125
* @param $skipJsonValidation boolean representing whether JSON schema validation needs to be performed.
126-
* @param $userProfileService UserProfileServiceInterface
127-
* @param $configManager ProjectConfigManagerInterface provides ProjectConfig through getConfig method.
128-
* @param $notificationCenter NotificationCenter
126+
* @param $userProfileService ?UserProfileServiceInterface
127+
* @param $configManager ?ProjectConfigManagerInterface provides ProjectConfig through getConfig method.
128+
* @param $notificationCenter ?NotificationCenter
129129
* @param $sdkKey string uniquely identifying the datafile corresponding to project and environment combination. Must provide at least one of datafile or sdkKey.
130130
*/
131131
public function __construct(
132132
$datafile,
133-
EventDispatcherInterface $eventDispatcher = null,
134-
LoggerInterface $logger = null,
135-
ErrorHandlerInterface $errorHandler = null,
133+
?EventDispatcherInterface $eventDispatcher = null,
134+
?LoggerInterface $logger = null,
135+
?ErrorHandlerInterface $errorHandler = null,
136136
$skipJsonValidation = false,
137-
UserProfileServiceInterface $userProfileService = null,
138-
ProjectConfigManagerInterface $configManager = null,
139-
NotificationCenter $notificationCenter = null,
137+
?UserProfileServiceInterface $userProfileService = null,
138+
?ProjectConfigManagerInterface $configManager = null,
139+
?NotificationCenter $notificationCenter = null,
140140
$sdkKey = null,
141141
array $defaultDecideOptions = []
142142
) {

src/Optimizely/OptimizelyConfig/OptimizelyConfigService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class OptimizelyConfigService
8585

8686
private ProjectConfigInterface $projectConfig;
8787

88-
public function __construct(ProjectConfigInterface $projectConfig, LoggerInterface $logger = null)
88+
public function __construct(ProjectConfigInterface $projectConfig, ?LoggerInterface $logger = null)
8989
{
9090
$this->experiments = $projectConfig->getAllExperiments();
9191
$this->featureFlags = $projectConfig->getFeatureFlags();

src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public function __construct(
8989
$fetchOnInit = true,
9090
$datafile = null,
9191
$skipJsonValidation = false,
92-
LoggerInterface $logger = null,
93-
ErrorHandlerInterface $errorHandler = null,
94-
NotificationCenter $notificationCenter = null,
92+
?LoggerInterface $logger = null,
93+
?ErrorHandlerInterface $errorHandler = null,
94+
?NotificationCenter $notificationCenter = null,
9595
$datafileAccessToken = null
9696
) {
9797
$this->_skipJsonValidation = $skipJsonValidation;

src/Optimizely/Utils/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Validator
3131
*
3232
* @return boolean Representing whether schema is valid or not.
3333
*/
34-
public static function validateJsonSchema($datafile, LoggerInterface $logger = null)
34+
public static function validateJsonSchema($datafile, ?LoggerInterface $logger = null)
3535
{
3636
$data = json_decode($datafile);
3737

src/Optimizely/Utils/VariableTypeUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
class VariableTypeUtils
2626
{
27-
public static function castStringToType($value, $variableType, LoggerInterface $logger = null)
27+
public static function castStringToType($value, $variableType, ?LoggerInterface $logger = null)
2828
{
2929
if ($variableType == FeatureVariable::STRING_TYPE) {
3030
return $value;

0 commit comments

Comments
 (0)