-
Notifications
You must be signed in to change notification settings - Fork 25
feat(flags): Implement local evaluation of flag dependencies #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: