Skip to content

Commit 605d2f7

Browse files
committed
Deletes duplicate code and removes incorrect second parameter strlen
1 parent c8c576e commit 605d2f7

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -925,15 +925,12 @@ private function validate_prefixes() {
925925
continue;
926926
}
927927

928-
if ( function_exists( 'iconv_strlen' ) && iconv_strlen( $prefix, $this->phpcsFile->config->encoding ) < self::MIN_PREFIX_LENGTH ) {
929-
$this->phpcsFile->addError(
930-
'The "%s" prefix is too short. Short prefixes are not unique enough and may cause name collisions with other code.',
931-
0,
932-
'ShortPrefixPassed',
933-
array( $prefix )
934-
);
935-
continue;
936-
} elseif ( ! function_exists( 'iconv_strlen' ) && strlen( $prefix, $this->phpcsFile->config->encoding ) < self::MIN_PREFIX_LENGTH ) {
928+
$prefix_length = strlen( $prefix );
929+
if ( function_exists( 'iconv_strlen' ) ) {
930+
$prefix_length = iconv_strlen( $prefix, $this->phpcsFile->config->encoding );
931+
}
932+
933+
if ( $prefix_length < self::MIN_PREFIX_LENGTH ) {
937934
$this->phpcsFile->addError(
938935
'The "%s" prefix is too short. Short prefixes are not unique enough and may cause name collisions with other code.',
939936
0,

0 commit comments

Comments
 (0)