Init.php ➔ peachyCheckPHPVersion()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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

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
/*
4
This file is part of Peachy MediaWiki Bot API
5
6
Peachy is free software: you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
Peachy is not responsible for any damage caused to the system running it.
20
*/
21
22
/**
23
 * @file
24
 * Main Peachy file
25
 * Defines constants, initializes global variables
26
 * Stores Peachy
27
 * @license GPL
28
 */
29
30
/**
31
 * The version that Peachy is running
32
 */
33
define( 'PEACHYVERSION', '2.0 (alpha 8)' );
34
35
/**
36
 * Minimum MediaWiki version that is required for Peachy
37
 */
38
define( 'MINMW', '1.23' );
39
40
/**
41
 * Minimum PHP version that is required for Peachy
42
 */
43
define( 'MINPHP', '5.2.1' );
44
45
/**
46
 * PECHO constants, used for {@link outputText}()
47
 */
48
define( 'PECHO_VERBOSE', -1 );
49
50
/**
51
 * PECHO constants, used for {@link outputText}()
52
 */
53
define( 'PECHO_NORMAL', 0 );
54
55
/**
56
 * PECHO constants, used for {@link outputText}()
57
 */
58
define( 'PECHO_NOTICE', 1 );
59
60
/**
61
 * PECHO constants, used for {@link outputText}()
62
 */
63
define( 'PECHO_WARN', 2 );
64
65
/**
66
 * PECHO constants, used for {@link outputText}()
67
 */
68
define( 'PECHO_ERROR', 3 );
69
70
/**
71
 * PECHO constants, used for {@link outputText}()
72
 */
73
define( 'PECHO_FATAL', 4 );
74
75
$pgIP = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
76
77
//If out /tmp directory doesnt exist, make it!
78
if( !file_exists( __DIR__ . '/tmp' ) ) {
79
    mkdir(__DIR__ . '/tmp');
80
}
81
82
require_once( $pgIP . 'Includes/Exceptions.php' );
83
require_once( $pgIP . 'Includes/AutoUpdate.php' );
84
85
peachyCheckPHPVersion( MINPHP );
86
87
$pgHooks = array();
88
$pgProxy = array();
89
$pgUA = 'Peachy MediaWiki Bot API Version ' . PEACHYVERSION;
90
91
require_once( $pgIP . 'Includes/Hooks.php' );
92
require_once( $pgIP . 'HTTP.php' );
93
require_once( $pgIP . 'Includes/Autoloader.php' );
94
require_once( $pgIP . 'GenFunctions.php' );
95
require_once( $pgIP . 'config.inc.php' );
96
require_once( $pgIP . 'Includes/SSH.php' );
97
require_once($pgIP . 'Includes/lime.php');
98
99
$pgVerbose = array();
100
if( $pgDisplayPechoVerbose ) $pgVerbose[] = -1;
101
if( $pgDisplayPechoNormal ) $pgVerbose[] = 0;
102
if( $pgDisplayPechoNotice ) $pgVerbose[] = 1;
103
if( $pgDisplayPechoWarn ) $pgVerbose[] = 2;
104
if( $pgDisplayPechoError ) $pgVerbose[] = 3;
105
if( $pgDisplayPechoFatal ) $pgVerbose[] = 4;
106
107
$pgIRCTrigger = array( '!', '.' );
108
109
//Last version check
110
$tmp = null;
111
112
if( function_exists( 'mb_internal_encoding' ) ) {
113
    mb_internal_encoding("UTF-8");
114
}
115
116
// Suppress warnings if timezone not set on server
117
date_default_timezone_set( @date_default_timezone_get() );
118
119
//Check for updates before loading Peachy.
120
if( !$pgDisableUpdates && !defined( 'PEACHY_PHPUNIT_TESTS' ) ) {
121
    //the below MUST have its own Http object or else things will break
122
    $updater = new AutoUpdate(new HTTP());
123
    $Uptodate = $updater->Checkforupdate();
124
    if (!$Uptodate) {
125
        $updater->updatePeachy();
126
    }
127
}
128
129
require_once( $pgIP . 'Includes/Peachy.php' );
130
131
/**
132
 * Simple version_compare() wrapper
133
 * @param string $check_version string
134
 * @throws DependencyError
135
 * @return void
136
 */
137
function peachyCheckPHPVersion( $check_version )
138
{
139
    if (version_compare(PHP_VERSION, $check_version, '<')) {
140
        throw new DependencyError("PHP " . $check_version, "http://php.net/downloads.php");
0 ignored issues
show
Documentation introduced by
'http://php.net/downloads.php' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
141
    }
142
}
143