Skip to content

Commit 04b70b6

Browse files
committed
Update phpdoc
1 parent acedf14 commit 04b70b6

9 files changed

+54
-4
lines changed

plugins/optimization-detective/class-od-link-collection.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ final class OD_Link_Collection implements Countable {
4343
/**
4444
* Links grouped by rel type.
4545
*
46+
* @since 0.4.0
47+
*
4648
* @var array<string, Link[]>
4749
*/
4850
private $links_by_rel = array();
4951

5052
/**
5153
* Adds link.
5254
*
55+
* @since 0.3.0
56+
*
5357
* @phpstan-param LinkAttributes $attributes
5458
*
5559
* @param array $attributes Attributes.
@@ -110,6 +114,8 @@ public function add_link( array $attributes, ?int $minimum_viewport_width = null
110114
* When two links are identical except for their minimum/maximum widths which are also consecutive, then merge them
111115
* together. Also, add media attributes to the links.
112116
*
117+
* @since 0.4.0
118+
*
113119
* @return LinkAttributes[] Prepared links with adjacent-duplicates merged together and media attributes added.
114120
*/
115121
private function get_prepared_links(): array {
@@ -132,6 +138,8 @@ function ( array $links ): array {
132138
/**
133139
* Merges consecutive links.
134140
*
141+
* @since 0.4.0
142+
*
135143
* @param Link[] $links Links.
136144
* @return LinkAttributes[] Merged consecutive links.
137145
*/
@@ -227,6 +235,8 @@ static function ( array $link ): array {
227235
/**
228236
* Gets the HTML for the link tags.
229237
*
238+
* @since 0.3.0
239+
*
230240
* @return string Link tags HTML.
231241
*/
232242
public function get_html(): string {
@@ -248,6 +258,8 @@ public function get_html(): string {
248258
/**
249259
* Constructs the Link HTTP response header.
250260
*
261+
* @since 0.4.0
262+
*
251263
* @return non-empty-string|null Link HTTP response header, or null if there are none.
252264
*/
253265
public function get_response_header(): ?string {
@@ -301,6 +313,8 @@ static function ( $matches ) {
301313
/**
302314
* Counts the links.
303315
*
316+
* @since 0.3.0
317+
*
304318
* @return non-negative-int Link count.
305319
*/
306320
public function count(): int {

plugins/optimization-detective/class-od-tag-visitor-registry.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@ final class OD_Tag_Visitor_Registry implements Countable, IteratorAggregate {
2626
/**
2727
* Visitors.
2828
*
29+
* @since 0.3.0
30+
*
2931
* @var array<non-empty-string, TagVisitorCallback>
3032
*/
3133
private $visitors = array();
3234

3335
/**
3436
* Registers a tag visitor.
3537
*
38+
* @since 0.3.0
39+
*
3640
* @phpstan-param TagVisitorCallback $tag_visitor_callback
3741
*
3842
* @param non-empty-string $id Identifier for the tag visitor.
@@ -45,6 +49,8 @@ public function register( string $id, callable $tag_visitor_callback ): void {
4549
/**
4650
* Determines if a visitor has been registered.
4751
*
52+
* @since 0.3.0
53+
*
4854
* @param non-empty-string $id Identifier for the tag visitor.
4955
* @return bool Whether registered.
5056
*/
@@ -55,6 +61,8 @@ public function is_registered( string $id ): bool {
5561
/**
5662
* Gets a registered visitor.
5763
*
64+
* @since 0.3.0
65+
*
5866
* @param non-empty-string $id Identifier for the tag visitor.
5967
* @return TagVisitorCallback|null Whether registered.
6068
*/
@@ -68,6 +76,8 @@ public function get_registered( string $id ): ?callable {
6876
/**
6977
* Unregisters a tag visitor.
7078
*
79+
* @since 0.3.0
80+
*
7181
* @param non-empty-string $id Identifier for the tag visitor.
7282
* @return bool Whether a tag visitor was unregistered.
7383
*/
@@ -82,6 +92,8 @@ public function unregister( string $id ): bool {
8292
/**
8393
* Returns an iterator for the URL Metrics in the group.
8494
*
95+
* @since 0.3.0
96+
*
8597
* @return ArrayIterator<string, TagVisitorCallback> ArrayIterator for tag visitors.
8698
*/
8799
public function getIterator(): ArrayIterator {
@@ -91,6 +103,8 @@ public function getIterator(): ArrayIterator {
91103
/**
92104
* Counts the URL Metrics in the group.
93105
*
106+
* @since 0.3.0
107+
*
94108
* @return int<0, max> URL Metric count.
95109
*/
96110
public function count(): int {

plugins/optimization-detective/class-od-url-metric-group-collection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ final class OD_URL_Metric_Group_Collection implements Countable, IteratorAggrega
3030
* even to when there are zero breakpoints: there will still be one group
3131
* in this case, in which every single URL Metric is added.
3232
*
33+
* @since 0.1.0
3334
* @var OD_URL_Metric_Group[]
3435
* @phpstan-var non-empty-array<OD_URL_Metric_Group>
3536
*/
@@ -53,13 +54,15 @@ final class OD_URL_Metric_Group_Collection implements Countable, IteratorAggrega
5354
* This array may be empty in which case there are no responsive breakpoints and all URL Metrics are collected in a
5455
* single group.
5556
*
57+
* @since 0.1.0
5658
* @var positive-int[]
5759
*/
5860
private $breakpoints;
5961

6062
/**
6163
* Sample size for URL Metrics for a given breakpoint.
6264
*
65+
* @since 0.1.0
6366
* @var int<1, max>
6467
*/
6568
private $sample_size;
@@ -69,13 +72,15 @@ final class OD_URL_Metric_Group_Collection implements Countable, IteratorAggrega
6972
*
7073
* A freshness age of zero means a URL Metric will always be considered stale.
7174
*
75+
* @since 0.1.0
7276
* @var int<0, max>
7377
*/
7478
private $freshness_ttl;
7579

7680
/**
7781
* Result cache.
7882
*
83+
* @since 0.3.0
7984
* @var array{
8085
* get_group_for_viewport_width?: array<int, OD_URL_Metric_Group>,
8186
* is_every_group_populated?: bool,
@@ -93,6 +98,8 @@ final class OD_URL_Metric_Group_Collection implements Countable, IteratorAggrega
9398
/**
9499
* Constructor.
95100
*
101+
* @since 0.1.0
102+
*
96103
* @throws InvalidArgumentException When an invalid argument is supplied.
97104
*
98105
* @phpstan-param positive-int[] $breakpoints

plugins/optimization-detective/class-od-url-metric-group.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ final class OD_URL_Metric_Group implements IteratorAggregate, Countable, JsonSer
9494
*
9595
* This class should never be directly constructed. It should only be constructed by the {@see OD_URL_Metric_Group_Collection::create_groups()}.
9696
*
97+
* @since 0.1.0
98+
*
9799
* @access private
98100
* @throws InvalidArgumentException If arguments are invalid.
99101
*

plugins/optimization-detective/class-od-url-metric.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ class OD_URL_Metric implements JsonSerializable {
6666
/**
6767
* Data.
6868
*
69+
* @since 0.1.0
6970
* @var Data
7071
*/
7172
protected $data;
7273

7374
/**
7475
* Elements.
7576
*
77+
* @since 0.7.0
7678
* @var OD_Element[]
7779
*/
7880
protected $elements;
@@ -88,6 +90,8 @@ class OD_URL_Metric implements JsonSerializable {
8890
/**
8991
* Constructor.
9092
*
93+
* @since 0.1.0
94+
*
9195
* @phpstan-param Data|array<string, mixed> $data Valid data or invalid data (in which case an exception is thrown).
9296
*
9397
* @throws OD_Data_Validation_Exception When the input is invalid.
@@ -104,6 +108,8 @@ public function __construct( array $data ) {
104108
/**
105109
* Prepares data with validation and sanitization.
106110
*
111+
* @since 0.6.0
112+
*
107113
* @throws OD_Data_Validation_Exception When the input is invalid.
108114
*
109115
* @param array<string, mixed> $data Data to validate.
@@ -349,7 +355,6 @@ public static function get_json_schema(): array {
349355
* @param array<string, mixed> $properties_schema Properties schema to extend.
350356
* @param array<string, mixed> $additional_properties Additional properties.
351357
* @param string $filter_name Filter name used to extend.
352-
*
353358
* @return array<string, mixed> Extended schema.
354359
*/
355360
protected static function extend_schema_with_optional_properties( array $properties_schema, array $additional_properties, string $filter_name ): array {

plugins/optimization-detective/class-od-visited-tag-state.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ final class OD_Visited_Tag_State {
3030

3131
/**
3232
* Constructor.
33+
*
34+
* @since 1.0.0
3335
*/
3436
public function __construct() {
3537
$this->reset();

plugins/optimization-detective/storage/class-od-storage-lock.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ final class OD_Storage_Lock {
2424
* Capability for being able to store a URL Metric now.
2525
*
2626
* @since n.e.x.t
27-
* @access private
2827
* @var string
2928
*/
3029
const STORE_URL_METRIC_NOW_CAPABILITY = 'od_store_url_metric_now';
@@ -33,7 +32,6 @@ final class OD_Storage_Lock {
3332
* Adds hooks.
3433
*
3534
* @since n.e.x.t
36-
* @access private
3735
*/
3836
public static function add_hooks(): void {
3937
add_filter( 'user_has_cap', array( __CLASS__, 'filter_user_has_cap' ) );
@@ -43,7 +41,6 @@ public static function add_hooks(): void {
4341
* Filters `user_has_cap` to grant the `od_store_url_metric_now` capability to users who can `manage_options` by default.
4442
*
4543
* @since n.e.x.t
46-
* @access private
4744
*
4845
* @param array<string, bool>|mixed $allcaps Capability names mapped to boolean values for whether the user has that capability.
4946
* @return array<string, bool> Capability names mapped to boolean values for whether the user has that capability.
@@ -94,6 +91,8 @@ public static function get_ttl(): int {
9491
/**
9592
* Gets transient key for locking URL Metric storage (for the current IP).
9693
*
94+
* @since 0.1.0
95+
*
9796
* @todo Should the URL be included in the key? Or should a user only be allowed to store one metric?
9897
* @return non-empty-string Transient key.
9998
*/

plugins/optimization-detective/storage/class-od-url-metrics-post-type.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,23 @@ class OD_URL_Metrics_Post_Type {
2323
/**
2424
* Post type slug.
2525
*
26+
* @since 0.1.0
2627
* @var string
2728
*/
2829
const SLUG = 'od_url_metrics';
2930

3031
/**
3132
* Event name (hook) for garbage collection of stale URL Metrics posts.
3233
*
34+
* @since 0.1.0
3335
* @var string
3436
*/
3537
const GC_CRON_EVENT_NAME = 'od_url_metrics_gc';
3638

3739
/**
3840
* Recurrence for garbage collection of stale URL Metrics posts.
3941
*
42+
* @since 0.1.0
4043
* @var string
4144
*/
4245
const GC_CRON_RECURRENCE = 'daily';

plugins/optimization-detective/storage/rest-api.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
/**
1616
* Namespace for optimization-detective.
1717
*
18+
* @since 0.1.0
19+
* @access private
1820
* @var string
1921
*/
2022
const OD_REST_API_NAMESPACE = 'optimization-detective/v1';
@@ -26,6 +28,8 @@
2628
* that does not strictly follow the standard usage. Namely, submitting a POST request to this endpoint will either
2729
* create a new `od_url_metrics` post, or it will update an existing post if one already exists for the provided slug.
2830
*
31+
* @since 0.1.0
32+
* @access private
2933
* @link https://google.aip.dev/136
3034
* @var string
3135
*/

0 commit comments

Comments
 (0)