Repository navigation
feat(flags): accept a caller default on FeatureFlagEvaluations::isEnabled() - #324
Merged
Merged
Conversation
…bled() The is-feature-enabled contract requires the SDK to accept a caller-supplied boolean default and return it whenever the flag has no value — unknown key, flags never loaded, failed request — while any value the flag does have, including false, wins over it. The snapshot's isEnabled() hardcoded false for every miss, so a genuinely disabled flag and a flag with no value at all were indistinguishable. Add an optional $defaultValue parameter, returned only when the snapshot holds no record for the key. The default stays false, so existing callers are unchanged. The deprecated Client::isFeatureEnabled() is left as is. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 8e05f524-d4d3-4802-be50-f997b9c60502
Contributor
posthog-php-socket Compliance ReportDate: 2026-11-19T00:44:10.994899+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
Contributor
posthog-php-fork_curl Compliance ReportDate: 2026-11-19T00:43:41.292705+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
Contributor
posthog-php-lib_curl Compliance ReportDate: 2026-11-19T00:44:02.586042+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
…lled event A missing key read with defaultValue true must still report a null $feature_flag_response and flag_missing, per evaluate-flags spec scenario "Supported caller defaults affect only missing enablement". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
turnipdabeets
marked this pull request as ready for review
November 19, 2026 00:40
turnipdabeets
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Brings posthog-php into compliance with the
is-feature-enabledcontract, which the weekly SDK compliance matrix flags as ❌ Fail for this SDK:A genuinely disabled flag and a flag with no value at all were indistinguishable, so callers who want a feature on while flags are unavailable had no way to express that.
🔨 What changed
FeatureFlagEvaluations::isEnabled()takes an optionalbool $defaultValue = false, returned only when the snapshot holds no record for the key — unknown flag, flags never loaded, a failed/flagsrequest, or a flag local evaluation left unresolved. A flag that has a value, includingfalse, still wins over the default.The deprecated
Client::isFeatureEnabled()/PostHog::isFeatureEnabled()facades are deliberately left alone: they are already marked@deprecatedin favour ofevaluateFlags(...)->isEnabled(...), which is the surface this change makes compliant.Backwards compatibility: purely additive. The parameter is optional and its default (
false) is the value the method returned for a miss before, so no existing call site changes behaviour. No deprecation path is needed.💚 How did you test it?
test/FeatureFlagEvaluationsTest.phpcovering the spec's scenarios: missing flags resolve to the caller default (trueandfalse), a flag value wins over the default (falseflag with defaulttrue, variant flag with defaultfalse), and unresolved / filtered-out flags take the default../vendor/bin/phpunit --bootstrap vendor/autoload.php --configuration phpunit.xml→ 2818 tests, 12581 assertions, 0 failures../vendor/bin/phpcs --standard=phpcs.xml --extensions=php lib test→ no new issues.composer api:updateregeneratedapi/public-api.json(the added optional parameter);composer api:checkpasses. The Laravel API snapshot is unaffected — it only coversPostHog\Laravel\symbols.pnpm change(minor).➡️ Follow-ups
openspec/specs/is-feature-enabled/spec.md's "Surface variants" table still documents the deprecated PHP signature without a default — worth refreshing in sdk-specs, which this PR intentionally does not touch.📝 Checklist
If releasing new changes
pnpm changeto generate a change intent file🤖 Agent context
Autonomy: Fully autonomous
Opened by a scheduled agent that reads the SDK compliance matrices in
PostHog/sdk-specsand implements one gap per run. This gap was picked over the other open candidates because its backwards-compatibility verdict is "backward-compatible" (additive), the contract is a core, widely used flag read, and the remediation is self-contained to a single method. Runner-up candidates — the identical default-value gap in posthog-go/-ruby/-dotnet, and the Logs and Traces contracts missing on several server SDKs — were left for future runs; Logs/Traces are whole subsystems rather than a scoped fix.Decision worth a reviewer's eye: the compliance note's remediation named the deprecated
Client::isFeatureEnabled(). That method was skipped on purpose, and the non-deprecated snapshot surface was fixed instead. If you want parity on the deprecated facade too, say so and it can be added.No manual end-to-end testing against a live PostHog project was performed — only the automated checks listed above.
Created with PostHog Desktop
🤖 Generated with Claude Code