Skip to content

Commit 8fcd8df

Browse files
author
Matias Melograno
committed
merged
2 parents a0e56bf + f649b67 commit 8fcd8df

File tree

14 files changed

+186
-192
lines changed

14 files changed

+186
-192
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ matrix:
1919
services:
2020
- redis-server
2121

22+
before-install:
23+
- echo "extension = zip.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
24+
2225
install:
2326
- composer install --prefer-source --no-interaction
2427
- composer update

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
6.2.5 (Apr 27, 2021)
2+
- Added delimiter in SharedMemory Cache.
3+
4+
6.2.4 (Mar 20, 2020)
5+
- Added missing methods in ClientInterface.
6+
17
6.2.3 (Nov 1, 2019)
28
- Added flag `IPAddressesEnabled` into options to enable/disable sending MachineName and MachineIP when data is posted in headers.
39

Detailed-README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ $splitClient = $splitFactory->client();
391391
Within tests folder you can find different test suites in order to run the Split SDK tests. The most important test suite is: **integration** that wrap the others test suites.
392392

393393
### Integration test suite
394-
Before to run this test suite, please be sure to have a Redis instance runing:
394+
Before to run this test suite, please be sure to have a Redis instance running:
395395
- In order to have a local Redis instance you can install [Docker Container Tool](https://www.docker.com) and pull the oficial Redis container running the command ```docker pull redis```.
396396

397397
And set the correct values on the **phpunit.xml** that you should have copied from **phpunit.xml.dist** file.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2018 Split Software, Co.
1+
Copyright © 2020 Split Software, Inc.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Split has built and maintains SDKs for:
4949
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
5050
* Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
5151
* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
52-
* .NET [Github](https://github.com/splitio/.net-core-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
52+
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
5353
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
5454
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
5555
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)

composer.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
"authors": [
77
{
88
"name": "Split",
9-
"homepage": "http://split.io"
9+
"homepage": "https://www.split.io/",
10+
"email": "php@split.io"
1011
},
1112
{
12-
"name": "Sebastian Arrubia",
13-
"email": "sebastian@split.io"
13+
"name": "Martin Redolatti",
14+
"email": "martin.redolatti@split.io"
15+
},
16+
{
17+
"name": "Matias Melograno",
18+
"email": "matias.melograno@split.io"
1419
}
1520
],
1621

@@ -28,7 +33,7 @@
2833
"phpunit/phpunit": "~4.0",
2934
"phpdocumentor/phpdocumentor": "2.*",
3035
"squizlabs/php_codesniffer": "2.*",
31-
"rogervila/php-sonarqube-scanner": "0.4.0"
36+
"rogervila/php-sonarqube-scanner": "1.1.0"
3237
},
3338

3439
"autoload": {

src/SplitIO/Component/Common/ErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function stop($throw = false)
7474
}
7575

7676
/**
77-
* Method to add the catched error
77+
* Method to add the caught error
7878
* @param $errno
7979
* @param string $errstr
8080
* @param string $errfile

src/SplitIO/Component/Memory/SharedMemory.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function write($key, $value, $expiration = 60, $mode = 0644, $size
3737

3838
$expiration = time() + $expiration;
3939

40-
$data = json_encode(array('expiration' => $expiration, 'value' => serialize($value)));
40+
$data = json_encode(array('expiration' => $expiration, 'value' => serialize($value))) . "\0";
4141

4242
@$shm_id = shmop_open($key, "c", $mode, $size);
4343

@@ -87,7 +87,11 @@ public static function read($key, $mode = 0644, $size = 100)
8787
throw new ReadSharedMemoryException("The shared memory block could not be read");
8888
}
8989

90-
$data = json_decode($cached_string, true);
90+
$null_pos = strpos($cached_string, "\0");
91+
$data = json_decode(
92+
substr($cached_string, 0, $null_pos),
93+
true
94+
);
9195

9296
if ((isset($data['expiration']) && time() > $data['expiration']) || !isset($data['expiration'])) {
9397
shmop_delete($shm_id);

src/SplitIO/Sdk/Client.php

Lines changed: 7 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -168,37 +168,7 @@ private function doEvaluation($operation, $metricName, $key, $featureName, $attr
168168
}
169169

170170
/**
171-
* Returns the treatment to show this id for this feature.
172-
* The set of treatments for a feature can be configured
173-
* on the Split web console.
174-
* This method returns the string 'control' if:
175-
* <ol>
176-
* <li>Any of the parameters were null</li>
177-
* <li>There was an exception</li>
178-
* <li>The SDK does not know this feature</li>
179-
* <li>The feature was deleted through the web console.</li>
180-
* </ol>
181-
* 'control' is a reserved treatment, to highlight these
182-
* exceptional circumstances.
183-
*
184-
* <p>
185-
* The sdk returns the default treatment of this feature if:
186-
* <ol>
187-
* <li>The feature was killed</li>
188-
* <li>The id did not match any of the conditions in the
189-
* feature roll-out plan</li>
190-
* </ol>
191-
* The default treatment of a feature is set on the Split web
192-
* console.
193-
*
194-
* <p>
195-
* This method does not throw any exceptions.
196-
* It also never returns null.
197-
*
198-
* @param $key
199-
* @param $featureName
200-
* @param $attributes
201-
* @return string
171+
* @inheritdoc
202172
*/
203173
public function getTreatment($key, $featureName, array $attributes = null)
204174
{
@@ -218,42 +188,7 @@ public function getTreatment($key, $featureName, array $attributes = null)
218188
}
219189

