get_list_of_locales()   F
last analyzed

Complexity

Conditions 15
Paths 643

Size

Total Lines 58
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 15
eloc 37
c 0
b 0
f 0
nc 643
nop 1
dl 0
loc 58
rs 2.2458

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
   Copyright (c) 2005 Steven Armstrong <sa at c-area dot ch>
4
   Copyright (c) 2009 Danilo Segan <[email protected]>
5
6
   Drop in replacement for native gettext.
7
8
   This file is part of PHP-gettext.
9
10
   PHP-gettext is free software; you can redistribute it and/or modify
11
   it under the terms of the GNU General Public License as published by
12
   the Free Software Foundation; either version 2 of the License, or
13
   (at your option) any later version.
14
15
   PHP-gettext is distributed in the hope that it will be useful,
16
   but WITHOUT ANY WARRANTY; without even the implied warranty of
17
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
   GNU General Public License for more details.
19
20
   You should have received a copy of the GNU General Public License
21
   along with PHP-gettext; if not, write to the Free Software
22
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
24
*/
25
/*
26
LC_CTYPE        0
27
LC_NUMERIC      1
28
LC_TIME         2
29
LC_COLLATE      3
30
LC_MONETARY     4
31
LC_MESSAGES     5
32
LC_ALL          6
33
*/
34
35
// LC_MESSAGES is not available if php-gettext is not loaded
36
// while the other constants are already available from session extension.
37
if (!defined('LC_MESSAGES')) {
38
    define('LC_MESSAGES', 5);
39
}
40
41
require('streams.php');
42
require('gettext.php');
43
44
45
// Variables
46
47
global $text_domains, $default_domain, $LC_CATEGORIES, $EMULATEGETTEXT, $CURRENTLOCALE;
48
$text_domains = array();
49
$default_domain = 'messages';
50
$LC_CATEGORIES = array('LC_CTYPE', 'LC_NUMERIC', 'LC_TIME', 'LC_COLLATE', 'LC_MONETARY', 'LC_MESSAGES', 'LC_ALL');
51
$EMULATEGETTEXT = 0;
52
$CURRENTLOCALE = '';
53
54
/* Class to hold a single domain included in $text_domains. */
55
class domain {
56
    var $l10n;
57
    var $path;
58
    var $codeset;
59
}
60
61
// Utility functions
62
63
/**
64
 * Return a list of locales to try for any POSIX-style locale specification.
65
 */
66
function get_list_of_locales($locale) {
67
    /* Figure out all possible locale names and start with the most
68
   * specific ones.  I.e. for sr_CS.UTF-8@latin, look through all of
69
   * sr_CS.UTF-8@latin, sr_CS@latin, sr@latin, sr_CS.UTF-8, sr_CS, sr.
70
   */
71
    $locale_names = array();
72
    $lang = null;
73
    $country = null;
74
    $charset = null;
75
    $modifier = null;
76
    if ($locale) {
77
    if (preg_match("/^(?P<lang>[a-z]{2,3})"              // language code
78
                    ."(?:_(?P<country>[A-Z]{2}))?"           // country code
79
                    ."(?:\.(?P<charset>[-A-Za-z0-9_]+))?"    // charset
80
                    ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier
81
                    $locale, $matches)) {
82
83
        if (isset($matches["lang"])) {
84
            $lang = $matches["lang"];
85
        }
86
        if (isset($matches["country"])) {
87
            $country = $matches["country"];
88
        }
89
        if (isset($matches["charset"])) {
90
            $charset = $matches["charset"];
91
        }
92
        if (isset($matches["modifier"])) {
93
            $modifier = $matches["modifier"];
94
        }
95
96
        if ($modifier) {
97
        if ($country) {
98
            if ($charset) {
99
                        array_push($locale_names, "${lang}_$country.$charset@$modifier");
100
            }
101
            array_push($locale_names, "${lang}_$country@$modifier");
102
        } elseif ($charset) {
103
                    array_push($locale_names, "${lang}.$charset@$modifier");
104
        }
105
        array_push($locale_names, "$lang@$modifier");
106
        }
107
        if ($country) {
108
        if ($charset) {
109
                    array_push($locale_names, "${lang}_$country.$charset");
110
        }
111
        array_push($locale_names, "${lang}_$country");
112
        } elseif ($charset) {
113
                array_push($locale_names, "${lang}.$charset");
114
        }
115
        array_push($locale_names, $lang);
116
    }
117
118
    // If the locale name doesn't match POSIX style, just include it as-is.
119
    if (!in_array($locale, $locale_names)) {
120
            array_push($locale_names, $locale);
121
    }
122
    }
123
    return $locale_names;
124
}
125
126
/**
127
 * Utility function to get a StreamReader for the given text domain.
128
 */
