Skip to content
Merged
Show file tree
Hide file tree
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
31 changes: 31 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,37 @@ jobs:
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=./build/logs/clover.xml -v

latest_dependency_tests:
name: Latest Deps (PHP ${{ matrix.php-versions }})
needs: [ linting ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: [ '8.1', '8.2' ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up PHP v${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Install latest supported dependencies
run: composer update justinrainbow/json-schema lastguest/murmurhash --with-dependencies
Comment thread
Mat001 marked this conversation as resolved.
- name: Verify latest majors resolved
run: |
php -r '
require "vendor/autoload.php";
$jsonSchema = Composer\InstalledVersions::getVersion("justinrainbow/json-schema");
$murmur = Composer\InstalledVersions::getVersion("lastguest/murmurhash");
echo "json-schema: $jsonSchema\nmurmurhash: $murmur\n";
exit((version_compare($jsonSchema, "6.0.0", ">=") && version_compare($murmur, "2.1.0", ">=")) ? 0 : 1);
'
- name: Run tests
run: |
mkdir -p ./build/logs
./vendor/bin/phpunit

integration_tests:
name: Integration Tests
needs: [ unit_tests ]
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"require": {
"php": ">=8.1",
"guzzlehttp/guzzle": ">=6.2",
"justinrainbow/json-schema": "^1.6 || ^2.0 || ^4.0 || ^5.0",
"lastguest/murmurhash": "^1.3.0",
"justinrainbow/json-schema": "^1.6 || ^2.0 || ^4.0 || ^5.0 || ^6.0",
Comment thread
Mat001 marked this conversation as resolved.
"lastguest/murmurhash": "^1.3.0 || ^2.1",
"monolog/monolog": ">=1.21"
},
"require-dev": {
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/Optimizely/Bucketer.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ public function __construct(LoggerInterface $logger)
*/
private function generateHashCode($bucketingKey)
{
return murmurhash3_int($bucketingKey, Bucketer::$HASH_SEED) & Bucketer::$UNSIGNED_MAX_32_BIT_VALUE;
// murmurhash v2 replaced the global function with a static class method
$hash = function_exists('murmurhash3_int')
? murmurhash3_int($bucketingKey, Bucketer::$HASH_SEED)
: \lastguest\Murmur::hash3_int($bucketingKey, Bucketer::$HASH_SEED);
return $hash & Bucketer::$UNSIGNED_MAX_32_BIT_VALUE;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/BucketerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ public function testGenerateBucketValue()
)
)
);
// Edge cases: empty string and multibyte UTF-8
$this->assertSame(
3175,
$generateBucketValueMethod->invoke(new Bucketer($this->loggerMock), '')
);
$this->assertSame(
8308,
$generateBucketValueMethod->invoke(new Bucketer($this->loggerMock), '日本語テスト1886780721')
);
}

public function testBucketValidExperimentNotInGroup()
Expand Down
Loading