Skip to content

Commit 81855fe

Browse files
committed
doc comment improvements
1 parent 118d4aa commit 81855fe

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

src/LaunchDarkly/LDClient.php

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ private function getFeatureRequester(string $sdkKey, array $options): FeatureReq
178178
* does not match any existing flag), `$defaultValue` is returned.
179179
*
180180
* @param string $key the unique key for the feature flag
181-
* @param LDContext|LDUser $context the evaluation context
181+
* @param LDContext|LDUser $context the evaluation context or user
182182
* @param mixed $defaultValue the default value of the flag
183-
* @return mixed the variation for the given context, or `$defaultValue` if the flag cannot be evaluated
183+
* @return mixed The variation for the given context, or `$defaultValue` if the flag cannot be evaluated
184184
* @see \LaunchDarkly\LDClient::variationDetail()
185185
*/
186186
public function variation(string $key, LDContext|LDUser $context, mixed $defaultValue = false): mixed
@@ -197,10 +197,10 @@ public function variation(string $key, LDContext|LDUser $context, mixed $default
197197
* detailed event data for this flag.
198198
*
199199
* @param string $key the unique key for the feature flag
200-
* @param LDContext|LDUser $context the evaluation context
200+
* @param LDContext|LDUser $context the evaluation context or user
201201
* @param mixed $defaultValue the default value of the flag
202202
*
203-
* @return EvaluationDetail an EvaluationDetail object that includes the feature flag value
203+
* @return EvaluationDetail An EvaluationDetail object that includes the feature flag value
204204
* and evaluation reason
205205
*/
206206
public function variationDetail(string $key, LDContext|LDUser $context, mixed $defaultValue = false): EvaluationDetail
@@ -295,14 +295,20 @@ public function isOffline(): bool
295295
}
296296

297297
/**
298-
* Tracks that a user performed an event.
298+
* Tracks that an application-defined event occurred.
299+
*
300+
* This method creates a "custom" analytics event containing the specified event name (key)
301+
* and context properties. You may attach arbitrary data or a metric value to the event with the
302+
* optional `data` and `metricValue` parameters.
303+
*
304+
* Note that event delivery is asynchronous, so the event may not actually be sent until later;
305+
* see {@see \LaunchDarkly\LDClient::flush()}.
299306
*
300307
* @param string $eventName The name of the event
301-
* @param LDContext|LDUser $context The evaluation context associated with the event
308+
* @param LDContext|LDUser $context The evaluation context or user associated with the event
302309
* @param mixed $data Optional additional information to associate with the event
303310
* @param int|float|null $metricValue A numeric value used by the LaunchDarkly experimentation feature in
304-
* numeric custom metrics. Can be omitted if this event is used by only non-numeric metrics. This
305-
* field will also be returned as part of the custom event for Data Export.
311+
* numeric custom metrics; can be omitted if this event is used by only non-numeric metrics
306312
*/
307313
public function track(string $eventName, LDContext|LDUser $context, mixed $data = null, int|float|null $metricValue = null): void
308314
{
@@ -315,12 +321,17 @@ public function track(string $eventName, LDContext|LDUser $context, mixed $data
315321
}
316322

317323
/**
318-
* Reports details about a user.
324+
* Reports details about an evaluation context or user.
325+
*
326+
* This method simply creates an analytics event containing the context properties, to
327+
* that LaunchDarkly will know about that context if it does not already.
319328
*
320-
* This simply registers the given user properties with LaunchDarkly without evaluating a feature flag.
321-
* This also happens automatically when you evaluate a flag.
329+
* Evaluating a flag, by calling {@see \LaunchDarkly\LDClient::variation()} or
330+
* {@see \LaunchDarkly\LDClient::variationDetail()} :func:`variation_detail()`, also sends
331+
* the context information to LaunchDarkly (if events are enabled), so you only need to use
332+
* identify() if you want to identify the context without evaluating a flag.
322333
*
323-
* @param LDContext|LDUser $context The user properties
334+
* @param LDContext|LDUser $context The context or user to register
324335
* @return void
325336
*/
326337
public function identify(LDContext|LDUser $context): void
@@ -342,7 +353,7 @@ public function identify(LDContext|LDUser $context): void
342353
*
343354
* This method does not send analytics events back to LaunchDarkly.
344355
*
345-
* @param LDContext|LDUser $context the evalation context
356+
* @param LDContext|LDUser $context the evalation context or user
346357
* @param array $options Optional properties affecting how the state is computed:
347358
* - `clientSideOnly`: Set this to true to specify that only flags marked for client-side use
348359
* should be included; by default, all flags are included
@@ -399,8 +410,8 @@ public function allFlagsState(LDContext|LDUser $context, array $options = []): F
399410
*
400411
* See: [Secure mode](https://docs.launchdarkly.com/sdk/features/secure-mode)
401412
*
402-
* @param LDContext|LDUser $context the evaluation context
403-
* @return string the hash value
413+
* @param LDContext|LDUser $context The evaluation context or user
414+
* @return string The hash value
404415
*/
405416
public function secureModeHash(LDContext|LDUser $context): string
406417
{

src/LaunchDarkly/LDContextBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function key(string $key): LDContextBuilder
9797
/**
9898
* Sets the context's kind attribute.
9999
*
100-
* Every LDContext has a kind. Setting it to an empty string or null is equivalent to
100+
* Every context has a kind. Setting it to an empty string or null is equivalent to
101101
* {@see \LaunchDarkly\LDContext::DEFAULT_KIND} ("user"). This value is case-sensitive.
102102
*
103103
* The meaning of the context kind is completely up to the application. Validation rules are

0 commit comments

Comments
 (0)