diff --git a/potx.inc b/potx.inc index 14d4824..3170c2c 100644 --- a/potx.inc +++ b/potx.inc @@ -984,6 +984,11 @@ function _potx_find_log_calls($file, $save_callback) { $depth--; } $tn++; + if ($depth < 0) { + // There is no second argument. This log() call was a false + // positive, continue with the next one. + continue 2; + } } // Get further parameters list($comma, $message, $par2) = array($_potx_tokens[$tn], $_potx_tokens[$tn+1], $_potx_tokens[$tn+2]); @@ -1039,6 +1044,11 @@ function _potx_find_format_plural_calls($file, $save_callback, $function_name = $depth--; } $tn++; + if ($depth < 0) { + // There is no second argument. This $function_name() call was a + // false positive, continue with the next one. + continue 2; + } } // Get further parameters list($comma1, $singular, $comma2, $plural, $par2) = array($_potx_tokens[$tn], $_potx_tokens[$tn+1], $_potx_tokens[$tn+2], $_potx_tokens[$tn+3], $_potx_tokens[$tn+4]); diff --git a/tests/potx_test_6.module b/tests/potx_test_6.module index ca7178b..198c63e 100644 --- a/tests/potx_test_6.module +++ b/tests/potx_test_6.module @@ -39,6 +39,8 @@ function potx_test_6_menu_alter(&$items) { function potx_test_6_page() { t('This is a test string.'); format_plural($count, '1 test string', '@count test strings'); + format_plural($count); + format_plural(); watchdog('test watchdog type', 'My watchdog message'); st('Installer only test string'); diff --git a/tests/potx_test_8.module b/tests/potx_test_8.module index def9a05..a9b70fc 100644 --- a/tests/potx_test_8.module +++ b/tests/potx_test_8.module @@ -25,8 +25,11 @@ function potx_test_8_example() { $g->alert('Alert message'); $h->emergency('Emergency message'); $i->log(1, 'Log message'); - $i->log($boo, 'Log message 2'); - $i->log(potx_test_8_sample(), 'Log message 3'); + $j->log('false positive'); + $k->log($boo, 'Log message 2'); + $l->log($another_false_positive); + $m->log(potx_test_8_sample(), 'Log message 3'); + $n->log(); } /** @@ -64,6 +67,8 @@ class PotxTestD8 { function testFormatPlural() { $this->formatPlural($count, '1 formatPlural test string', '@count formatPlural test strings'); $this->formatPlural($count, '1 formatPlural test string in context', '@count formatPlural test strings in context', array(), array('context' => 'Test context')); + $this->formatPlural($count); + $this->formatPlural(); \Drupal::translation()->formatPlural($count, '1 translation->formatPlural test string in context', '@count translation->formatPlural test strings in context', array(), array('context' => 'Test context')); \Drupal::translation()->formatPlural($count, '1 translation->formatPlural test string', '@count translation->formatPlural test strings');