Skip to content

Commit c8c576e

Browse files
committed
Adds fallback for sniff when iconv is not available
1 parent d8baf91 commit c8c576e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,14 @@ private function validate_prefixes() {
933933
array( $prefix )
934934
);
935935
continue;
936+
} elseif ( ! function_exists( 'iconv_strlen' ) && strlen( $prefix, $this->phpcsFile->config->encoding ) < self::MIN_PREFIX_LENGTH ) {
937+
$this->phpcsFile->addError(
938+
'The "%s" prefix is too short. Short prefixes are not unique enough and may cause name collisions with other code.',
939+
0,
940+
'ShortPrefixPassed',
941+
array( $prefix )
942+
);
943+
continue;
936944
}
937945

938946
// Validate the prefix against characters allowed for function, class, constant names etc.

0 commit comments

Comments
 (0)