Skip to content

Commit f1a319b

Browse files
Tamara-BarumclaudeCopilot
authored
[FSSDK-13266] Update dependency constraints for json-schema and murmurhash (#298)
* [FSSDK-13266] Update dependency constraints for json-schema and murmurhash Allow justinrainbow/json-schema v6.x and lastguest/murmurhash v2.x to support newer versions of these dependencies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [FSSDK-13266] Fix compatibility with murmurhash v2 and json-schema v6 murmurhash v2 removed the global murmurhash3_int() function in favor of a static class method. Add a function_exists() check to support both APIs. json-schema v6 deprecated check() in favor of validate(). Switch to the new method for forward compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [FSSDK-13266] Fix: Add check() fallback for older json-schema versions validate() does not exist in json-schema v1.6 and v2.x. Use method_exists() to call validate() when available and fall back to check() for older versions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add latest dependency CI coverage Co-authored-by: Tamara-Barum <88795935+Tamara-Barum@users.noreply.github.com> * Limit permissions for dependency CI job Co-authored-by: Tamara-Barum <88795935+Tamara-Barum@users.noreply.github.com> * [FSSDK-13266] Address PR review feedback - Fix Validator.php comment to accurately describe json-schema version history (validate() added in v5, check() deprecated in v6) - De-duplicate bitmask operation in Bucketer.php - Change murmurhash constraint from ^2.0 to ^2.1 (2.0.0 requires PHP 7) - Regenerate composer.lock to match updated constraints - Remove premature CHANGELOG 4.0.4 entry (belongs in release-prep PR) - Add CI job to test with latest dependency versions (PHP 8.1 + 8.2) with version assertion to verify v6/v2 actually resolved - Add edge-case bucketing test keys (empty string, UTF-8) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [FSSDK-13266] Fix: Split composer show into separate commands composer show does not accept multiple package names as positional arguments — the second name was parsed as a version constraint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [FSSDK-13266] Address alexjoeyyong review: simplify Validator and CI job - Revert Validator.php to use check() directly — it works in all allowed versions (1.6 through 6.x) and the v6 deprecation is docblock-only - Remove redundant composer install step from latest-deps CI job - Remove redundant composer show lines — the php -r gate already echoes and asserts the resolved versions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [FSSDK-13266] Add 4.0.4 CHANGELOG entry and tighten CI murmurhash gate Re-add the user-facing CHANGELOG entry and align the CI version check with the ^2.1 murmurhash constraint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [FSSDK-13266] Remove 4.0.4 CHANGELOG entry The release entry belongs in the separate release-prep PR alongside the SDK_VERSION bump. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent be16fd9 commit f1a319b

5 files changed

Lines changed: 55 additions & 11 deletions

File tree

‎.github/workflows/php.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,37 @@ jobs:
6464
composer global require php-coveralls/php-coveralls
6565
php-coveralls --coverage_clover=./build/logs/clover.xml -v
6666
67+
latest_dependency_tests:
68+
name: Latest Deps (PHP ${{ matrix.php-versions }})
69+
needs: [ linting ]
70+
runs-on: ubuntu-latest
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
php-versions: [ '8.1', '8.2' ]
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v3
78+
- name: Set up PHP v${{ matrix.php-versions }}
79+
uses: shivammathur/setup-php@v2
80+
with:
81+
php-version: ${{ matrix.php-versions }}
82+
- name: Install latest supported dependencies
83+
run: composer update justinrainbow/json-schema lastguest/murmurhash --with-dependencies
84+
- name: Verify latest majors resolved
85+
run: |
86+
php -r '
87+
require "vendor/autoload.php";
88+
$jsonSchema = Composer\InstalledVersions::getVersion("justinrainbow/json-schema");
89+
$murmur = Composer\InstalledVersions::getVersion("lastguest/murmurhash");
90+
echo "json-schema: $jsonSchema\nmurmurhash: $murmur\n";
91+
exit((version_compare($jsonSchema, "6.0.0", ">=") && version_compare($murmur, "2.1.0", ">=")) ? 0 : 1);
92+
'
93+
- name: Run tests
94+
run: |
95+
mkdir -p ./build/logs
96+
./vendor/bin/phpunit
97+
6798
integration_tests:
6899
name: Integration Tests
69100
needs: [ unit_tests ]

‎composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"require": {
1818
"php": ">=8.1",
1919
"guzzlehttp/guzzle": ">=6.2",
20-
"justinrainbow/json-schema": "^1.6 || ^2.0 || ^4.0 || ^5.0",
21-
"lastguest/murmurhash": "^1.3.0",
20+
"justinrainbow/json-schema": "^1.6 || ^2.0 || ^4.0 || ^5.0 || ^6.0",
21+
"lastguest/murmurhash": "^1.3.0 || ^2.1",
2222
"monolog/monolog": ">=1.21"
2323
},
2424
"require-dev": {

‎composer.lock‎

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/Optimizely/Bucketer.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ public function __construct(LoggerInterface $logger)
7272
*/
7373
private function generateHashCode($bucketingKey)
7474
{
75-
return murmurhash3_int($bucketingKey, Bucketer::$HASH_SEED) & Bucketer::$UNSIGNED_MAX_32_BIT_VALUE;
75+
// murmurhash v2 replaced the global function with a static class method
76+
$hash = function_exists('murmurhash3_int')
77+
? murmurhash3_int($bucketingKey, Bucketer::$HASH_SEED)
78+
: \lastguest\Murmur::hash3_int($bucketingKey, Bucketer::$HASH_SEED);
79+
return $hash & Bucketer::$UNSIGNED_MAX_32_BIT_VALUE;
7680
}
7781

7882
/**

‎tests/BucketerTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ public function testGenerateBucketValue()
8888
)
8989
)
9090
);
91+
// Edge cases: empty string and multibyte UTF-8
92+
$this->assertSame(
93+
3175,
94+
$generateBucketValueMethod->invoke(new Bucketer($this->loggerMock), '')
95+
);
96+
$this->assertSame(
97+
8308,
98+
$generateBucketValueMethod->invoke(new Bucketer($this->loggerMock), '日本語テスト1886780721')
99+
);
91100
}
92101

93102
public function testBucketValidExperimentNotInGroup()

0 commit comments

Comments
 (0)