Lingo::initExtension()   A
last analyzed

Complexity

Conditions 5
Paths 1

Size

Total Lines 40
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 5
eloc 22
c 3
b 0
f 0
nc 1
nop 0
dl 0
loc 40
ccs 0
cts 22
cp 0
crap 30
rs 9.2568
1
<?php
2
/**
3
 * File containing the Lingo class
4
 *
5
 * This file is part of the MediaWiki extension Lingo.
6
 *
7
 * @copyright 2011 - 2018, Stephan Gambke
8
 * @license GPL-2.0-or-later
9
 *
10
 * The Lingo extension is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by the Free
12
 * Software Foundation; either version 2 of the License, or (at your option) any
13
 * later version.
14
 *
15
 * The Lingo extension is distributed in the hope that it will be useful, but
16
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18
 * details.
19
 *
20
 * You should have received a copy of the GNU General Public License along
21
 * with this program. If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 * @file
24
 * @ingroup Lingo
25
 */
26
27
namespace Lingo;
28
29
use MediaWiki\MediaWikiServices;
0 ignored issues
show
Bug introduced by
The type MediaWiki\MediaWikiServices was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
31
/**
32
 * Class Lingo
33
 *
34
 * @package Lingo
35
 * @ingroup Lingo
36
 */
37
class Lingo {
38
39
	/**
40
	 * Deferred settings
41
	 * - registration of _NOGLOSSARY_ magic word
42
	 * - extension description shown on Special:Version
43
	 *
44
	 * @since 2.0.2
45
	 */
46
	public static function initExtension() {
47
		$GLOBALS[ 'wgExtensionFunctions' ][] = function () {
48
			$parser = LingoParser::getInstance();
49
50
			$backend = new $GLOBALS[ 'wgexLingoBackend' ]();
51
52
			$parser->setBackend( $backend );
53
54
			\Hooks::register( 'ContentAlterParserOutput', function () use ( $parser ){
0 ignored issues
show
Bug introduced by
The type Hooks was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
55
				$parser->parse( MediaWikiServices::getInstance()->getParser() );
56
			} );
57
58
			\Hooks::register( 'ApiMakeParserOptions', function ( \ParserOptions $popts, \Title $title, array $params ) use ( $parser ){
0 ignored issues
show
Bug introduced by
The type Title was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
The type ParserOptions was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
59
				$parser->setApiParams( $params );
60
			} );
61
62
			\Hooks::register( 'GetDoubleUnderscoreIDs', function ( array &$doubleUnderscoreIDs ) {
63
				$doubleUnderscoreIDs[] = 'noglossary';
64
				return true;
65
			} );
66
67
			\Hooks::register( 'ParserFirstCallInit', function ( \Parser $parser ) {
0 ignored issues
show
Bug introduced by
The type Parser was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
68
				$parser->setHook( 'noglossary', function ( $input, array $args, \Parser $parser, \PPFrame $frame ) {
0 ignored issues
show
Bug introduced by
The type PPFrame was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
69
					$output = $parser->recursiveTagParse( $input, $frame );
70
					return '<span class="noglossary">' . $output . '</span>';
71
				} );
72
73
				return true;
74
			} );
75
76
			\Hooks::register( 'SpecialPageBeforeExecute', function ( \SpecialPage $specialPage, $subPage ) {
0 ignored issues
show
Unused Code introduced by
The parameter $subPage is not used and could be removed. ( Ignorable by Annotation )

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

76
			\Hooks::register( 'SpecialPageBeforeExecute', function ( \SpecialPage $specialPage, /** @scrutinizer ignore-unused */ $subPage ) {

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

Loading history...
Bug introduced by
The type SpecialPage was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
77
				if ( $specialPage instanceof \SpecialVersion ) {
0 ignored issues
show
Bug introduced by
The type SpecialVersion was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
78
					foreach ( $GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ] as $index => $description ) {
79
						if ( $GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ][ $index ][ 'name' ] === 'Lingo' ) {
80
							$GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ][ $index ][ 'description' ] = wfMessage( 'lingo-desc', $GLOBALS[ 'wgexLingoPage' ] ?: wfMessage( 'lingo-terminologypagename' )->inContentLanguage()->text() )->text();
0 ignored issues
show
Bug introduced by
The function wfMessage was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

80
							$GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ][ $index ][ 'description' ] = /** @scrutinizer ignore-call */ wfMessage( 'lingo-desc', $GLOBALS[ 'wgexLingoPage' ] ?: wfMessage( 'lingo-terminologypagename' )->inContentLanguage()->text() )->text();
Loading history...
81
						}
82
					}
83
				}
84
85
				return true;
86
			} );
87
		};
88
	}
89
90
}
91