feat(flags): Implement local evaluation of flag dependencies#84
feat(flags): Implement local evaluation of flag dependencies#84
Conversation
And add flag dependencies examples.
688b756 to
9d9d69c
Compare
Update FeatureFlag.php Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
4ac3e4e to
42821f4
Compare
There was a problem hiding this comment.
Pull Request Overview
Implements local evaluation of feature flag dependencies in the PostHog PHP SDK, enabling complex conditional flags where one flag can depend on the value of another flag. This feature allows for more sophisticated feature rollout strategies and ensures flags can be evaluated locally without additional API calls.
- Adds comprehensive flag dependency evaluation logic with cycle detection
- Implements multivariate flag dependency support for complex chains
- Provides extensive test coverage for all dependency scenarios
Reviewed Changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/FeatureFlag.php | Core implementation of flag dependency evaluation with recursion and cycle detection |
| lib/Client.php | Integration of flag dependency context into client evaluation methods |
| test/FlagDependencyTest.php | Unit tests for flag dependency evaluation logic and edge cases |
| test/MultivariateIntegrationTest.php | Integration tests for multivariate flag dependencies |
| test/FlagDependencyIntegrationTest.php | End-to-end integration tests with client API |
| test/FeatureFlagLocalEvaluationTest.php | Updates existing tests to handle new flag dependency behavior |
| example.php | Enhanced examples demonstrating flag dependencies with interactive menu |
| README.md | Updated feature list to highlight flag dependencies |
| .env.example | Configuration template for running examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| public static function matchesDependencyValue($expectedValue, $actualValue) | ||
| { | ||
| // String variant case - check for exact match or boolean true | ||
| if (is_string($actualValue) && strlen($actualValue) > 0) { |
There was a problem hiding this comment.
The empty string check using strlen($actualValue) > 0 is less readable than $actualValue !== ''. Consider using the more explicit comparison for better code clarity.
| if (is_string($actualValue) && strlen($actualValue) > 0) { | |
| if (is_string($actualValue) && $actualValue !== '') { |
Implements local evaluation of flag dependencies. This is is based on the work done for posthog-python in: