WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#44397 new defect (bug)

Argument type does not match: theme.php

Reported by: subrataemfluence Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: Themes Keywords: has-patch 2nd-opinion
Focuses: coding-standards Cc:

Description

In the function doc of get_theme_root_uri(), the argument types of $stylesheet_or_template and $theme_root do not match. Default values of arguments are boolean but in function doc they are stated as strings.

File name: wp-admin/theme.php
Function: get_theme_root_uri
<?php
/**
 * Retrieve URI for themes directory.
 *
 * Does not have trailing slash.
 *
 * @since 1.5.0
 *
 * @global array $wp_theme_directories
 *
 * @param string $stylesheet_or_template Optional. The stylesheet or template name of the theme.
 *                                       Default is to leverage the main theme root.
 * @param string $theme_root             Optional. The theme root for which calculations will be based, preventing
 *                                       the need for a get_raw_theme_root() call.
 * @return string Themes URI.
 */
function get_theme_root_uri( $stylesheet_or_template = false, $theme_root = false ) {
   ...
}

Can we re-write the parameter descriptions in the following way?

<?php
 * @param string | bool $stylesheet_or_template Optional. The stylesheet or template name of the theme.
 *                                       Default is to leverage the main theme root. Default value false.
 * @param string | bool $theme_root             Optional. The theme root for which calculations will be based, preventing
 *                                       the need for a get_raw_theme_root() call. Default value false.

since we are checking for boolean values of these two parameters inside the function body like:

<?php
if ( $stylesheet_or_template && ! $theme_root ) {
   $theme_root = get_raw_theme_root( $stylesheet_or_template );
}

if ( $stylesheet_or_template && $theme_root ) {
   ...
}

and on the other hand we are passing string values to theses parameters when calling this function like this:

<?php
$this->theme_root_uri = get_theme_root_uri( $this->stylesheet, $this->theme_root );

Attachments (1)

44397.diff (1.2 KB) - added by subrataemfluence 5 weeks ago.

Download all attachments as: .zip

Change History (2)

#1 @subrataemfluence
5 weeks ago

  • Keywords has-patch 2nd-opinion added; needs-patch removed
Note: See TracTickets for help on using tickets.