Skip to content

Commit 32c0322

Browse files
committed
Code Quality: Resolve return.empty PHPStan errors in baseline.
Fixes a couple of functions with return-type problems. One is resolved by adding the missing `void` type, while the other is resolved by updating the function to conform to the existing `string` return type contract, a likely oversight in the original commit. This change was part of Contributor Day at WordCamp US 2026. Developed in: WordPress#13081 Discussed in: https://core.trac.wordpress.org/ticket/65817 Props dmsnell, nomadmystic. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@63314 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 62668de commit 32c0322

4 files changed

Lines changed: 2 additions & 37 deletions

File tree

‎phpstan.neon.dist‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ includes:
7979
- tests/phpstan/baselines/property.phpDocType.neon
8080
- tests/phpstan/baselines/property.private.neon
8181
- tests/phpstan/baselines/property.protected.neon
82-
- tests/phpstan/baselines/return.empty.neon
8382
- tests/phpstan/baselines/return.missing.neon
8483
- tests/phpstan/baselines/return.type.neon
8584
- tests/phpstan/baselines/return.unusedType.neon

‎src/wp-content/themes/twentytwenty/inc/custom-css.php‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@
2323
* @return string Generated CSS.
2424
*/
2525
function twentytwenty_generate_css( $selector, $style, $value, $prefix = '', $suffix = '', $display = true ) {
26-
27-
$return = '';
28-
2926
/*
3027
* Bail early if we have no $selector elements or properties and $value.
3128
*/
3229
if ( ! $value || ! $selector ) {
33-
34-
return;
30+
return '';
3531
}
3632

3733
$return = sprintf( '%s { %s: %s; }', $selector, $style, $prefix . $value . $suffix );

‎src/wp-includes/l10n.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ function wp_get_l10n_php_file_data( $php_file ) {
17351735
* @type bool $explicit_option_en_us Whether the English (United States) option uses an explicit value of en_US
17361736
* instead of an empty value. Default false.
17371737
* }
1738-
* @return string HTML dropdown list of languages.
1738+
* @return string|void HTML dropdown list of languages.
17391739
*/
17401740
function wp_dropdown_languages( $args = array() ) {
17411741

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +0,0 @@
1-
# PHPStan baseline for the `return.empty` errors in WordPress core.
2-
#
3-
# https://phpstan.org/error-identifiers/return.empty
4-
#
5-
# Each entry is scoped to a single file and carries an exact occurrence count,
6-
# so that a new instance is reported as a new error rather than being absorbed
7-
# silently. Fixing an occurrence therefore means decrementing or removing its
8-
# entry here as part of the same change.
9-
#
10-
# The goal is to empty this file and delete it, along with the `includes` entry
11-
# for it in phpstan.neon.dist.
12-
#
13-
# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with
14-
#
15-
# composer phpstan:baselines -- --identifier=return.empty
16-
#
17-
# which reruns the analysis with this file suppressed so the errors surface again.
18-
19-
parameters:
20-
ignoreErrors:
21-
-
22-
message: '#^Function twentytwenty_generate_css\(\) should return string but empty return statement found\.$#'
23-
identifier: return.empty
24-
count: 1
25-
path: ../../../src/wp-content/themes/twentytwenty/inc/custom-css.php
26-
-
27-
message: '#^Function wp_dropdown_languages\(\) should return string but empty return statement found\.$#'
28-
identifier: return.empty
29-
count: 1
30-
path: ../../../src/wp-includes/l10n.php

0 commit comments

Comments
 (0)