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 ) {
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' );
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.