129
function _get_reader($domain = null, $category = 5, $enable_cache = true) {
130
    global $text_domains, $default_domain, $LC_CATEGORIES;
131
    if (!isset($domain)) {
132
        $domain = $default_domain;
133
    }
134
    if (!isset($text_domains[$domain]->l10n)) {
135
        // get the current locale
136
        $locale = _setlocale(LC_MESSAGES, 0);
137
        $bound_path = isset($text_domains[$domain]->path) ?
138
          $text_domains[$domain]->path : './';
139
        $subpath = $LC_CATEGORIES[$category]."/$domain.mo";
140
141
        $locale_names = get_list_of_locales($locale);
142
        $input = null;
143
        foreach ($locale_names as $locale) {
144
            $full_path = $bound_path.$locale."/".$subpath;
145
            if (file_exists($full_path)) {
146
            $input = new FileReader($full_path);
147
            break;
148
            }
149
        }
150
151
        if (!array_key_exists($domain, $text_domains)) {
152
            // Initialize an empty domain object.
153
            $text_domains[$domain] = new domain();
154
        }
155
        $text_domains[$domain]->l10n = new gettext_reader($input,
156
                                                            $enable_cache);
157
    }
158
    return $text_domains[$domain]->l10n;
159
}
160
161
/**
162
 * Returns whether we are using our emulated gettext API or PHP built-in one.
163
 */
164
function locale_emulation() {
165
    global $EMULATEGETTEXT;
166
    return $EMULATEGETTEXT;
167
}
168
169
/**
170
 * Checks if the current locale is supported on this system.
171
 */
172
function _check_locale_and_function($function = false) {
173
    global $EMULATEGETTEXT;
174
    if ($function and !function_exists($function)) {
175
            return false;
176
    }
177
    return !$EMULATEGETTEXT;
178
}
179
180
/**
181
 * Get the codeset for the given domain.
182
 */
183
function _get_codeset($domain = null) {
184
    global $text_domains, $default_domain, $LC_CATEGORIES;
185
    if (!isset($domain)) {
186
        $domain = $default_domain;
187
    }
188
    return (isset($text_domains[$domain]->codeset)) ? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding');
189
}
190
191
/**
192
 * Convert the given string to the encoding set by bind_textdomain_codeset.
193
 */
194
function _encode($text) {
195
    $target_encoding = _get_codeset();
196
    if (function_exists("mb_detect_encoding")) {
197
    $source_encoding = mb_detect_encoding($text);
198
    if ($source_encoding != $target_encoding) {
199
            $text = mb_convert_encoding($text, $target_encoding, $source_encoding);
200
    }
201
    }
202
    return $text;
203
}
204
205
206
// Custom implementation of the standard gettext related functions
207
208
/**
209
 * Returns passed in $locale, or environment variable $LANG if $locale == ''.
210
 */
211
function _get_default_locale($locale) {
212
    if ($locale == '') {
213
        // emulate variable support
214
    return getenv('LANG');
215
    } else {
216
        return $locale;
217
    }
218
    }
219
220
/**
221
 * Sets a requested locale, if needed emulates it.
222
 */
223
function _setlocale($category, $locale) {
224
    global $CURRENTLOCALE, $EMULATEGETTEXT;
225
    if ($locale === 0) { // use === to differentiate between string "0"
226
        if ($CURRENTLOCALE != '') {
227
                    return $CURRENTLOCALE;
228
        } else {
229
                    // obey LANG variable, maybe extend to support all of LC_* vars
230
            // even if we tried to read locale without setting it first
231
            return _setlocale($category, $CURRENTLOCALE);
232
        }
233
    } else {
234
        if (function_exists('setlocale')) {
235
            $ret = setlocale($category, $locale);
236
            if (($locale == '' and !$ret) or // failed setting it by env
237
              ($locale != '' and $ret != $locale)) { // failed setting it
238
            // Failed setting it according to environment.
239
            $CURRENTLOCALE = _get_default_locale($locale);
240
            $EMULATEGETTEXT = 1;
241
            } else {
242
            $CURRENTLOCALE = $ret;
243
            $EMULATEGETTEXT = 0;
244
            }
245
        } else {
246
            // No function setlocale(), emulate it all.
247
            $CURRENTLOCALE = _get_default_locale($locale);
248
            $EMULATEGETTEXT = 1;
249
        }
250
        // Allow locale to be changed on the go for one translation domain.
251
        global $text_domains, $default_domain;
252
        if (array_key_exists($default_domain, $text_domains)) {
253
            unset($text_domains[$default_domain]->l10n);
254
        }
255
        return $CURRENTLOCALE;
256
    }
257
}
258
259
/**
260
 * Sets the path for a domain.
261
 */
