Skip to content

fix: avoid deprecation notices in php 8.1 when passing null to strlen #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Optimizely/DecisionService/DecisionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public function getForcedVariation(ProjectConfigInterface $projectConfig, $exper
$experimentId = $projectConfig->getExperimentFromKey($experimentKey)->getId();

// check for null and empty string experiment ID
if (strlen($experimentId) == 0) {
if (strlen((string)$experimentId) == 0) {
// this case is logged in getExperimentFromKey
return [ null, $decideReasons];
}
Expand Down Expand Up @@ -554,7 +554,7 @@ public function setForcedVariation(ProjectConfigInterface $projectConfig, $exper
$experimentId = $experiment->getId();

// check if the experiment exists in the datafile (a new experiment is returned if it is not in the datafile)
if (strlen($experimentId) == 0) {
if (strlen((string)$experimentId) == 0) {
// this case is logged in getExperimentFromKey
return false;
}
Expand All @@ -570,7 +570,7 @@ public function setForcedVariation(ProjectConfigInterface $projectConfig, $exper
$variationId = $variation->getId();

// check if the variation exists in the datafile (a new variation is returned if it is not in the datafile)
if (strlen($variationId) == 0) {
if (strlen((string)$variationId) == 0) {
// this case is logged in getVariationFromKey
return false;
}
Expand Down