[wp-trac] [WordPress Trac] #21616: add-textdomain doesn't conform to WP coding standards

WordPress Trac noreply at wordpress.org
Thu May 1 00:30:54 UTC 2014


#21616: add-textdomain doesn't conform to WP coding standards
------------------------------------+----------------------------
 Reporter:  groovecoder             |       Owner:
     Type:  defect (bug)            |      Status:  reopened
 Priority:  normal                  |   Milestone:  WordPress.org
Component:  I18N                    |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+----------------------------
Changes (by GaryJ):

 * keywords:   => has-patch dev-feedback


Comment:

 [attachment:21616.2.diff] is a first pass at this, and is open to
 suggestions on all aspects.

 To check my change was working correctly, I needed some tests. To be able
 to test sensibly, I neede to be able to just process a string of PHP code,
 and not individual files, so I needed some refactoring. If this means this
 diff should go on to a new ticket, which can this fix this ticket, let me
 know.

 The general approach was to make use of the native counter (`$index`) when
 looping through the array of tokens, so we can check if the previous token
 before the closing `)` was an instance of whitespace (using coding
 standards). At the moment, I add a single space to the current token, and
 strip whatever whitespace was on the end of the previously processed
 tokens. There's a case where the previous whitespace might have been a
 line break, not a single space, so this bit could be improved.

 With the check of the previous token possible, it becomes a matter of
 string manipulation to get the desired output.

 One thing I did need to change, was to hold on echoing until the file had
 been completely processed (so that I could remove a previous token during
 the processing) instead of echo-ing one token at a time. I'm not sure if
 this will cause any BC behaviour changes.

 The new functions are documented, but given a wider ticket scope, I'd
 refactor `process_tokens()` even further (and look at making it a
 protected method).

 The tests are simple, but all currently pass.

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


More information about the wp-trac mailing list