From 1f7f85f304351da9a468267a7e9dc3453c572560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Fri, 28 Jul 2023 12:02:13 +0200 Subject: [PATCH 1/4] Fix: Add ReturnTypeWillChange attribute --- src/Optimizely/Decide/OptimizelyDecision.php | 1 + src/Optimizely/OptimizelyConfig/OptimizelyAttribute.php | 1 + src/Optimizely/OptimizelyConfig/OptimizelyAudience.php | 1 + src/Optimizely/OptimizelyConfig/OptimizelyConfig.php | 1 + src/Optimizely/OptimizelyConfig/OptimizelyEvent.php | 1 + src/Optimizely/OptimizelyConfig/OptimizelyExperiment.php | 1 + src/Optimizely/OptimizelyConfig/OptimizelyFeature.php | 1 + src/Optimizely/OptimizelyConfig/OptimizelyVariable.php | 1 + src/Optimizely/OptimizelyConfig/OptimizelyVariation.php | 1 + 9 files changed, 9 insertions(+) diff --git a/src/Optimizely/Decide/OptimizelyDecision.php b/src/Optimizely/Decide/OptimizelyDecision.php index 3cd7fe1c..a69cc8a5 100644 --- a/src/Optimizely/Decide/OptimizelyDecision.php +++ b/src/Optimizely/Decide/OptimizelyDecision.php @@ -81,6 +81,7 @@ public function getReasons() return $this->reasons; } + #[\ReturnTypeWillChange] public function jsonSerialize() { return get_object_vars($this); diff --git a/src/Optimizely/OptimizelyConfig/OptimizelyAttribute.php b/src/Optimizely/OptimizelyConfig/OptimizelyAttribute.php index d3eee9b9..a38182d5 100644 --- a/src/Optimizely/OptimizelyConfig/OptimizelyAttribute.php +++ b/src/Optimizely/OptimizelyConfig/OptimizelyAttribute.php @@ -53,6 +53,7 @@ public function getKey() /** * @return string JSON representation of the object. */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return get_object_vars($this); diff --git a/src/Optimizely/OptimizelyConfig/OptimizelyAudience.php b/src/Optimizely/OptimizelyConfig/OptimizelyAudience.php index e331871a..d11e4b32 100644 --- a/src/Optimizely/OptimizelyConfig/OptimizelyAudience.php +++ b/src/Optimizely/OptimizelyConfig/OptimizelyAudience.php @@ -68,6 +68,7 @@ public function getConditions() /** * @return string JSON representation of the object. */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return get_object_vars($this); diff --git a/src/Optimizely/OptimizelyConfig/OptimizelyConfig.php b/src/Optimizely/OptimizelyConfig/OptimizelyConfig.php index 26093779..c8d6f33e 100644 --- a/src/Optimizely/OptimizelyConfig/OptimizelyConfig.php +++ b/src/Optimizely/OptimizelyConfig/OptimizelyConfig.php @@ -166,6 +166,7 @@ public function getEvents() /** * @return string JSON representation of the object. */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return get_object_vars($this); diff --git a/src/Optimizely/OptimizelyConfig/OptimizelyEvent.php b/src/Optimizely/OptimizelyConfig/OptimizelyEvent.php index 8a3a90de..17ff39ed 100644 --- a/src/Optimizely/OptimizelyConfig/OptimizelyEvent.php +++ b/src/Optimizely/OptimizelyConfig/OptimizelyEvent.php @@ -68,6 +68,7 @@ public function getExperimentIds() /** * @return string JSON representation of the object. */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return get_object_vars($this); diff --git a/src/Optimizely/OptimizelyConfig/OptimizelyExperiment.php b/src/Optimizely/OptimizelyConfig/OptimizelyExperiment.php index 71bd9959..77d274b3 100644 --- a/src/Optimizely/OptimizelyConfig/OptimizelyExperiment.php +++ b/src/Optimizely/OptimizelyConfig/OptimizelyExperiment.php @@ -83,6 +83,7 @@ public function getVariationsMap() /** * @return string JSON representation of the object. */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return get_object_vars($this); diff --git a/src/Optimizely/OptimizelyConfig/OptimizelyFeature.php b/src/Optimizely/OptimizelyConfig/OptimizelyFeature.php index 7b605064..491f4ea2 100644 --- a/src/Optimizely/OptimizelyConfig/OptimizelyFeature.php +++ b/src/Optimizely/OptimizelyConfig/OptimizelyFeature.php @@ -118,6 +118,7 @@ public function getVariablesMap() /** * @return string JSON representation of the object. */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return get_object_vars($this); diff --git a/src/Optimizely/OptimizelyConfig/OptimizelyVariable.php b/src/Optimizely/OptimizelyConfig/OptimizelyVariable.php index 836e054f..fade386b 100644 --- a/src/Optimizely/OptimizelyConfig/OptimizelyVariable.php +++ b/src/Optimizely/OptimizelyConfig/OptimizelyVariable.php @@ -82,6 +82,7 @@ public function getValue() /** * @return string JSON representation of the object. */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return get_object_vars($this); diff --git a/src/Optimizely/OptimizelyConfig/OptimizelyVariation.php b/src/Optimizely/OptimizelyConfig/OptimizelyVariation.php index e7335eea..3e735a20 100644 --- a/src/Optimizely/OptimizelyConfig/OptimizelyVariation.php +++ b/src/Optimizely/OptimizelyConfig/OptimizelyVariation.php @@ -84,6 +84,7 @@ public function getVariablesMap() * @return string JSON representation of the object. * Unsets featureEnabled property for variations of ab experiments. */ + #[\ReturnTypeWillChange] public function jsonSerialize() { $props = get_object_vars($this); From b374f17595ea9cfce7ada0ad113e015012ed41d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Fri, 21 Jul 2023 17:41:58 +0200 Subject: [PATCH 2/4] Enhancement: Keep packages sorted in composer.json --- composer.json | 5 ++++- composer.lock | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 57cc755c..2a28d4cd 100644 --- a/composer.json +++ b/composer.json @@ -16,9 +16,9 @@ }, "require": { "php": ">=8.1", + "guzzlehttp/guzzle": ">=6.2", "justinrainbow/json-schema": "^1.6 || ^2.0 || ^4.0 || ^5.0", "lastguest/murmurhash": "^1.3.0", - "guzzlehttp/guzzle": ">=6.2", "monolog/monolog": ">=1.21" }, "require-dev": { @@ -31,5 +31,8 @@ "psr-4": { "Optimizely\\": "src/Optimizely" } + }, + "config": { + "sort-packages": true } } diff --git a/composer.lock b/composer.lock index 030d3673..50ece972 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2fad7123e2b1cb75c4a03d2332468c70", + "content-hash": "82b1237943c87584a7fd69a882570e14", "packages": [ { "name": "guzzlehttp/guzzle", From 31f811b0582453c24f699d64c45cd6c1f6a6fc1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Fri, 21 Jul 2023 17:29:31 +0200 Subject: [PATCH 3/4] Fix: Wrap arguments in code examples --- README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aec472c4..692f26d4 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,15 @@ $optimizely = new Optimizely(<>); Or you may also use OptimizelyFactory method to create an optimizely client using your SDK key, an optional fallback datafile and an optional datafile access token. Using this method internally creates an HTTPProjectConfigManager. See [HTTPProjectConfigManager](#use-httpprojectconfigmanager) for further detail. ```php -$optimizelyClient = OptimizelyFactory::createDefaultInstance("your-sdk-key", <>, <>); +>, + <> +); ``` To access your HTTPProjectConfigManager: @@ -55,7 +63,15 @@ Or you can also provide an implementation of the [`ProjectConfigManagerInterface ```php $configManager = new HTTPProjectConfigManager(<>); -$optimizely = new Optimizely(<>, null, null, null, false, null, $configManager); +$optimizely = new Optimizely( + <>, + null, + null, + null, + false, + null, + $configManager +); ``` ### ProjectConfigManagerInterface From 5d776a747cc93cc3b6b3ef07ad3507b02c0e615b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Fri, 21 Jul 2023 17:25:27 +0200 Subject: [PATCH 4/4] Fix: Code examples --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 692f26d4..6f9d1610 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,10 @@ php composer.phar require optimizely/optimizely-sdk Create the Optimizely client, for example: ```php +>); ``` @@ -56,12 +60,22 @@ $optimizelyClient = OptimizelyFactory::createDefaultInstance( To access your HTTPProjectConfigManager: ```php +configManager; ``` Or you can also provide an implementation of the [`ProjectConfigManagerInterface`](https://github.com/optimizely/php-sdk/blob/master/src/Optimizely/ProjectConfigManager/ProjectConfigManagerInterface.php) in the constructor: ```php +>); $optimizely = new Optimizely( <>, @@ -90,6 +104,10 @@ Calling `fetch` will update the internal ProjectConfig instance that will be ret ### Use HTTPProjectConfigManager ```php +>); ```