220190
/**
221-
* Returns an object with the treatment to show this id for this feature
222-
* and the config provided.
223-
* The set of treatments and config for a feature can be configured
224-
* on the Split web console.
225-
* This method returns the string 'control' if:
226-
* <ol>
227-
* <li>Any of the parameters were null</li>
228-
* <li>There was an exception</li>
229-
* <li>The SDK does not know this feature</li>
230-
* <li>The feature was deleted through the web console.</li>
231-
* </ol>
232-
* 'control' is a reserved treatment, to highlight these
233-
* exceptional circumstances.
234-
*
235-
* <p>
236-
* The sdk returns the default treatment of this feature if:
237-
* <ol>
238-
* <li>The feature was killed</li>
239-
* <li>The id did not match any of the conditions in the
240-
* feature roll-out plan</li>
241-
* </ol>
242-
* The default treatment of a feature is set on the Split web
243-
* console.
244-
*
245-
* <p>
246-
* This method does not throw any exceptions.
247-
* It also never returns null.
248-
*
249-
* This method returns null configuration if:
250-
* <ol>
251-
* <li>config was not set up</li>
252-
* </ol>
253-
* @param $key
254-
* @param $featureName
255-
* @param $attributes
256-
* @return string
191+
* @inheritdoc
257192
*/
258193
public function getTreatmentWithConfig($key, $featureName, array $attributes = null)
259194
{
@@ -319,7 +254,7 @@ private function registerData($impressions, $attributes, $metricName, $latency =
319254
}
320255
} catch (\Exception $e) {
321256
SplitApp::logger()->critical(
322-
': An exception occured when trying to store impressions.'
257+
': An exception occurred when trying to store impressions.'
323258
);
324259
}
325260
}
@@ -388,35 +323,7 @@ private function doEvaluationForTreatments($operation, $metricName, $key, $featu
388323
}
389324

390325
/**
391-
* Returns an associative array which each key will be
392-
* the treatment result for each feature passed as parameter.
393-
* The set of treatments for a feature can be configured
394-
* on the Split web console.
395-
* This method returns the string 'control' if:
396-
* <ol>
397-
* <li>featureNames is invalid/li>
398-
* </ol>
399-
* 'control' is a reserved treatment, to highlight these
400-
* exceptional circumstances.
401-
*
402-
* <p>
403-
* The sdk returns the default treatment of this feature if:
404-
* <ol>
405-
* <li>The feature was killed</li>
406-
* <li>The id did not match any of the conditions in the
407-
* feature roll-out plan</li>
408-
* </ol>
409-
* The default treatment of a feature is set on the Split web
410-
* console.
411-
*
412-
* <p>
413-
* This method does not throw any exceptions.
414-
* It also never returns null.
415-
*
416-
* @param $key
417-
* @param $featureNames
418-
* @param $attributes
419-
* @return array|control
326+
* @inheritdoc
420327
*/
421328
public function getTreatments($key, $featureNames, array $attributes = null)
422329
{
@@ -434,44 +341,14 @@ function ($feature) {
434341
)
435342
);
436343
} catch (\Exception $e) {
437-
SplitApp::logger()->critical('getTreatmens method is throwing exceptions');
344+
SplitApp::logger()->critical('getTreatments method is throwing exceptions');
438345
$splitNames = InputValidator::validateFeatureNames($featureNames, 'getTreatments');
439346
return is_null($splitNames) ? array() : array_fill_keys($splitNames, TreatmentEnum::CONTROL);
440347
}
441348
}
442349

443350
/**
444-
* Returns an associative array which each key will be
445-
* the treatment result and the config for each
446-
* feature passed as parameter.
447-
* The set of treatments for a feature can be configured
448-
* on the Split web console and the config for
449-
* that treatment.
450-
* This method returns the string 'control' if:
451-
* <ol>
452-
* <li>featureNames is invalid/li>
453-
* </ol>
454-
* 'control' is a reserved treatment, to highlight these
455-
* exceptional circumstances.
456-
*
457-
* <p>
458-
* The sdk returns the default treatment of this feature if:
459-
* <ol>
460-
* <li>The feature was killed</li>
461-
* <li>The id did not match any of the conditions in the
462-
* feature roll-out plan</li>
463-
* </ol>
464-
* The default treatment of a feature is set on the Split web
465-
* console.
466-
*
467-
* <p>
468-
* This method does not throw any exceptions.
469-
* It also never returns null.
470-
*
471-
* @param $key
472-
* @param $featureNames
473-
* @param $attributes
474-
* @return array|control
351+
* @inheritdoc
475352
*/
476353
public function getTreatmentsWithConfig($key, $featureNames, array $attributes = null)
477354
{
@@ -492,18 +369,7 @@ public function getTreatmentsWithConfig($key, $featureNames, array $attributes =
492369
}
493370

494371
/**
495-
* A short-hand for
496-
* <pre>
497-
* (getTreatment(key, feature) == treatment) ? true : false;
498-
* </pre>
499-
*
500-
* This method never throws exceptions.
501-
* Instead of throwing exceptions, it returns false.
502-
*
503-
* @param $key
504-
* @param $featureName
505-
* @param $treatment
506-
* @return bool
372+
* @inheritdoc
507373
*/
508374
public function isTreatment($key, $featureName, $treatment)
509375
{

0 commit comments

Comments
 (0)