262
function _bindtextdomain($domain, $path) {
263
    global $text_domains;
264
    // ensure $path ends with a slash ('/' should work for both, but lets still play nice)
265
    if (substr(php_uname(), 0, 7) == "Windows") {
266
        if ($path[strlen($path) - 1] != '\\' and $path[strlen($path) - 1] != '/') {
267
                $path .= '\\';
268
        }
269
    } else {
270
        if ($path[strlen($path) - 1] != '/') {
271
                $path .= '/';
272
        }
273
    }
274
    if (!array_key_exists($domain, $text_domains)) {
275
        // Initialize an empty domain object.
276
        $text_domains[$domain] = new domain();
277
    }
278
    $text_domains[$domain]->path = $path;
279
}
280
281
/**
282
 * Specify the character encoding in which the messages from the DOMAIN message catalog will be returned.
283
 */
284
function _bind_textdomain_codeset($domain, $codeset) {
285
    global $text_domains;
286
    $text_domains[$domain]->codeset = $codeset;
287
}
288
289
/**
290
 * Sets the default domain.
291
 */
292
function _textdomain($domain) {
293
    global $default_domain;
294
    $default_domain = $domain;
295
}
296
297
/**
298
 * Lookup a message in the current domain.
299
 */
300
function _gettext($msgid) {
301
    $l10n = _get_reader();
302
    return _encode($l10n->translate($msgid));
303
}
304
305
/**
306
 * Alias for gettext.
307
 */
308
function __($msgid) {
309
    return _gettext($msgid);
310
}
311
312
/**
313
 * Plural version of gettext.
314
 */
315
function _ngettext($singular, $plural, $number) {
316
    $l10n = _get_reader();
317
    return _encode($l10n->ngettext($singular, $plural, $number));
318
}
319
320
/**
321
 * Override the current domain.
322
 */
323
function _dgettext($domain, $msgid) {
324
    $l10n = _get_reader($domain);
325
    return _encode($l10n->translate($msgid));
326
}
327
328
/**
329
 * Plural version of dgettext.
330
 */
331
function _dngettext($domain, $singular, $plural, $number) {
332
    $l10n = _get_reader($domain);
333
    return _encode($l10n->ngettext($singular, $plural, $number));
334
}
335
336
/**
337
 * Overrides the domain and category for a single lookup.
338
 */
339
function _dcgettext($domain, $msgid, $category) {
340
    $l10n = _get_reader($domain, $category);
341
    return _encode($l10n->translate($msgid));
342
}
343
/**
344
 * Plural version of dcgettext.
345
 */
346
function _dcngettext($domain, $singular, $plural, $number, $category) {
347
    $l10n = _get_reader($domain, $category);
348
    return _encode($l10n->ngettext($singular, $plural, $number));
349
}
350
351
/**
352
 * Context version of gettext.
353
 */
354
function _pgettext($context, $msgid) {
355
    $l10n = _get_reader();
356
    return _encode($l10n->pgettext($context, $msgid));
357
}
358
359
/**
360
 * Override the current domain in a context gettext call.
361
 */
362
function _dpgettext($domain, $context, $msgid) {
363
    $l10n = _get_reader($domain);
364
    return _encode($l10n->pgettext($context, $msgid));
365
}
366
367
/**
368
 * Overrides the domain and category for a single context-based lookup.
369
 */
370
function _dcpgettext($domain, $context, $msgid, $category) {
371
    $l10n = _get_reader($domain, $category);
372
    return _encode($l10n->pgettext($context, $msgid));
373
}
374
375
/**
376
 * Context version of ngettext.
377
 */
378
function _npgettext($context, $singular, $plural) {
379
    $l10n = _get_reader();
380
    return _encode($l10n->npgettext($context, $singular, $plural));
381
}
382
383
/**
384
 * Override the current domain in a context ngettext call.
385
 */
386
function _dnpgettext($domain, $context, $singular, $plural) {
387
    $l10n = _get_reader($domain);
388
    return _encode($l10n->npgettext($context, $singular, $plural));
389
}
390
391
/**
392
 * Overrides the domain and category for a plural context-based lookup.
393
 */
394
function _dcnpgettext($domain, $context, $singular, $plural, $category) {
395
    $l10n = _get_reader($domain, $category);
396
    return _encode($l10n->npgettext($context, $singular, $plural));
397
}
398
399
400
401
// Wrappers to use if the standard gettext functions are available,
402
// but the current locale is not supported by the system.
403
// Use the standard impl if the current locale is supported, use the
404
// custom impl otherwise.
405
406
function T_setlocale($category, $locale) {
407
    return _setlocale($category, $locale);
408
}
409
410
function T_bindtextdomain($domain, $path) {
411
    if (_check_locale_and_function()) {
412
        return bindtextdomain($domain, $path);
413
    } else {
414
        return _bindtextdomain($domain, $path);
0 ignored issues
show
Bug introduced by
Are you sure the usage of _bindtextdomain($domain, $path) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
415
    }
416
    }
417
function T_bind_textdomain_codeset($domain, $codeset) {
418
    // bind_textdomain_codeset is available only in PHP 4.2.0+
419
    if (_check_locale_and_function('bind_textdomain_codeset')) {
420
            return bind_textdomain_codeset($domain, $codeset);
421
    } else {
422
        return _bind_textdomain_codeset($domain, $codeset);
0 ignored issues
show
Bug introduced by
Are you sure the usage of _bind_textdomain_codeset($domain, $codeset) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
423
    }
424
    }
425
function T_textdomain($domain) {
426
    if (_check_locale_and_function()) {
427
        return textdomain($domain);
428
    } else {
429
        return _textdomain($domain);
0 ignored issues
show
Bug introduced by
Are you sure the usage of _textdomain($domain) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
430
    }
431
    }
432
function T_gettext($msgid) {
433
    if (_check_locale_and_function()) {
434
        return gettext($msgid);
435
    } else {
436
        return _gettext($msgid);
437
    }
438
    }
439
function T_($msgid) {
440
    if (_check_locale_and_function()) {
441
        return _($msgid);
442
    }
443
    return __($msgid);
444
}
445
function T_ngettext($singular, $plural, $number) {
446
    if (_check_locale_and_function()) {
447
            return ngettext($singular, $plural, $number);
448
    } else {
449
        return _ngettext($singular, $plural, $number);
450
    }
451
    }
452
function T_dgettext($domain, $msgid) {
453
    if (_check_locale_and_function()) {
454
        return dgettext($domain, $msgid);
455
    } else {
456
        return _dgettext($domain, $msgid);
457
    }
458
    }
459
function T_dngettext($domain, $singular, $plural, $number) {
460
    if (_check_locale_and_function()) {
461
            return dngettext($domain, $singular, $plural, $number);
462
    } else {
463
        return _dngettext($domain, $singular, $plural, $number);
464
    }
465
    }
466
function T_dcgettext($domain, $msgid, $category) {
467
    if (_check_locale_and_function()) {
468
            return dcgettext($domain, $msgid, $category);
469
    } else {
470
        return _dcgettext($domain, $msgid, $category);
471
    }
472
    }
473
function T_dcngettext($domain, $singular, $plural, $number, $category) {
474
    if (_check_locale_and_function()) {
475
            return dcngettext($domain, $singular, $plural, $number, $category);
476
    } else {
477
        return _dcngettext($domain, $singular, $plural, $number, $category);
478
    }
479
    }
480
481
function T_pgettext($context, $msgid) {
482
    if (_check_locale_and_function('pgettext')) {
483
        return pgettext($context, $msgid);
484
    } else {
485
        return _pgettext($context, $msgid);
486
    }
487
    }
488
489
function T_dpgettext($domain, $context, $msgid) {
490
    if (_check_locale_and_function('dpgettext')) {
491
        return dpgettext($domain, $context, $msgid);
492
    } else {
493
        return _dpgettext($domain, $context, $msgid);
494
    }
495
    }
496
497
function T_dcpgettext($domain, $context, $msgid, $category) {
498
    if (_check_locale_and_function('dcpgettext')) {
499
        return dcpgettext($domain, $context, $msgid, $category);
500
    } else {
501
        return _dcpgettext($domain, $context, $msgid, $category);
502
    }
503
    }
504
505
function T_npgettext($context, $singular, $plural, $number) {
506
    if (_check_locale_and_function('npgettext')) {
507
            return npgettext($context, $singular, $plural, $number);
508
    } else {
509
            return _npgettext($context, $singular, $plural, $number);
0 ignored issues
show
Unused Code introduced by
The call to _npgettext() has too many arguments starting with $number. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

509
            return /** @scrutinizer ignore-call */ _npgettext($context, $singular, $plural, $number);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
510
    }
511
    }
512
513
function T_dnpgettext($domain, $context, $singular, $plural, $number) {
514
    if (_check_locale_and_function('dnpgettext')) {
515
        return dnpgettext($domain, $context, $singular, $plural, $number);
516
    } else {
517
        return _dnpgettext($domain, $context, $singular, $plural, $number);
0 ignored issues
show
Unused Code introduced by
The call to _dnpgettext() has too many arguments starting with $number. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

517
        return /** @scrutinizer ignore-call */ _dnpgettext($domain, $context, $singular, $plural, $number);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
518
    }
519
    }
520
521
function T_dcnpgettext($domain, $context, $singular, $plural,
522
                        $number, $category) {
523
    if (_check_locale_and_function('dcnpgettext')) {
524
            return dcnpgettext($domain, $context, $singular,
525
                            $plural, $number, $category);
526
    } else {
527
            return _dcnpgettext($domain, $context, $singular,
528
                            $plural, $number, $category);
0 ignored issues
show
Unused Code introduced by
The call to _dcnpgettext() has too many arguments starting with $category. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

528
            return /** @scrutinizer ignore-call */ _dcnpgettext($domain, $context, $singular,

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
529
    }
530
    }
531
532
533
534
// Wrappers used as a drop in replacement for the standard gettext functions
535
536
if (!function_exists('gettext')) {
537
    function bindtextdomain($domain, $path) {
538
        return _bindtextdomain($domain, $path);
0 ignored issues
show
Bug introduced by
Are you sure the usage of _bindtextdomain($domain, $path) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
539
    }
540
    function bind_textdomain_codeset($domain, $codeset) {
541
        return _bind_textdomain_codeset($domain, $codeset);
0 ignored issues
show
Bug introduced by
Are you sure the usage of _bind_textdomain_codeset($domain, $codeset) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
542
    }
543
    function textdomain($domain) {
544
        return _textdomain($domain);
0 ignored issues
show
Bug introduced by
Are you sure the usage of _textdomain($domain) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
545
    }
546
    function gettext($msgid) {
547
        return _gettext($msgid);
548
    }
549
    function _($msgid) {
550
        return __($msgid);
551
    }
552
    function ngettext($singular, $plural, $number) {
553
        return _ngettext($singular, $plural, $number);
554
    }
555
    function dgettext($domain, $msgid) {
556
        return _dgettext($domain, $msgid);
557
    }
558
    function dngettext($domain, $singular, $plural, $number) {
559
        return _dngettext($domain, $singular, $plural, $number);
560
    }
561
    function dcgettext($domain, $msgid, $category) {
562
        return _dcgettext($domain, $msgid, $category);
563
    }
564
    function dcngettext($domain, $singular, $plural, $number, $category) {
565
        return _dcngettext($domain, $singular, $plural, $number, $category);
566
    }
567
    function pgettext($context, $msgid) {
568
        return _pgettext($context, $msgid);
569
    }
570
    function npgettext($context, $singular, $plural, $number) {
571
        return _npgettext($context, $singular, $plural, $number);
0 ignored issues
show
Unused Code introduced by
The call to _npgettext() has too many arguments starting with $number. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

571
        return /** @scrutinizer ignore-call */ _npgettext($context, $singular, $plural, $number);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
572
    }
573
    function dpgettext($domain, $context, $msgid) {
574
        return _dpgettext($domain, $context, $msgid);
575
    }
576
    function dnpgettext($domain, $context, $singular, $plural, $number) {
577
        return _dnpgettext($domain, $context, $singular, $plural, $number);
0 ignored issues
show
Unused Code introduced by
The call to _dnpgettext() has too many arguments starting with $number. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

577
        return /** @scrutinizer ignore-call */ _dnpgettext($domain, $context, $singular, $plural, $number);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
578
    }
579
    function dcpgettext($domain, $context, $msgid, $category) {
580
        return _dcpgettext($domain, $context, $msgid, $category);
581
    }
582
    function dcnpgettext($domain, $context, $singular, $plural,
583
                            $number, $category) {
584
        return _dcnpgettext($domain, $context, $singular, $plural,
585
                            $number, $category);
0 ignored issues
show
Unused Code introduced by
The call to _dcnpgettext() has too many arguments starting with $category. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

585
        return /** @scrutinizer ignore-call */ _dcnpgettext($domain, $context, $singular, $plural,

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
586
    }
587
}
588
589
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
590