[wp-trac] [WordPress Trac] #41057: Update PHP codebase per WordPress PHP Coding Standards

WordPress Trac noreply at wordpress.org
Tue Jun 20 10:29:25 UTC 2017


#41057: Update PHP codebase per WordPress PHP Coding Standards
----------------------------+-----------------------
 Reporter:  netweb          |       Owner:  pento
     Type:  task (blessed)  |      Status:  accepted
 Priority:  normal          |   Milestone:  4.9
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+-----------------------

Comment (by jrf):

 > Would you mind posting your updates as new comments, rather than editing
 comments? Comment edits aren't emailed to ticket subscribers, so I only
 noticed your updates by chance.

 @pento I didn't want to spam the participants of this thread with the
 details of individual PHPCS/WPCS issues found/fixed. If someone is
 interested to follow that in detail, I suggest "watching" the
 [https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
 WPCS repo] instead to get notifications about the individual issues/fixes.

 Latest issues identified based on visual review of some of the patches:
 * https://github.com/WordPress-Coding-Standards/WordPress-Coding-
 Standards/issues/982
 * https://github.com/WordPress-Coding-Standards/WordPress-Coding-
 Standards/issues/983
 * https://github.com/WordPress-Coding-Standards/WordPress-Coding-
 Standards/issues/985
 * https://github.com/WordPress-Coding-Standards/WordPress-Coding-
 Standards/issues/986
 * https://github.com/WordPress-Coding-Standards/WordPress-Coding-
 Standards/issues/988

 Latest PRs fixing some of these things:
 * https://github.com/WordPress-Coding-Standards/WordPress-Coding-
 Standards/pull/981
 * https://github.com/WordPress-Coding-Standards/WordPress-Coding-
 Standards/pull/987
 * https://github.com/WordPress-Coding-Standards/WordPress-Coding-
 Standards/pull/989


 > Is there are definitive method for running PHPCS/WPCS with the various
 PRs? Being fairly unfamiliar with both projects, it's a bit tricky to
 figure out whether bugs are being caused by know or unknown issues.

 PRs to WPCS are generally merged quite quickly, so using the latest
 `develop` branch should work. Unless I've accidentally done something
 silly, I expect the above three mentioned PRs to be merged within the next
 24 hours.

 There are no open PRs in PHPCS at this moment related to this ticket, so
 using the PHPCS `2.9` branch should be ok.

 When figuring out where issues are coming from, the following PHPCS tricks
 can be useful:
 * Use the `-s` flag when running `phpcs` to see which sniff is reporting
 issues on which line.
 * Running `phpcs -p -s ./filename.php --standard=WordPress-Core --report-
 diff -vv` will give you a full report on all the fixes which PHPCS tries
 to apply in the various loops without the file actually being changed.
 (report is very long, but the relevant bit is at the bottom anyway)

 > Also, while I remember, another thing noticed - multibyte characters
 seem to cause invalid PHP to be produced. If you remove /tests/ from the
 excluded locations, tests/phpunit/tests/pomo/po.php and
 tests/phpunit/tests/pomo/mo.php will have curly braces immediately
 following a multibyte string missing, after reformatting.

 The default encoding PHPCS 2.x uses for interpreting files is
 `ISO-8859-1`. This can be changed by setting `--encoding=utf-8` on the
 command line or using `<config name="encoding" value="utf-8"/>` in a
 custom ruleset.
 AFAIK, this can not be changed for an individual file, so will affect how
 all files are read.

 If so desired, we can add this directive to the `WordPress-Core` ruleset
 in WPCS.


 > It's currently running PHPCS against the latest dev-master WPCS sniffs
 without error.

 @netweb Without error ? From what I've seen so far, hardly any individual
 file patches are 100% bug-free, so please be very careful for now when
 pulling patches.

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


More information about the wp-trac mailing list