Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#53359 closed task (blessed) (fixed)

Coding Standards fixes for WP 5.9

Reported by: desrosj's profile desrosj Owned by:
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Previously:

Change History (90)

@kapilpaul
3 years ago

Patch for PHPCS fixing in bundled themes.

#1 @kapilpaul
3 years ago

In 53359.diff mostly fixed the strict comparison. here is the GitHub PR

#2 @SergeyBiryukov
3 years ago

In 51285:

Coding Standards: Remove redundant type casting to array in WP_Query::get_posts().

This brings some consistency with other instances of using get_post_stati() in core.

get_post_stati() always returns an array, so the type casting is not needed.

Follow-up to [13172].

See #53359.

#3 @SergeyBiryukov
3 years ago

In 51381:

Coding Standards: Remove wrapping HTML tags from translatable strings.

This fixes a "Strings should not be wrapped in HTML" WPCS warning in help tabs for Export Personal Data and Erase Personal Data screens.

Follow-up to [50147].

See #53359.

#4 @SergeyBiryukov
3 years ago

In 51399:

Coding Standards: Rename the $ID variable to $user_id in wp_insert_user() and wp_update_user().

This fixes a "Variable $ID is not in valid snake_case format" WPCS warning.

Follow-up to [2872].

See #53359.

#5 @SergeyBiryukov
3 years ago

In 51400:

Bundled Themes: Correct comment formatting in inc/block-patterns.php.

Follow-up to [51045], [51103].

Props kapilpaul.
See #53359, #52627.

#6 @SergeyBiryukov
3 years ago

In 51401:

Twenty Fifteen: Use strict comparison in inc/custom-header.php.

Props kapilpaul.
See #53359.

#7 @desrosj
3 years ago

In 51406:

Bundled Themes: Correct comment formatting in inc/block-patterns.php.

Follow-up to [51045], [51103].

Props kapilpaul, SergeyBiryukov.
See #53359, #52627.

This ticket was mentioned in PR #1509 on WordPress/wordpress-develop by jrfnl.


3 years ago
#8

  • Keywords has-patch has-unit-tests added

#9 @jrf
3 years ago

I've just uploaded 9 CS related patches to fix some low hanging fruit. To verify, one PR containing all these patches has been opened on GH and the build is passing: https://github.com/WordPress/wordpress-develop/pull/1509

hellofromtonya commented on PR #1509:


3 years ago
#10

@jrfnl Is this PR complete and ready for code review?

jrfnl commented on PR #1509:


3 years ago
#11

@hellofromtonya There will always be more fixes to make, but the fixes as pulled here are ready for commit as far as I'm concerned.

#12 @jrf
3 years ago

Added three more patches related to the ignore annotation review done for #53477. As the changes in ignore annotations are not related to the PHPCS update in #53477, I'm adding the patches here.

This ticket was mentioned in PR #1510 on WordPress/wordpress-develop by jrfnl.


3 years ago
#13

Update the PHP_CodeSniffer dependency from version 3.5.5 to version 3.6.0.

I have also verified the ignore annotations, but no changes are needed there which are directly related to the PHPCS update. Changes which could be made have been added to #53359.

Trac ticket: https://core.trac.wordpress.org/ticket/53477

#14 @hellofromTonya
3 years ago

  • Keywords commit added

