[wp-trac] [WordPress Trac] #63249: Minor code and inline docs improvements in class-wp-rest-server.php

WordPress Trac noreply at wordpress.org
Tue Apr 8 09:43:42 UTC 2025


#63249: Minor code and inline docs improvements in class-wp-rest-server.php
--------------------------+-----------------------------
 Reporter:  dilipbheda    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:
 Severity:  normal        |   Keywords:  has-patch
  Focuses:  docs          |
--------------------------+-----------------------------
 **Inline Documentation Improvement**

 Some `@param` tags are missing default value annotations. e.g:
 - `@param string|null` — the default value should be specified when
 applicable.
 - `@param false|null` — missing mention of the default value.


 **Conditional Logic Adjustment**

 ''Function:'' `get_json_last_error()`

 **The current condition:**

 `if ( JSON_ERROR_NONE === $last_error_code || empty( $last_error_code ) )
 {`

 **Proposed change:**

 `if ( empty( $last_error_code ) || JSON_ERROR_NONE === $last_error_code )
 {`

 This change reorders the condition to check for an empty value first,
 which is a common best practice. It improves readability and slightly
 optimizes performance by short-circuiting sooner when `$last_error_code`
 is empty.

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


More information about the wp-trac mailing list