Completed
Push — independent-tests ( 9f7203...563c9a )
by Jeroen De
04:19
created

PHPUnit4And6Compat::expectException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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 6 and the first side effect is on line 14.

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
// If testing against an older version of MediaWiki, define
4
// an empty trait to avoid fatal errors.
5
if ( !trait_exists( PHPUnit4And6Compat::class ) ) {
6
	trait PHPUnit4And6Compat {
7
		public function expectException( string $exception ) {
8
			$this->setExpectedException( $exception );
0 ignored issues
show
Bug introduced by
It seems like setExpectedException() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
9
		}
10
	}
11
}
12
13
if ( defined( 'MEDIAWIKI' ) ) {
14
	return;
15
}
16
17
if ( PHP_SAPI !== 'cli' ) {
18
	die( 'Not an entry point' );
19
}
20
21
error_reporting( -1 );
22
ini_set( 'display_errors', 1 );
23
24
if ( !is_readable( __DIR__ . '/../vendor/autoload.php' ) ) {
25
	die( 'You need to install this package with Composer before you can run the tests' );
26
}
27
28
require __DIR__ . '/../vendor/autoload.php';
29