[wp-trac] [WordPress Trac] #44397: Argument type does not match: theme.php

WordPress Trac noreply at wordpress.org
Mon Jun 18 14:58:17 UTC 2018


#44397: Argument type does not match: theme.php
------------------------------+-----------------------------
 Reporter:  subrataemfluence  |      Owner:  (none)
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Themes            |    Version:  trunk
 Severity:  normal            |   Keywords:  needs-patch
  Focuses:  coding-standards  |
------------------------------+-----------------------------
 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
 <?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
 <?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
 <?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
 <?php
 $this->theme_root_uri = get_theme_root_uri( $this->stylesheet,
 $this->theme_root );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44397>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list