mirror of
https://ghproxy.net/https://github.com/fairpm/fair-plugin.git
synced 2025-09-04 10:32:01 +08:00
Make compat.php
compliant with the coding standard. (#165)
This commit is contained in:
parent
2b858dc3c2
commit
10ca60baee
2 changed files with 13 additions and 12 deletions
|
@ -98,7 +98,7 @@ if ( ! function_exists( '_is_utf8_charset' ) ) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'mb_substr' ) ) :
|
||||
if ( ! function_exists( 'mb_substr' ) ) {
|
||||
/**
|
||||
* Compat function to mimic mb_substr().
|
||||
*
|
||||
|
@ -117,7 +117,7 @@ if ( ! function_exists( 'mb_substr' ) ) :
|
|||
function mb_substr( $string, $start, $length = null, $encoding = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.stringFound
|
||||
return _mb_substr( $string, $start, $length, $encoding );
|
||||
}
|
||||
endif;
|
||||
}
|
||||
|
||||
// If _mb_substr already loaded.
|
||||
if ( ! function_exists( '_mb_substr' ) ) {
|
||||
|
@ -174,11 +174,11 @@ if ( ! function_exists( '_mb_substr' ) ) {
|
|||
| \xF4[\x80-\x8F][\x80-\xBF]{2}
|
||||
)/x';
|
||||
|
||||
// Start with 1 element instead of 0 since the first thing we do is pop.
|
||||
$chars = array( '' );
|
||||
// Start with 1 element instead of 0 since the first thing we do is pop.
|
||||
$chars = [ '' ];
|
||||
|
||||
do {
|
||||
// We had some string left over from the last round, but we counted it in that last round.
|
||||
do {
|
||||
// We had some string left over from the last round, but we counted it in that last round.
|
||||
array_pop( $chars );
|
||||
|
||||
/*
|
||||
|
@ -190,13 +190,13 @@ if ( ! function_exists( '_mb_substr' ) ) {
|
|||
$chars = array_merge( $chars, $pieces );
|
||||
|
||||
// If there's anything left over, repeat the loop.
|
||||
} while ( count( $pieces ) > 1 && $str = array_pop( $pieces ) );
|
||||
} while ( count( $pieces ) > 1 && $str = array_pop( $pieces ) ); // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
|
||||
|
||||
return implode( '', array_slice( $chars, $start, $length ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'mb_strlen' ) ) :
|
||||
if ( ! function_exists( 'mb_strlen' ) ) {
|
||||
/**
|
||||
* Compat function to mimic mb_strlen().
|
||||
*
|
||||
|
@ -212,7 +212,7 @@ if ( ! function_exists( 'mb_strlen' ) ) :
|
|||
function mb_strlen( $string, $encoding = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.stringFound
|
||||
return _mb_strlen( $string, $encoding );
|
||||
}
|
||||
endif;
|
||||
}
|
||||
|
||||
// If _mb_strlen is already loaded.
|
||||
if ( ! function_exists( '_mb_strlen' ) ) {
|
||||
|
@ -278,7 +278,7 @@ if ( ! function_exists( '_mb_strlen' ) ) {
|
|||
$count += count( $pieces );
|
||||
|
||||
// If there's anything left over, repeat the loop.
|
||||
} while ( $str = array_pop( $pieces ) );
|
||||
} while ( $str = array_pop( $pieces ) ); // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
|
||||
|
||||
// Fencepost: preg_split() always returns one extra item in the array.
|
||||
return --$count;
|
||||
|
@ -375,7 +375,7 @@ if ( ! function_exists( 'array_is_list' ) ) {
|
|||
* @return bool True if array is a list, false otherwise.
|
||||
*/
|
||||
function array_is_list( $arr ) {
|
||||
if ( ( array() === $arr ) || ( array_values( $arr ) === $arr ) ) {
|
||||
if ( ( [] === $arr ) || ( array_values( $arr ) === $arr ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
<!-- Exclude third-party dependencies -->
|
||||
<exclude-pattern>inc/updater/class-lite\.php</exclude-pattern>
|
||||
<exclude-pattern>inc/compatibility/compat\.php</exclude-pattern>
|
||||
|
||||
<!-- Exclude language files -->
|
||||
<exclude-pattern>languages/*</exclude-pattern>
|
||||
|
@ -56,6 +55,7 @@
|
|||
</rule>
|
||||
|
||||
<rule ref="HM.Functions.NamespacedFunctions.MissingNamespace">
|
||||
<exclude-pattern>inc/compatibility/compat\.php</exclude-pattern>
|
||||
<exclude-pattern>inc/icons/svg\.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
|
@ -70,6 +70,7 @@
|
|||
<!-- Exclude some files from the side effects rules -->
|
||||
<rule ref="PSR1.Files.SideEffects">
|
||||
<exclude-pattern>plugin\.php</exclude-pattern>
|
||||
<exclude-pattern>inc/compatibility/compat\.php</exclude-pattern>
|
||||
<exclude-pattern>inc/icons/svg\.php</exclude-pattern>
|
||||
<exclude-pattern>tests/phpunit/bootstrap\.php</exclude-pattern>
|
||||
</rule>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue