Passed
Push — master ( 761e95...f1e6ba )
by Jeroen De
05:40
created

src/ProcessingErrorHandler.php (2 issues)

Labels
Severity

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
namespace ParamProcessor;
4
5
/**
6
 * Static class for error handling.
7
 *
8
 * @since 0.4
9
 * @deprecated since 1.0
10
 *
11
 * @licence GNU GPL v2+
12
 * @author Jeroen De Dauw < [email protected] >
13
 */
14
final class ProcessingErrorHandler {
15
16
	/**
17
	 * @since 0.4
18
	 *
19
	 * @var array of ProcessingError
20
	 */
21
	private static $errors = [];
22
23
	/**
24
	 * Adds a single ProcessingError.
25
	 *
26
	 * @since 0.4
27
	 *
28
	 * @param string $errorMessage
0 ignored issues
show
There is no parameter named $errorMessage. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
29
	 * @param integer $severity
0 ignored issues
show
There is no parameter named $severity. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
30
	 */
31
	public static function addError( ProcessingError $error ) {
32
		self::$errors[$error->getElement()][] = $error;
33
	}
34
35
	/**
36
	 * Adds a list of ProcessingError.
37
	 *
38
	 * @since 0.4
39
	 *
40
	 * @param array $errors
41
	 */
42
	public static function addErrors( array $errors ) {
43
		foreach ( $errors as $error ) {
44
			self::addError( $error );
45
		}
46
	}
47
48
	/**
49
	 * Returns a list of all registered errors.
50
	 *
51
	 * @since 0.4
52
	 *
53
	 * @return array of ProcessingError
54
	 */
55
	public static function getErrors() {
56
		return self::$errors;
57
	}
58
59
}