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.
Test Setup Failed
Push — master ( 1f58dd...e46154 )
by
unknown
31:29
created

src/MessageLog.php (19 issues)

1
<?php
2
3
/**
4
 * File holding the Lingo\MessageLog class.
5
 *
6
 * This file is part of the MediaWiki extension Lingo.
7
 *
8
 * @copyright 2011 - 2018, Stephan Gambke
9
 * @license GPL-2.0-or-later
10
 *
11
 * The Lingo extension is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by the Free
13
 * Software Foundation; either version 2 of the License, or (at your option) any
14
 * later version.
15
 *
16
 * The Lingo extension is distributed in the hope that it will be useful, but
17
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19
 * details.
20
 *
21
 * You should have received a copy of the GNU General Public License along
22
 * with this program. If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 * @author Stephan Gambke
25
 *
26
 * @file
27
 * @ingroup Lingo
28
 */
29
30
namespace Lingo;
31
32
use Html;
0 ignored issues
show
The type Html 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...
33
use Parser;
0 ignored issues
show
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...
34
use ParserOptions;
0 ignored issues
show
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...
35
36
/**
37
 * This class holds messages (errors, warnings, notices) for Lingo
38
 *
39
 * Contains a static function to initiate the parsing.
40
 *
41
 * @ingroup Lingo
42
 */
43
class MessageLog {
44
45
	private $mMessages = [];
46
	private $mParser = null;
47
48
	const MESSAGE_ERROR = 1;
49
	const MESSAGE_WARNING = 2;
50
	const MESSAGE_NOTICE = 3;
51
52
	/**
53
	 * @param $message
54
	 * @param int $severity
55
	 */
56
	public function addMessage( $message, $severity = self::MESSAGE_NOTICE ) {
57
		$this->mMessages[] = [ $message, $severity ];
58
59
		// log errors and warnings in debug log
60
		if ( $severity == self::MESSAGE_WARNING ||
0 ignored issues
show
Operator == prohibited; use === instead
Loading history...
61
			$severity == self::MESSAGE_ERROR
0 ignored issues
show
Operator == prohibited; use === instead
Loading history...
62
		) {
63
			wfDebug( $message );
0 ignored issues
show
The function wfDebug 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

63
			/** @scrutinizer ignore-call */ 
64
   wfDebug( $message );
Loading history...
64
		}
65
	}
66
67
	/**
68
	 * @param $message
69
	 */
70
	public function addError( $message ) {
71
		$this->mMessages[] = [ $message, self::MESSAGE_ERROR ];
72
		wfDebug( "Error: $message\n" );
0 ignored issues
show
The function wfDebug 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

72
		/** @scrutinizer ignore-call */ 
73
  wfDebug( "Error: $message\n" );
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $message instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
73
	}
74
75
	/**
76
	 * @param $message
77
	 */
78
	public function addWarning( $message ) {
79
		$this->mMessages[] = [ $message, self::MESSAGE_WARNING ];
80
		wfDebug( "Warning: $message\n" );
0 ignored issues
show
The function wfDebug 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
		/** @scrutinizer ignore-call */ 
81
  wfDebug( "Warning: $message\n" );
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $message instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
81
	}
82
83
	/**
84
	 * @param $message
85
	 */
86
	public function addNotice( $message ) {
87
		$this->mMessages[] = [ $message, self::MESSAGE_NOTICE ];
88
	}
89
90
	/**
91
	 * @param int $severity
92
	 * @param null $header
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $header is correct as it would always require null to be passed?
Loading history...
93
	 * @return null|string
94
	 */
95
	public function getMessagesFormatted( $severity = self::MESSAGE_WARNING, $header = null ) {
96
		global $wgTitle, $wgUser;
97
98
		$ret = '';
99
100
		foreach ( $this->mMessages as $message ) {
101
			if ( $message[ 1 ] <= $severity ) {
102
				$ret .= '* ' . $message[ 0 ] . "\n";
103
			}
104
		}
105
106
		if ( $ret != '' ) {
0 ignored issues
show
Operator != prohibited; use !== instead
Loading history...
107
			if ( !$this->mParser ) {
108
				$parser = new Parser();
109
			}
110
111
			if ( $header == null ) {
0 ignored issues
show
Operator == prohibited; use === instead
Loading history...
The condition $header == null is always true.
Loading history...
112
				$header = '';
113
			} elseif ( $header != '' ) {
0 ignored issues
show
Operator != prohibited; use !== instead
Loading history...
114
				$header = Html::rawElement( 'div', [ 'class' => 'heading' ], $header );
115
			}
116
117
			$ret = Html::rawElement( 'div', [ 'class' => 'messages' ],
118
				$header . "\n" .
119
				$ret
120
			);
121
122
			// FIXME: Variable 'parser' might have not been defined
0 ignored issues
show
Comment refers to a FIXME task "Variable 'parser' might have not been defined"
Loading history...
123
			// FIXME: $parser->parse returns ParserOutput, not String
0 ignored issues
show
Comment refers to a FIXME task "$parser->parse returns ParserOutput, not String"
Loading history...
124
			$ret = $parser->parse( $ret, $wgTitle, ParserOptions::newFromUser( $wgUser ) );
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $parser does not seem to be defined for all execution paths leading up to this point.
Loading history...
125
		} else {
126
			// FIXME: Should probably return '' (and throw an error if necessary)
0 ignored issues
show
Comment refers to a FIXME task "Should probably return '' (and throw an error if necessary"
Loading history...
127
			$ret = null;
128
		}
129
130
		return $ret;
131
	}
132
133
}
134