Completed
Push — master ( 097423...ee4fab )
by Jeroen De
10s
created

SemanticResultFormats.i18n.php ➔ wfJsonI18nShimbca08b007f0d711a()   B

Complexity

Conditions 6
Paths 3

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 6
eloc 12
nc 3
nop 3
dl 0
loc 18
rs 8.8571
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 15 and the first side effect is on line 34.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * This is a backwards-compatibility shim, generated by:
4
 * https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
5
 *
6
 * Beginning with MediaWiki 1.23, translation strings are stored in json files,
7
 * and the EXTENSION.i18n.php file only exists to provide compatibility with
8
 * older releases of MediaWiki. For more information about this migration, see:
9
 * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
10
 *
11
 * This shim maintains compatibility back to MediaWiki 1.17.
12
 */
13
$messages = array();
14
if ( !function_exists( 'wfJsonI18nShimbca08b007f0d711a' ) ) {
15
	function wfJsonI18nShimbca08b007f0d711a( $cache, $code, &$cachedData ) {
0 ignored issues
show
Unused Code introduced by
The parameter $cache is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
		$codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] );
17
		foreach ( $codeSequence as $csCode ) {
18
			$fileName = dirname( __FILE__ ) . "/i18n/$csCode.json";
19
			if ( is_readable( $fileName ) ) {
20
				$data = FormatJson::decode( file_get_contents( $fileName ), true );
21
				foreach ( array_keys( $data ) as $key ) {
22
					if ( $key === '' || $key[0] === '@' ) {
23
						unset( $data[$key] );
24
					}
25
				}
26
				$cachedData['messages'] = array_merge( $data, $cachedData['messages'] );
27
			}
28
29
			$cachedData['deps'][] = new FileDependency( $fileName );
30
		}
31
		return true;
32
	}
33
34
	$GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 'wfJsonI18nShimbca08b007f0d711a';
35
}
36