mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-25 03:01:21 +08:00
Replaced substr_compare with strncmp where possible
This commit is contained in:
@@ -332,7 +332,7 @@ class MessageController extends Controller
|
||||
ksort($existingMessages);
|
||||
foreach ($existingMessages as $message => $translation) {
|
||||
if (!isset($merged[$message]) && !isset($todo[$message]) && !$removeUnused) {
|
||||
if (!empty($translation) && substr_compare($translation, '@@', 0, 2) === 0 && substr_compare($translation, '@@', -2) === 0) {
|
||||
if (!empty($translation) && strncmp($translation, '@@', 2) === 0 && substr_compare($translation, '@@', -2) === 0) {
|
||||
$todo[$message] = $translation;
|
||||
} else {
|
||||
$todo[$message] = '@@' . $translation . '@@';
|
||||
|
||||
@@ -109,7 +109,7 @@ class GettextMoFile extends GettextFile
|
||||
$separatorPosition = strpos($id, chr(4));
|
||||
|
||||
|
||||
if (($context && $separatorPosition !== false && !empty($id) && substr_compare($id, $context, 0, $separatorPosition) === 0) ||
|
||||
if (($context && $separatorPosition !== false && strncmp($id, $context, $separatorPosition) === 0) ||
|
||||
(!$context && $separatorPosition === false)) {
|
||||
if ($separatorPosition !== false) {
|
||||
$id = substr($id, $separatorPosition+1);
|
||||
|
||||
@@ -392,7 +392,7 @@ class MessageFormatter extends Component
|
||||
}
|
||||
$selector = trim($plural[$i++]);
|
||||
|
||||
if ($i == 1 && !empty($selector) && substr_compare($selector, 'offset:', 0, 7) === 0) {
|
||||
if ($i == 1 && strncmp($selector, 'offset:', 7) === 0) {
|
||||
$offset = (int) trim(mb_substr($selector, 7, ($pos = mb_strpos(str_replace(["\n", "\r", "\t"], ' ', $selector), ' ', 7)) - 7));
|
||||
$selector = trim(mb_substr($selector, $pos + 1));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user