Coding Standards: Adjust coding standards to always omit parentheses for `include`/`require` statements.

These are language constructs, not function calls, so the parentheses are unnecessary.

This updates the PHPCS configuration file the enforce the sniff until it is moved from the `WordPress-Extra` ruleset to the `WordPress-Core` ruleset upstream.

Follow-up to [47198].

Props desrosj, jrf, GaryJ.
Fixes #49376.

git-svn-id: https://develop.svn.wordpress.org/trunk@47207 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-02-07 19:14:29 +00:00
parent 2ce61ea2d6
commit f8b2ff1b53
5 changed files with 22 additions and 8 deletions

View File

@ -169,7 +169,7 @@
</rule>
<!-- Whitelist the I18n functions file from issues identified by the I18n sniff
(such as calling the low-level translate() function). -->
(such as calling the low-level translate() function). -->
<rule ref="WordPress.WP.I18n">
<exclude-pattern>/src/wp-includes/l10n\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/l10n\.php</exclude-pattern>
@ -189,8 +189,8 @@
</rule>
<!-- Exclude checking of line endings when reporting errors, but fix them when running phpcbf.
Git and SVN manage these pretty well cross-platform as "native".
Whitelist configuration files. -->
Git and SVN manage these pretty well cross-platform as "native".
Whitelist configuration files. -->
<rule ref="Generic.Files.LineEndings">
<exclude-pattern>/wp-config\.php</exclude-pattern>
<exclude-pattern>/wp-config-sample\.php</exclude-pattern>
@ -270,6 +270,21 @@
</properties>
</rule>
<!-- Enforce no parenthesis for language constructs, and only one space immediately after.
Including this rule is temporary until it is moved from the WordPress-Extra ruleset to
the WordPress-Core ruleset upstream.
-->
<rule ref="PEAR.Files.IncludingFile.BracketsNotRequired">
<type>warning</type>
</rule>
<rule ref="PEAR.Files.IncludingFile.UseRequire">
<type>warning</type>
</rule>
<rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
<type>warning</type>
</rule>
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Assignments in while conditions are a valid method of looping over iterables. -->
<rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
<exclude-pattern>*</exclude-pattern>

View File

@ -427,7 +427,7 @@ function attachment_submit_meta_box( $post ) {
echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Move to Trash' ) . '</a>';
} else {
$delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete Permanently' ) . '</a>';
echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete Permanently' ) . '</a>';
}
}
?>

View File

@ -21,7 +21,7 @@ function translations_api( $type, $args = null ) {
require ABSPATH . WPINC . '/version.php';
if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ) ) ) {
return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) );
return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) );
}
/**

View File

@ -5200,7 +5200,7 @@ function _doing_it_wrong( $function, $message, $version ) {
function is_lighttpd_before_150() {
$server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '' );
$server_parts[1] = isset( $server_parts[1] ) ? $server_parts[1] : '';
return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' );
return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' );
}
/**

View File

@ -258,8 +258,7 @@ function get_shortcode_regex( $tagnames = null ) {
// Also, see shortcode_unautop() and shortcode.js.
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation
return
'\\[' // Opening bracket.
return '\\[' // Opening bracket.
. '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]].
. "($tagregexp)" // 2: Shortcode name.
. '(?![\\w-])' // Not followed by word character or hyphen.