[wp-trac] [WordPress Trac] #43150: Update Emoji build step to follow WP Coding Standards.

WordPress Trac noreply at wordpress.org
Wed Jan 24 23:27:49 UTC 2018


#43150: Update Emoji build step to follow WP Coding Standards.
------------------------------+-------------------------------
 Reporter:  peterwilsoncc     |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  5.0
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:  coding-standards
------------------------------+-------------------------------

Comment (by netweb):

 Replying to [comment:6 jrf]:
 > @netweb FYI, you can combine several disables in one command, so the
 comment block above the arrays could look like this:
 >
 > {{{#!php
 > <?php
 >         /*
 >          * Don't format the array across 4000 lines.
 >          * phpcs:disable
 WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine,WordPress.Arrays.CommaAfterArrayItem.NoSpaceAfterComma
 >          *
 >          * N.B.: Do not remove the START/END comments - they're used to
 find where to insert the arrays.
 >          */
 > }}}

 Neat, thanks @jrf, I went searching the PHPCS docs to find some
 documentation or examples of multiline `phpcs:disable` and didn't find
 any, this is much neater and will keep this in mind for the future +1

 > As a side-note: as this is a non-keyed array, as far as I can see, WPCS
 wouldn't be throwing the
 `WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine` error if the
 array was passed like `array(....)` (no new line after opening bracket or
 before closing bracket).
 > The line is going to be ridiculously long anyway, so why have those two
 new lines ?
 >
 > Similarly, as the line is so long, why not have the comma's after each
 array item ?
 >
 > Having said that, you may not need to use the `phpcs:disable` comments
 at all to still comply with the standards.

 Patch [attachment:43150.3.diff] implements @jrf's approach above, no
 `phpcs:disable` comments are required in `src/wp-includes/formatting.php`
 and is now formatted as:

 {{{#!php
 <?php
 function _wp_emoji_list( $type = 'entities' ) {
         // Do not remove the START/END comments - they're used to find
 where to insert the arrays.

         // START: emoji arrays
         $entities = array(
 '&#x1f469;&#x200d;&#x2764;&#xfe0f;&#x200d;&#x1f48b;&#x200d;&#x1f469;',
 '&#x1f469;&#x200d;&#x2764;&#xfe0f;&#x200d;&#x1f48b;&#x200d;&#x1f468;',
 '&#x1f468;&#x20...
         $partials = array( '&#x1f004;', '&#x1f0cf;', '&#x1f170;',
 '&#x1f171;', '&#x1f17e;', '&#x1f17f;', '&#x1f18e;', '&#x1f191;',
 '&#x1f192;', '&#x1f193;', '&#x1f194;', '&#x1f195;', '...
         // END: emoji arrays

 }}}

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


More information about the wp-trac mailing list