Skip to content

Commit 785890a

Browse files
authored
use phpDocumentor 3 + misc doc comment cleanup (#68)
1 parent b8d539a commit 785890a

19 files changed

+106
-90
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ composer.phar
77
integration-tests/vendor
88
composer.lock
99
docs/build
10+
docs/.phpdoc
1011
.phpunit.result.cache

.ldrelease/build-docs.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22

3+
# This script assumes that it is running in a Docker container using the image
4+
# "ldcircleci/php-sdk-release", defined in https://github.com/launchdarkly/sdks-ci-docker
5+
36
set -e
47

58
cd docs
6-
make PHPDOC_ARCHIVE=/home/circleci/ldtools/phpDocumentor.phar # provided in ldcircleci/ld-php-sdk-release image
9+
make

.ldrelease/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publications:
88

99
circleci:
1010
linux:
11-
image: ldcircleci/ld-php-sdk-release:1 # built in sdks-ci-docker project, contains PHP 7.2 + phpDocumentor
11+
image: ldcircleci/php-sdk-release:1 # built in sdks-ci-docker project, contains PHP 7.3 + phpDocumentor 3
1212

1313
documentation:
1414
githubPages: true

docs/Makefile

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11

2-
# PHPDOC_ARCHIVE is overridden in the CircleCI release
3-
PHPDOC_ARCHIVE := $(shell pwd)/build/phpDocumentor.phar
4-
OUTPUT_DIR := $(shell pwd)/build
5-
PHPDOC_URL=https://www.phpdoc.org/phpDocumentor.phar
2+
SOURCE_DIR = $(shell cd .. && pwd)
3+
PHPDOCUMENTOR = php $(LDTOOLS_DIR)/php/phpDocumentor.phar
64

7-
.PHONY: install html
5+
.PHONY: html
86

9-
html: install
7+
html:
108
rm -rf build/temp build/html
11-
cd .. && php $(PHPDOC_ARCHIVE) --visibility public --title "LaunchDarkly PHP SDK ${LD_RELEASE_VERSION}"
12-
13-
install: $(PHPDOC_ARCHIVE)
14-
15-
$(PHPDOC_ARCHIVE):
16-
mkdir -p build
17-
cd build && unzip ../lib/phpDocumentor.phar.zip
9+
$(PHPDOCUMENTOR) \
10+
-d $(SOURCE_DIR) \
11+
-t build/html \
12+
--ignore vendor/ \
13+
--ignore tests/ \
14+
--ignore docs/ \
15+
--ignore src/LaunchDarkly/Impl \
16+
--visibility public \
17+
--defaultpackagename "SDK" \
18+
--title "LaunchDarkly PHP SDK ${LD_RELEASE_VERSION}"

src/LaunchDarkly/EvaluationDetail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* An object that combines the result of a flag evaluation with an explanation of how it was calculated.
99
*
10-
* This is returned by {@link \LaunchDarkly\LDClient::variationDetail()}.
10+
* This is returned by {@see \LaunchDarkly\LDClient::variationDetail()}.
1111
*/
1212
class EvaluationDetail
1313
{

src/LaunchDarkly/EvaluationReason.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Describes the reason that a flag evaluation produced a particular value.
77
*
8-
* This is part of the {@link \LaunchDarkly\EvaluationDetail} object returned by {@link \LaunchDarkly\LDClient::variationDetail()}.
8+
* This is part of the {@see \LaunchDarkly\EvaluationDetail} object returned by {@see \LaunchDarkly\LDClient::variationDetail()}.
99
*/
1010
class EvaluationReason implements \JsonSerializable
1111
{

src/LaunchDarkly/EventPublisher.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
/**
55
* Interface for the component that sends events to the LaunchDarkly service.
66
*
7-
* The default implementation is {@link \LaunchDarkly\Integrations\Curl::eventPublisher()}. The SDK also
8-
* provides {@link \LaunchDarkly\Integrations\Guzzle::eventPublisher()}.
7+
* The default implementation is {@see \LaunchDarkly\Integrations\Curl::eventPublisher()}. The SDK also
8+
* provides {@see \LaunchDarkly\Integrations\Guzzle::eventPublisher()}.
99
*/
1010
interface EventPublisher
1111
{
12-
/** @var int */
12+
/**
13+
* @var int
14+
* @ignore
15+
*/
1316
const CURRENT_SCHEMA_VERSION = 2;
1417

1518
/**

src/LaunchDarkly/FeatureFlagsState.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
namespace LaunchDarkly;
33

44
use LaunchDarkly\Impl\Model\FeatureFlag;
5+
use LaunchDarkly\LDClient;
56

67
/**
78
* A snapshot of the state of all feature flags with regard to a specific user.
89
*
9-
* This is generated by calling {@link \LaunchDarkly\LDClient::allFlagsState()}.
10+
* This is generated by calling {@see \LaunchDarkly\LDClient::allFlagsState()}.
1011
*
1112
* Serializing this object to JSON using json_encode(), or the jsonSerialize() method, will produce the
1213
* appropriate data structure for bootstrapping the LaunchDarkly JavaScript client. See the SDK
@@ -87,11 +88,12 @@ public function getFlagValue(string $key)
8788
}
8889

8990
/**
90-
* Returns the evaluation reason for an individual feature flag (as returned by LDClient.variationDetail())
91+
* Returns the evaluation reason for an individual feature flag (as returned by variationDetail())
9192
* at the time the state was recorded.
9293
* @param string $key the feature flag key
9394
* @return EvaluationReason|null the evaluation reason; null if reasons were not recorded, or if there
9495
* was no such flag
96+
* @see \LaunchDarkly\LDClient::variationDetail()
9597
*/
9698
public function getFlagReason(string $key): ?EvaluationReason
9799
{
@@ -103,9 +105,10 @@ public function getFlagReason(string $key): ?EvaluationReason
103105
}
104106

105107
/**
106-
* Returns an associative array of flag keys to flag values. If a flag would have evaluated to the default
107-
* value, its value will be null.
108-
* <p>
108+
* Returns an associative array of flag keys to flag values.
109+
*
110+
* If a flag would have evaluated to the default value, its value will be null.
111+
*
109112
* Do not use this method if you are passing data to the front end to "bootstrap" the JavaScript client.
110113
* Instead, use jsonSerialize().
111114
* @return array an associative array of flag keys to JSON values
@@ -117,9 +120,10 @@ public function toValuesMap(): array
117120

118121
/**
119122
* Returns a JSON representation of the entire state map (as an associative array), in the format used
120-
* by the LaunchDarkly JavaScript SDK. Use this method if you are passing data to the front end in
121-
* order to "bootstrap" the JavaScript client.
122-
* <p>
123+
* by the LaunchDarkly JavaScript SDK.
124+
*
125+
* Use this method if you are passing data to the front end in order to "bootstrap" the JavaScript client.
126+
*
123127
* Note that calling json_encode() on a FeatureFlagsState object will automatically use the
124128
* jsonSerialize() method.
125129
* @return array an associative array suitable for passing as a JSON object

src/LaunchDarkly/FeatureRequester.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Interface for the component that retrieves feature flag data.
99
*
10-
* The default implementation is {@link \LaunchDarkly\Integrations\Guzzle::featureRequester()}, which requests
10+
* The default implementation is {@see \LaunchDarkly\Integrations\Guzzle::featureRequester()}, which requests
1111
* flags inefficiently via HTTP on demand. For other implementations, including database integrations, see the
1212
* LaunchDarkly\Integrations namespace.
1313
*/

src/LaunchDarkly/Impl/Integrations/FeatureRequesterBase.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ protected function __construct(string $baseUri, string $sdkKey, array $options)
4242
/**
4343
* Override this method to read a JSON object (as a string) from the underlying store.
4444
*
45-
* @param $namespace "features" or "segments"
46-
* @param $key flag or segment key
45+
* @param string $namespace "features" or "segments"
46+
* @param string $key flag or segment key
4747
* @return string|null the stored JSON data, or null if not found
4848
*/
4949
protected function readItemString(string $namespace, string $key): ?string
@@ -54,7 +54,7 @@ protected function readItemString(string $namespace, string $key): ?string
5454
/**
5555
* Override this method to read a set of JSON objects (as strings) from the underlying store.
5656
*
57-
* @param $namespace "features" or "segments"
57+
* @param string $namespace "features" or "segments"
5858
* @return array|null array of stored JSON strings
5959
*/
6060
protected function readItemStringList(string $namespace): ?array
@@ -76,7 +76,7 @@ protected function createCache(array $options): ?FeatureRequesterCache
7676
/**
7777
* Gets an individual feature flag.
7878
*
79-
* @param $key string feature flag key
79+
* @param string $key feature flag key
8080
* @return FeatureFlag|null The decoded JSON feature data, or null if missing
8181
*/
8282
public function getFeature(string $key): ?FeatureFlag
@@ -98,7 +98,7 @@ public function getFeature(string $key): ?FeatureFlag
9898
/**
9999
* Gets an individual user segment.
100100
*
101-
* @param $key string segment key
101+
* @param string $key segment key
102102
* @return Segment|null The decoded JSON segment data, or null if missing
103103
*/
104104
public function getSegment(string $key): ?Segment

src/LaunchDarkly/Impl/Integrations/FeatureRequesterCache.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ interface FeatureRequesterCache
66
/**
77
* Read a value from the cache.
88
*
9-
* @param $cacheKey the unique key
9+
* @param string $cacheKey the unique key
1010
* @return string the cached value, or null if not found
1111
*/
1212
public function getCachedString(string $cacheKey): ?string;
1313

1414
/**
1515
* Store a value in the cache.
1616
*
17-
* @param $cacheKey the unique key
18-
* @param $data the string value
17+
* @param string $cacheKey the unique key
18+
* @param string $data the string value
1919
*/
2020
public function putCachedString(string $cacheKey, ?string $data): void;
2121
}

src/LaunchDarkly/Impl/Integrations/GuzzleFeatureRequester.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(string $baseUri, string $sdkKey, array $options)
6060
/**
6161
* Gets feature data from a likely cached store
6262
*
63-
* @param $key string feature key
63+
* @param string $key feature key
6464
* @return FeatureFlag|null The decoded FeatureFlag, or null if missing
6565
*/
6666
public function getFeature(string $key): ?FeatureFlag
@@ -83,7 +83,7 @@ public function getFeature(string $key): ?FeatureFlag
8383
/**
8484
* Gets segment data from a likely cached store
8585
*
86-
* @param $key string segment key
86+
* @param string $key segment key
8787
* @return Segment|null The decoded Segment, or null if missing
8888
*/
8989
public function getSegment(string $key): ?Segment

src/LaunchDarkly/Impl/PreloadedFeatureRequester.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(FeatureRequester $baseRequester, array $knownFeature
2828
/**
2929
* Gets feature data from cached values
3030
*
31-
* @param $key feature key
31+
* @param string $key feature key
3232
* @return FeatureFlag|null The decoded FeatureFlag, or null if missing
3333
*/
3434
public function getFeature(string $key): ?FeatureFlag
@@ -42,7 +42,7 @@ public function getFeature(string $key): ?FeatureFlag
4242
/**
4343
* Gets segment data from the regular feature requester
4444
*
45-
* @param $key segment key
45+
* @param string $key segment key
4646
* @return Segment|null The decoded Segment, or null if missing
4747
*/
4848
public function getSegment(string $key): ?Segment

src/LaunchDarkly/Impl/SemanticVersion.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public function __construct(
4545

4646
/**
4747
* Attempts to parse a string as a semantic version.
48-
* @param $input string the input string
49-
* @param $loose boolean true if minor and patch versions can be omitted
48+
* @param string $input the input string
49+
* @param bool $loose true if minor and patch versions can be omitted
5050
* @throws \InvalidArgumentException if the string is not in an acceptable format
5151
*/
5252
public static function parse(string $input, bool $loose = false): SemanticVersion
@@ -67,7 +67,7 @@ public static function parse(string $input, bool $loose = false): SemanticVersio
6767

6868
/**
6969
* Compares this version to another version using Semantic Versioning precedence rules.
70-
* @param $other a SemanticVersion object
70+
* @param SemanticVersion $other a SemanticVersion object
7171
* @return int -1 if this version has lower precedence than the other version; 1 if this version
7272
* has higher precedence; zero if the two have equal precedence
7373
*/

src/LaunchDarkly/Integrations/Curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Curl
2121
* $client = new LDClient("sdk_key", $config);
2222
*
2323
* This implementation forks a process for each event payload. Alternatively, you can use
24-
* {@link \LaunchDarkly\Integrations\Guzzle::eventPublisher()}, which makes synchronous requests.
24+
* {@see \LaunchDarkly\Integrations\Guzzle::eventPublisher()}, which makes synchronous requests.
2525
*
2626
* @param array $options Configuration settings (can also be passed in the main client configuration):
2727
* - `curl`: command for executing `curl`; defaults to `/usr/bin/env curl`

src/LaunchDarkly/Integrations/Guzzle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function featureRequester($options = array())
3333
/**
3434
* Configures an adapter for sending analytics events to LaunchDarkly using GuzzleHttp.
3535
*
36-
* The default mechanism for sending events is {@link \LaunchDarkly\Integrations\Curl::eventPublisher()}.
36+
* The default mechanism for sending events is {@see \LaunchDarkly\Integrations\Curl::eventPublisher()}.
3737
* To use Guzzle instead, call this method and store its return value in the `event_publisher` property
3838
* of the client configuration:
3939
*

src/LaunchDarkly/LDClient.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,30 @@ class LDClient
5555
*
5656
* @param string $sdkKey The SDK key for your account
5757
* @param array $options Client configuration settings
58-
* - `base_uri`: Base URI of the LaunchDarkly service. Change this if you are connecting to a Relay Proxy instance instead of
58+
* - `base_uri`: Base URI of the LaunchDarkly service. Change this if you are connecting to a Relay Proxy instance instead of
5959
* directly to LaunchDarkly.
60-
* - `events_uri`: Base URI for sending events to LaunchDarkly. Change this if you are forwarding events through a Relay Proxy instance.
61-
* - `timeout`: The maximum length of an HTTP request in seconds. Defaults to 3.
62-
* - `connect_timeout`: The maximum number of seconds to wait while trying to connect to a server. Defaults to 3.
63-
* - `cache`: An optional implementation of Guzzle's [CacheStorageInterface](https://github.com/Kevinrob/guzzle-cache-middleware/blob/master/src/Storage/CacheStorageInterface.php).
60+
* - `events_uri`: Base URI for sending events to LaunchDarkly. Change this if you are forwarding events through a Relay Proxy instance.
61+
* - `timeout`: The maximum length of an HTTP request in seconds. Defaults to 3.
62+
* - `connect_timeout`: The maximum number of seconds to wait while trying to connect to a server. Defaults to 3.
63+
* - `cache`: An optional implementation of Guzzle's [CacheStorageInterface](https://github.com/Kevinrob/guzzle-cache-middleware/blob/master/src/Storage/CacheStorageInterface.php).
6464
* Defaults to an in-memory cache.
65-
* - `send_events`: If set to false, disables the sending of events to LaunchDarkly. Defaults to true.
66-
* - `logger`: An optional implementation of [Psr\Log\LoggerInterface](https://www.php-fig.org/psr/psr-3/). Defaults to a
65+
* - `send_events`: If set to false, disables the sending of events to LaunchDarkly. Defaults to true.
66+
* - `logger`: An optional implementation of [Psr\Log\LoggerInterface](https://www.php-fig.org/psr/psr-3/). Defaults to a
6767
* Monolog\Logger sending all messages to the PHP error_log.
68-
* - `offline`: If set to true, disables all network calls and always returns the default value for flags. Defaults to false.
69-
* - `feature_requester`: An optional {@link \LaunchDarkly\FeatureRequester} implementation, or a class or factory for one.
70-
* Defaults to {@link \LaunchDarkly\Integrations\Guzzle::featureRequester()}.
71-
* - `feature_requester_class`: Deprecated, equivalent to feature_requester.
72-
* - `event_publisher`: An optional {@link \LaunchDarkly\EventPublisher} implementation, or a class or factory for one.
73-
* Defaults to {@link \LaunchDarkly\Integrations\Curl::eventPublisher()}.
74-
* - `event_publisher_class`: Deprecated, equivalent to event_publisher.
75-
* - `all_attributes_private`: If set to true, no user attributes (other than the key) will be sent back to LaunchDarkly.
68+
* - `offline`: If set to true, disables all network calls and always returns the default value for flags. Defaults to false.
69+
* - `feature_requester`: An optional {@see \LaunchDarkly\FeatureRequester} implementation, or a class or factory for one.
70+
* Defaults to {@see \LaunchDarkly\Integrations\Guzzle::featureRequester()}. There are also optional packages providing
71+
* database integrations; see [Storing data](https://docs.launchdarkly.com/sdk/features/storing-data#php).
72+
* - `feature_requester_class`: Deprecated, equivalent to feature_requester.
73+
* - `event_publisher`: An optional {@see \LaunchDarkly\EventPublisher} implementation, or a class or factory for one.
74+
* Defaults to {@see \LaunchDarkly\Integrations\Curl::eventPublisher()}.
75+
* - `event_publisher_class`: Deprecated, equivalent to event_publisher.
76+
* - `all_attributes_private`: If set to true, no user attributes (other than the key) will be sent back to LaunchDarkly.
7677
* Defaults to false.
77-
* - `private_attribute_names`: An optional array of user attribute names to be marked private. Any users sent to LaunchDarkly
78+
* - `private_attribute_names`: An optional array of user attribute names to be marked private. Any users sent to LaunchDarkly
7879
* with this configuration active will have attributes with these names removed. You can also set private attributes on a
7980
* per-user basis in LDUserBuilder.
80-
* - Other options may be available depending on any features you are using from the LaunchDarkly\Integrations namespace.
81+
* - Other options may be available depending on any features you are using from the `LaunchDarkly\Integrations` namespace.
8182
*
8283
* @return LDClient
8384
*/
@@ -327,16 +328,16 @@ public function identify(LDUser $user): void
327328
* Returns an object that encapsulates the state of all feature flags for a given user.
328329
*
329330
* This includes the flag values as well as other flag metadata that may be needed by front-end code,
330-
* since the most common use case for this method is [bootstrapping](https://docs.launchdarkly.com/docs/js-sdk-reference#section-bootstrapping)
331+
* since the most common use case for this method is [bootstrapping](https://docs.launchdarkly.com/sdk/features/bootstrapping)
331332
* in conjunction with the JavaScript browser SDK.
332333
*
333334
* This method does not send analytics events back to LaunchDarkly.
334335
*
335336
* @param LDUser $user The end user requesting the feature flags
336337
* @param array $options Optional properties affecting how the state is computed:
337-
* - `clientSideOnly`: Set this to true to specify that only flags marked for client-side use
338+
* - `clientSideOnly`: Set this to true to specify that only flags marked for client-side use
338339
* should be included; by default, all flags are included
339-
* - `withReasons`: Set this to true to include evaluation reasons (see {@link variationDetail()})
340+
* - `withReasons`: Set this to true to include evaluation reasons (see {@see \LaunchDarkly\LDClient::variationDetail()})
340341
* @return FeatureFlagsState a FeatureFlagsState object (will never be null)
341342
*/
342343
public function allFlagsState(LDUser $user, array $options = array()): FeatureFlagsState
@@ -406,7 +407,7 @@ public function alias(LDUser $user, LDUser $previousUser): void
406407
/**
407408
* Generates an HMAC sha256 hash for use in Secure mode.
408409
*
409-
* See: https://docs.launchdarkly.com/docs/js-sdk-reference#section-secure-mode
410+
* See: [Secure mode](https://docs.launchdarkly.com/sdk/features/secure-mode)
410411
*/
411412
public function secureModeHash(LDUser $user): string
412413
{

src/LaunchDarkly/LDUser.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* The only mandatory property property is the key, which must uniquely identify each user. For authenticated users,
88
* this may be a username or e-mail address. For anonymous users, it could be an IP address or session ID.
99
*
10-
* Use {@link \LaunchDarkly\LDUserBuilder} to construct instances of this class.
10+
* Use {@see \LaunchDarkly\LDUserBuilder} to construct instances of this class.
1111
*/
1212
class LDUser
1313
{
@@ -48,7 +48,9 @@ class LDUser
4848
protected $_privateAttributeNames = array();
4949

5050
/**
51-
* Constructor for directly creating an instance; it is preferable to use LDUserBuilder.
51+
* Constructor for directly creating an instance.
52+
*
53+
* It is preferable to use {@see LDUserBuilder} instead of this constructor.
5254
*
5355
* @param string $key Unique key for the user. For authenticated users, this may be a username or e-mail address. For anonymous users, this could be an IP address or session ID.
5456
* @param string|null $secondary An optional secondary identifier

0 commit comments

Comments
 (0)