Marking submitted patches from [https://github.com/WordPress/wordpress-develop/pull/1509 PR 1509) ready for commit.

jrfnl commented on PR #1510:


3 years ago
#15

Closing as merged via changeset https://core.trac.wordpress.org/changeset/51470

#16 @SergeyBiryukov
3 years ago

In 51526:

Coding Standards: Fix typo in the JS function name for handling the password reset button.

Follow-up to [50129].

See #53359.

#17 @SergeyBiryukov
3 years ago

In 51534:

Coding Standards: Correct DateTimeZone class name in WP_Customize_Date_Time_Control::get_timezone_info().

Follow-up to [41626].

See #53359.

#18 @peterwilsoncc
3 years ago

In 51548:

Coding Standards: Use strict comparisons in wp-admin/options-discussion.php.

See #53359.

#19 @peterwilsoncc
3 years ago

In 51549:

Coding Standards: Use strict comparisons in wp-admin/upload.php.

See #53359.

#20 @SergeyBiryukov
3 years ago

In 51550:

Coding Standards: Fix incorrect comment indent in safecss_filter_attr().

Props jrf.
See #53359.

#21 @SergeyBiryukov
3 years ago

In 51551:

Coding Standards: Fix incorrect alignment in two comment blocks.

Tabs should only be used for indentation and not for mid-line alignment.

Props jrf.
See #53359.

#22 @SergeyBiryukov
3 years ago

In 51552:

Coding Standards: Remove redundant semicolons after closing curly brackets.

Props jrf.
See #53359.

#23 @SergeyBiryukov
3 years ago

In 51553:

Bundled Themes: Remove redundant semicolons after closing curly brackets.

Includes a few minor indentation fixes.

Props jrf.
See #53359.

#24 @SergeyBiryukov
3 years ago

In 51554:

Twenty Thirteen: Remove wrapping HTML tag from translatable string.

This fixes a "Strings should not be wrapped in HTML" WPCS warning.

Props jrf.
See #53359.

#25 @SergeyBiryukov
3 years ago

In 51556:

Twenty Thirteen: Correct indentation in image.php template.

Props jrf.
See #53359.

#26 @SergeyBiryukov
3 years ago

In 51557:

Coding Standards: Silence a WPCS warning in date_i18n().

This fixes a "Calling current_time() with a $type of timestamp or U is strongly discouraged as it will not return a Unix (UTC) timestamp" warning.

Props jrf.
See #53359.

This ticket was mentioned in PR #1552 on WordPress/wordpress-develop by jrfnl.


3 years ago
#27

If a closure doesn't use $this, it can be made static for improved performance.

Static closures are supported in PHP since PHP 5.4.

Trac ticket: https://core.trac.wordpress.org/ticket/53359

#28 @jrf
3 years ago

I've just opened PR 1552 with two more patches to fix all closures not using $this to be static (performance tweak).

jrfnl commented on PR #1509:


3 years ago
#29

I've rebased the remaining commits in this PR to solve the merge conflicts and make the patches commitable again.

#30 @hellofromTonya
3 years ago

PR 1552 is ready for commit.

cc @SergeyBiryukov

#31 @hellofromTonya
3 years ago

PR 1509 is also ready for commit.

cc @SergeyBiryukov

#32 @hellofromTonya
3 years ago

In 51657:

Coding Standards: Use static closures when not using $this.

When a closure does not use $this, it can be made static for improved performance.

Static closures are supported in PHP since PHP 5.4. ​

Props jrf, hellofromTonya, swissspidy, SergeyBiryukov.
See #53359.

hellofromtonya commented on PR #1552:


3 years ago
#33

Closing as committed with changeset https://core.trac.wordpress.org/changeset/51657.

#34 @hellofromTonya
3 years ago

In 51658:

Coding Standards: Update the config for WordPress.PHP.NoSilencedErrors in PHPCS ruleset.

Follow-up to [45611].

Props jrf, hellofromTonya.
See #53359.

#35 @hellofromTonya
3 years ago

In 51659:

Coding Standards: Update the config for WordPress.PHP.FileName in PHPCS ruleset.

The WPCS sniff already takes the test classes in the tests/phpunit/includes directory into account.

Only the test cases outside of that directory, i.e. in the tests/phpunit/tests directory need to be listed here.

Includes alphabetizing the list.

Follow-up to [42346], [45607].

Props jrf, hellofromTonya, SergeyBiryukov.
See #53359.

#36 @SergeyBiryukov
3 years ago

Just noting that some of the patches here make changes to the wp-includes/blocks directory. However, these changes can be overwritten later with package updates from Gutenberg, so they would have to be made upstream in the Gutenberg repo first. The latest commits will skip those changes for now.

#37 @hellofromTonya
3 years ago

In 51660:

Coding Standards: Remove redundant ignore annotation in populate_options().

Follow-up to [43627], [43628].

Props jrf, hellofromTonya.
See #53359.

#38 @hellofromTonya
3 years ago

In 51661:

Coding Standards: Make ignore annotation more specific in WP_Site_Health_Auto_Updates::test_vcs_abspath().

Follow-up to [44986].

Props jrf, hellofromTonya.
See #53359.

#39 @hellofromTonya
3 years ago

In 51662:

Coding Standards: Fix indentation and remove ignore annotation in wp_privacy_send_personal_data_export_email().

Follow-up to [51129], [51410].

Props jrf, hellofromTonya.
See #53359.

#40 @desrosj
3 years ago

In 51693:

Coding Standards: Apply some minor alignment fixes.

These are updates caused by running composer format.

Follow up to [51501], [51599], [51618], [51653].
See #53359, #50542, #53238, #53668, #53690.

jrfnl commented on PR #1509:


3 years ago
#41

Closing as fully committed via a variety of changesets.

#42 @SergeyBiryukov
3 years ago

In 51822:

Coding Standards: Use strict comparison in wp-inclues/class-wp-http-cookie.php.

Follow-up to [10512].

See #53359.

#43 @SergeyBiryukov
3 years ago

In 51823:

Coding Standards: Rename the $arrURL variable to $parsed_url in WP_Http::request().

This fixes a Variable "$arrURL" is not in valid snake_case format WPCS warning.

Follow-up to [10509], [45667].

See #53359.

#44 @SergeyBiryukov
3 years ago

In 51824:

Coding Standards: Rename the $arrURL variable to $parsed_url in WP_Http_Cookie::__construct().

This fixes a Variable "$arrURL" is not in valid snake_case format WPCS warning.

Follow-up to [10509], [25044], [45667], [51823].

See #53359.

#45 @SergeyBiryukov
3 years ago

In 51825:

Coding Standards: Rename the $arrURL variable to $parsed_url in WP_Http_Streams::request().

This fixes a Variable "$arrURL" is not in valid snake_case format WPCS warning.

Follow-up to [8620], [10509], [25044], [25224], [45667], [51823], [51824].

See #53359.

#46 @SergeyBiryukov
3 years ago

In 51826:

Coding Standards: Rename the $processedHeaders variable to $processed_headers in WP_Http::request().

This fixes a Variable "$processedHeaders" is not in valid snake_case format WPCS warning.

Follow-up to [8620], [51823].

See #53359.

This ticket was mentioned in Slack in #core by sergey. View the logs.


3 years ago

#48 @costdev
3 years ago

Posting related ticket for visibility: #54177

#49 @SergeyBiryukov
3 years ago

In 51877:

Coding Standards: Use strict comparison in wp-includes/class-http.php.

Follow-up to [10625], [10864], [13274], [29661], [33748], [47508], [47808].

See #53359.

#50 @SergeyBiryukov
3 years ago

In 51879:

Coding Standards: Use strict comparison in wp-includes/class-wp-http-ixr-client.php.

Follow-up to [16064], [16871], [17928].

See #53359.

#51 @hellofromTonya
3 years ago

In 51888:

Coding Standards: Use strict type check for in_array() in register_block_script_handle().

Follow-up to [51501].

Props aristath, sergeybiryukov.
Fixes #54206. See #53359.

#52 @johnbillion
2 years ago

  • Keywords commit removed

#53 @SergeyBiryukov
2 years ago

In 51929:

Coding Standards: Rename the $arrHeaders variable to $processed_headers in WP_Http_Streams::request().

This fixes a Variable "$arrHeaders" is not in valid snake_case format WPCS warning.

Follow-up to [8516], [51826].

See #53359.

#54 @SergeyBiryukov
2 years ago

In 51931:

Coding Standards: Rename $theHeaders variable to $processed_headers in WP_Http_Curl::request().

This fixes a Variable "$theHeaders" is not in valid snake_case format WPCS warning.

Follow-up to [8516], [8520], [51826], [51929].

See #53359.

#55 @SergeyBiryukov
2 years ago

In 51940:

Coding Standards: Rename the $process variable to $processed_response for clarity in WP_Http_Streams::request().

Includes minor code layout fixes for better readability.

Follow-up to [8516], [51826], [51929], [51931].

See #53359.

This ticket was mentioned in Slack in #core by sergey. View the logs.


2 years ago

#57 @SergeyBiryukov
2 years ago

In 51944:

Coding Standards: Correct alignment in wp_enqueue_global_styles().

This fixes an Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space WPCS warning.

Follow-up to [50973], [51819].

See #53359.

#58 @SergeyBiryukov
2 years ago

In 51951:

Coding Standards: Correct alignment in WP_Site_Health::get_test_update_temp_backup_writable().

This fixes an Equals sign not aligned with surrounding assignments; expected 1 space but found 6 spaces WPCS warning.

Follow-up to [51815].

See #51857, #53359.

This ticket was mentioned in Slack in #core by sergey. View the logs.


2 years ago

#60 @SergeyBiryukov
2 years ago

In 52025:

Coding Standards: Rename the $strResponse argument to $str_response in WP_Http::processResponse().

This fixes a Variable "$strResponse" is not in valid snake_case format WPCS warning.

Additionally, rename a $res variable to $response for clarity.

Follow-up to [8516], [51823], [51826], [51877].

See #53359.

#61 @SergeyBiryukov
2 years ago

In 52026:

Coding Standards: Move wp-includes/class-http.php to wp-includes/class-wp-http.php.

This renames the file containing the WP_Http class to conform to the coding standards.

This commit also includes:

  • A new class-http.php that includes the new file, for anyone that may've been including the file directly.
  • Replaces references to the old filename with the new filename.

Follow-up to [8516], [13274], [33748].

Fixes #54389. See #53359.

#62 @SergeyBiryukov
2 years ago

In 52150:

Coding Standards: Rename the $gzData argument to $gz_data in WP_Http_Encoding::compatible_gzinflate().

This fixes a Variable "$gzData" is not in valid snake_case format WPCS warning.

Follow-up to [11684].

See #53359.

#63 @SergeyBiryukov
2 years ago

In 52228:

Coding Standards: Wrap some long lines in js/_enqueues/admin/post.js per the JS coding standards for better readability.

See #53359.

#64 @SergeyBiryukov
2 years ago

In 52278:

I18N: Remove redundant default text domain parameter in some __() calls.

Follow-up to [51160], [52069].

See #53359.

#66 @audrasjb
2 years ago

In 52345:

Coding Standards: Correct alignment in blocks.php and class-wp-rest-templates-controller.

See #53359.

#68 @SergeyBiryukov
2 years ago

In 52346:

Coding Standards: Use camel case with a lowercase first letter for the blockTheme array key.

This matches the WordPress JS naming conventions and the naming of other keys in the $prepared_themes array.

Follow-up to [52341].

See #54578, #53359.

#69 @SergeyBiryukov
2 years ago

In 52348:

Coding Standards: Simplify or wrap some long conditions in wp-includes/theme.php for better readability.

Includes adjusting some DocBlocks per the documentation standards.

Follow-up to [35595], [41937], [52256].

See #53359, #53399.

#70 @SergeyBiryukov
2 years ago

In 52350:

Coding Standards: Remove a trailing comma from a compact() call in _wp_customize_include().

This fixes a Trailing comma's are not allowed in function calls in PHP 7.2 or earlier error in the PHP compatibility check.

Follow-up to [52348].

See #53359.

#73 @audrasjb
2 years ago

In 52354:

Docs: Docblock adjustments in some 5.9 block related functions.

Adds missing @since mention to wp_enqueue_block_style() and _wp_multiple_block_styles(), and a few other minor changes.

Follow-up to [52069].

See #53359.

#75 @SergeyBiryukov
2 years ago

In 52428:

Coding Standards: Use strict comparison in wp-admin/options-reading.php.

Follow-up to [16816].

See #53359.

#76 @hellofromTonya
2 years ago

  • Resolution set to fixed
  • Status changed from new to closed

With 5.9 RC1 tomorrow and since coding standards updates usually touch code, I'm going to close this out.

If there are any more changes required between now and the final 5.9 release, this can be referenced and reopened if necessary with dev-reviewed.

#54728 is open for continuation during the 6.0 cycle.

#77 @SergeyBiryukov
2 years ago

In 52431:

Coding Standards: Use strict comparison in wp-admin/options.php.

Follow-up to [21852], [47874], [51075].

See #53359.

Note: See TracTickets for help on using tickets.