Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
382ce6c
Bump minimum PHP version to 7.4 in composer.json
westonruter May 8, 2026
e9ce2ca
Bump PHPCS testVersion to 7.4-
westonruter May 8, 2026
2a5cc3f
Bump plugin header Requires PHP from 7.2 to 7.4
westonruter May 8, 2026
872f9c5
Drop PHP 7.2 and 7.3 from the unit-test matrix
westonruter May 8, 2026
0e0671f
Update CONTRIBUTING.md and AGENTS.md to reference PHP 7.4
westonruter May 8, 2026
619d91b
Update phpstan.neon.dist comment to reference PHP 7.4
westonruter May 8, 2026
cd44261
Drop PHP 7.2/7.3 array_merge empty-input guard
westonruter May 8, 2026
04e1f38
Reindent speculation-rules heredoc closer using PHP 7.3+ flexible her…
westonruter May 8, 2026
6017bd9
Allow @var docblocks alongside native property type hints
westonruter May 8, 2026
6d94c56
Add native typed properties to OD_HTML_Tag_Processor
westonruter May 8, 2026
2eb0730
Add native typed properties to OD_URL_Metric_Group
westonruter May 8, 2026
3dee81d
Add native typed properties to OD_URL_Metric_Group_Collection
westonruter May 8, 2026
2565e27
Add native typed properties to OD_Tag_Visitor_Context
westonruter May 8, 2026
500ece2
Add native typed properties to OD_Template_Optimization_Context
westonruter May 8, 2026
0c35e17
Add native typed properties to OD_URL_Metric_Store_Request_Context
westonruter May 8, 2026
65cb28c
Add native typed properties to OD_URL_Metric
westonruter May 8, 2026
7f02300
Add native typed properties to OD_Element
westonruter May 8, 2026
d7dc8e0
Add native typed properties to small OD classes
westonruter May 8, 2026
1b6b942
Add native typed properties to image-prioritizer tag visitors
westonruter May 8, 2026
2f0fc6d
Add native typed property to Embed_Optimizer_Tag_Visitor
westonruter May 8, 2026
a8b58ae
Add native typed property to PLSR_URL_Pattern_Prefixer
westonruter May 8, 2026
5260154
Add native typed properties to performance-lab server-timing classes
westonruter May 8, 2026
2aea571
Add native typed properties to view-transitions classes
westonruter May 8, 2026
6a0ce79
Require native property type hints across plugin source
westonruter May 8, 2026
8f3b90a
Convert single-expression closures to arrow functions in optimization…
westonruter May 8, 2026
884f24f
Convert single-expression closures to arrow functions in performance-lab
westonruter May 8, 2026
74a704e
Convert single-expression closures to arrow functions in image-priori…
westonruter May 8, 2026
1ae6374
Convert single-expression closure to arrow function in speculation-rules
westonruter May 8, 2026
f6cb8a2
Convert single-expression closures to arrow functions in web-worker-o…
westonruter May 8, 2026
200b0cc
Convert single-expression closure to arrow function in view-transitions
westonruter May 8, 2026
71430b3
Simplify boolean logic in plvt_register_view_transition_animations()
westonruter May 8, 2026
ea9906a
Remove redundant type hint
westonruter May 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Convert single-expression closures to arrow functions in optimization…
…-detective

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
  • Loading branch information
westonruter and claude committed May 8, 2026
commit 8f3b90a22ee0bd08ebb15797a6a93fd5c84d31f5
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ public function add_link( array $attributes, ?int $minimum_viewport_width = null
private function get_prepared_links(): array {
return array_merge(
...array_map(
function ( array $links ): array {
return $this->merge_consecutive_links( $links );
},
fn ( array $links ): array => $this->merge_consecutive_links( $links ),
array_values( $this->links_by_rel )
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ public function add_url_metric( OD_URL_Metric $url_metric ): void {
// Sort URL Metrics in descending order by timestamp.
usort(
$this->url_metrics,
static function ( OD_URL_Metric $a, OD_URL_Metric $b ): int {
return $b->get_timestamp() <=> $a->get_timestamp();
}
static fn ( OD_URL_Metric $a, OD_URL_Metric $b ): int => $b->get_timestamp() <=> $a->get_timestamp()
);

// Only keep the sample size of the newest URL Metrics.
Expand Down Expand Up @@ -355,9 +353,7 @@ public function get_lcp_element(): ?OD_Element {
// Prefer to use URL Metrics, which have a current ETag.
$url_metrics = array_filter(
$this->url_metrics,
function ( OD_URL_Metric $url_metric ): bool {
return $url_metric->get_etag() === $this->get_collection()->get_current_etag();
}
fn ( OD_URL_Metric $url_metric ): bool => $url_metric->get_etag() === $this->get_collection()->get_current_etag()
);

// Otherwise, if no URL Metrics have a current ETag, fall back to using all the stale ones.
Expand Down
8 changes: 2 additions & 6 deletions plugins/optimization-detective/class-od-url-metric.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,7 @@ public function get_timestamp(): float {
public function get_elements(): array {
if ( null === $this->elements ) {
$this->elements = array_map(
function ( array $element ): OD_Element {
return new OD_Element( $element, $this );
},
fn ( array $element ): OD_Element => new OD_Element( $element, $this ),
$this->data['elements']
);
}
Expand All @@ -541,9 +539,7 @@ public function jsonSerialize(): array {
$data = $this->data;

$data['elements'] = array_map(
static function ( OD_Element $element ): array {
return $element->jsonSerialize();
},
static fn ( OD_Element $element ): array => $element->jsonSerialize(),
$this->get_elements()
);

Expand Down
12 changes: 5 additions & 7 deletions plugins/optimization-detective/detection.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,11 @@ function od_get_detection_scripts( string $slug, OD_URL_Metric_Group_Collection
'cachePurgePostId' => od_get_cache_purge_post_id(),
'urlMetricHMAC' => od_get_url_metrics_storage_hmac( $slug, $current_etag, $current_url, $cache_purge_post_id ),
'urlMetricGroupStatuses' => array_map(
static function ( OD_URL_Metric_Group $group ): array {
return array(
'minimumViewportWidth' => $group->get_minimum_viewport_width(), // Exclusive.
'maximumViewportWidth' => $group->get_maximum_viewport_width(), // Inclusive.
'complete' => $group->is_complete(),
);
},
static fn ( OD_URL_Metric_Group $group ): array => array(
Comment thread
westonruter marked this conversation as resolved.
Outdated
'minimumViewportWidth' => $group->get_minimum_viewport_width(), // Exclusive.
'maximumViewportWidth' => $group->get_maximum_viewport_width(), // Inclusive.
'complete' => $group->is_complete(),
),
iterator_to_array( $group_collection )
),
'storageLockTTL' => OD_Storage_Lock::get_ttl(),
Expand Down