[wp-trac] [WordPress Trac] #56021: Rename or deprecate assertDiscardWhitespace()

WordPress Trac noreply at wordpress.org
Tue Jun 21 06:08:49 UTC 2022

#56021: Rename or deprecate assertDiscardWhitespace()
 Reporter:  SergeyBiryukov    |       Owner:  (none)
     Type:  enhancement       |      Status:  new
 Priority:  normal            |   Milestone:  6.1
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:

Comment (by jrf):

 Leaving this here as it seems loosely related.

 I've just had a look at the `assertDiscardWhitespace()` method in a little
 more detail (to see how it differs) and am wondering about the whitespace
 replacement being done for both `$actual` as well as `$expected`:
 $expected = preg_replace( '/\s*/', '', $expected );

 This replaces all whitespace with an empty string. That effectively means
 that two substrings with different meaning could be considered the same.

 Simple example:
     'the value must be set inline',
     'the value must be set in line' // . $line_number

 I wonder if it would be more accurate to replace all whitespace with a
 single space instead ?

 The down-side of that would be that the below would no longer be
 considered "equal":

 Maybe the function's whitespace handling shouldn't be changed, but the
 docblock should be updated with a warning using it with non-markup text
 instead ?

Ticket URL: <https://core.trac.wordpress.org/ticket/56021#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list