GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 841b7d...3ed1d3 )
by
unknown
13:44 queued 04:45
created

src/Lingo.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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   GNU General Public License, version 2 (or any later version)
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
/**
30
 * Class Lingo
31
 *
32
 * @package Lingo
33
 * @ingroup Lingo
34
 */
35
class Lingo {
36
37
	/**
38
	 * Deferred settings
39
	 * - registration of _NOGLOSSARY_ magic word
40
	 * - extension description shown on Special:Version
41
	 *
42
	 * @since 2.0.2
43
	 */
44
	public static function initExtension() {
0 ignored issues
show
initExtension uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
45
46
		$GLOBALS[ 'wgExtensionFunctions' ][] = function () {
47
48
			$parser = LingoParser::getInstance();
49
50
			$backend = new $GLOBALS[ 'wgexLingoBackend' ]();
51
52
			$parser->setBackend( $backend );
53
54
			\Hooks::register( 'ContentAlterParserOutput', [ $parser, 'parse' ] );
55
56
			\Hooks::register('GetDoubleUnderscoreIDs', function ( array &$doubleUnderscoreIDs ) {
57
				$doubleUnderscoreIDs[] = 'noglossary';
58
				return true;
59
			} );
60
61
			\Hooks::register( 'ParserFirstCallInit', function ( \Parser $parser ) {
62
63
				$parser->setHook( 'noglossary', function ( $input, array $args, \Parser $parser, \PPFrame $frame ) {
64
					$output = $parser->recursiveTagParse( $input, $frame );
65
					return '<span class="noglossary">' . $output . '</span>';
66
				} );
67
68
				return true;
69
			} );
70
71
			\Hooks::register( 'SpecialPageBeforeExecute', function ( \SpecialPage $specialPage, $subPage ) {
0 ignored issues
show
The parameter $subPage 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...
72
73
				if ( $specialPage instanceof \SpecialVersion ) {
74
					foreach ( $GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ] as $index => $description ) {
75
						if ( $GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ][ $index ][ 'name' ] === 'Lingo' ) {
76
							$GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ][ $index ][ 'description' ] = wfMessage( 'lingo-desc', $GLOBALS[ 'wgexLingoPage' ] ?: wfMessage( 'lingo-terminologypagename' )->inContentLanguage()->text() )->text();
77
						}
78
					}
79
				}
80
81
				return true;
82
			} );
83
		};
84
	}
85
86
}
87