Passed
Push — master ( 1c4c6c...dd9495 )
by Daimona
01:53
created
includes/Exception/PermissionDeniedException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Exception;
4 4
 
Please login to merge, or discard this patch.
includes/Task/StartNew.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function runInternal() : int {
17
+	public function runInternal () : int {
18 18
 		$orderedList = [
19 19
 			'create-pages',
20 20
 			'open-updates',
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @inheritDoc
34 34
 	 */
35
-	protected function getSubtasksMap() : array {
35
+	protected function getSubtasksMap () : array {
36 36
 		return [
37 37
 			'create-pages' => CreatePages::class,
38 38
 			'open-updates' => OpenUpdates::class,
Please login to merge, or discard this patch.
includes/Request/CurlRequest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Request;
4 4
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 * @inheritDoc
13 13
 	 * @throws APIRequestException
14 14
 	 */
15
-	protected function reallyMakeRequest( string $params ) : string {
15
+	protected function reallyMakeRequest ( string $params ) : string {
16 16
 		$curl = curl_init();
17 17
 		if ( $curl === false ) {
18 18
 			throw new APIRequestException( 'Cannot open cURL handler.' );
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	 * @internal Only used as CB for cURL (CURLOPT_HEADERFUNCTION)
56 56
 	 * @suppress PhanUnreferencedPublicMethod,PhanUnusedPublicNoOverrideMethodParameter
57 57
 	 */
58
-	public function headersHandler( $ch, string $header ) : int {
58
+	public function headersHandler ( $ch, string $header ) : int {
59 59
 		$bits = explode( ':', $header, 2 );
60
-		if ( trim( $bits[0] ) === 'Set-Cookie' ) {
61
-			$this->newCookies[] = $bits[1];
60
+		if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) {
61
+			$this->newCookies[ ] = $bits[ 1 ];
62 62
 		}
63 63
 
64 64
 		return strlen( $header );
Please login to merge, or discard this patch.
includes/Task/Task.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task;
4 4
 
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 	 *
15 15
 	 * @return string[]
16 16
 	 */
17
-	abstract protected function getSubtasksMap() : array;
17
+	abstract protected function getSubtasksMap () : array;
18 18
 
19 19
 	/**
20 20
 	 * @param string $subtask Defined in self::SUBTASKS_MAP
21 21
 	 * @return TaskResult
22 22
 	 */
23
-	protected function runSubtask( string $subtask ) : TaskResult {
23
+	protected function runSubtask ( string $subtask ) : TaskResult {
24 24
 		$map = $this->getSubtasksMap();
25 25
 		if ( !isset( $map[ $subtask ] ) ) {
26 26
 			throw new \InvalidArgumentException( "'$subtask' is not a valid task." );
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @inheritDoc
35 35
 	 */
36
-	final public function getOperationName(): string {
36
+	final public function getOperationName (): string {
37 37
 		return 'task';
38 38
 	}
39 39
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param string $class
44 44
 	 * @return Subtask
45 45
 	 */
46
-	private function getSubtaskInstance( string $class ) : Subtask {
46
+	private function getSubtaskInstance ( string $class ) : Subtask {
47 47
 		return new $class( $this->getLogger(), $this->getWiki(), $this->getDataProvider() );
48 48
 	}
49 49
 }
Please login to merge, or discard this patch.
includes/TaskManager.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme;
4 4
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @param LoggerInterface $logger
56 56
 	 * @param Wiki $wiki
57 57
 	 */
58
-	public function __construct( LoggerInterface $logger, Wiki $wiki ) {
58
+	public function __construct ( LoggerInterface $logger, Wiki $wiki ) {
59 59
 		$this->logger = $logger;
60 60
 		$this->wiki = $wiki;
61 61
 		$this->provider = new TaskDataProvider( $this->logger, $this->wiki );
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK
69 69
 	 * @return TaskResult
70 70
 	 */
71
-	public function run( string $mode, string $name = null ) : TaskResult {
71
+	public function run ( string $mode, string $name = null ) : TaskResult {
72 72
 		if ( $mode === self::MODE_COMPLETE ) {
73 73
 			return $this->runAllTasks();
74 74
 		} elseif ( $name === null ) {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 * @return TaskResult
85 85
 	 */
86
-	protected function runAllTasks() : TaskResult {
86
+	protected function runAllTasks () : TaskResult {
87 87
 		$orderedList = [
88 88
 			'update-list',
89 89
 			'start-new',
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @param string $name
106 106
 	 * @return TaskResult
107 107
 	 */
108
-	protected function runTask( string $name ) : TaskResult {
108
+	protected function runTask ( string $name ) : TaskResult {
109 109
 		if ( !isset( self::TASKS_MAP[ $name ] ) ) {
110 110
 			throw new \InvalidArgumentException( "'$name' is not a valid task." );
111 111
 		}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @param string $name
121 121
 	 * @return TaskResult
122 122
 	 */
123
-	protected function runSubtask( string $name ) : TaskResult {
123
+	protected function runSubtask ( string $name ) : TaskResult {
124 124
 		if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) {
125 125
 			throw new \InvalidArgumentException( "'$name' is not a valid subtask." );
126 126
 		}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @param string $class
136 136
 	 * @return Task
137 137
 	 */
138
-	private function getTaskInstance( string $class ) : Task {
138
+	private function getTaskInstance ( string $class ) : Task {
139 139
 		return new $class( $this->logger, $this->wiki, $this->provider );
140 140
 	}
141 141
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param string $class
146 146
 	 * @return Subtask
147 147
 	 */
148
-	private function getSubtaskInstance( string $class ) : Subtask {
148
+	private function getSubtaskInstance ( string $class ) : Subtask {
149 149
 		return new $class( $this->logger, $this->wiki, $this->provider );
150 150
 	}
151 151
 }
Please login to merge, or discard this patch.
includes/Task/TaskBase.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task;
4 4
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 abstract class TaskBase extends ContextSource {
15 15
 	/** @var string[] */
16
-	protected $errors = [];
16
+	protected $errors = [ ];
17 17
 	/** @var TaskDataProvider */
18 18
 	protected $dataProvider;
19 19
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * @param Wiki $wiki
25 25
 	 * @param TaskDataProvider $dataProvider
26 26
 	 */
27
-	final public function __construct(
27
+	final public function __construct (
28 28
 		LoggerInterface $logger,
29 29
 		Wiki $wiki,
30 30
 		TaskDataProvider $dataProvider
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return TaskResult
40 40
 	 */
41
-	final public function run() : TaskResult {
41
+	final public function run () : TaskResult {
42 42
 		$class = ( new \ReflectionClass( $this ) )->getShortName();
43 43
 		$opName = $this->getOperationName();
44 44
 		$this->getLogger()->info( "Starting $opName $class" );
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return int One of the STATUS_* constants
71 71
 	 */
72
-	abstract protected function runInternal() : int;
72
+	abstract protected function runInternal () : int;
73 73
 
74 74
 	/**
75 75
 	 * How this operation should be called in logs
76 76
 	 *
77 77
 	 * @return string
78 78
 	 */
79
-	abstract public function getOperationName() : string;
79
+	abstract public function getOperationName () : string;
80 80
 
81 81
 	/**
82 82
 	 * @return TaskDataProvider
83 83
 	 */
84
-	protected function getDataProvider() : TaskDataProvider {
84
+	protected function getDataProvider () : TaskDataProvider {
85 85
 		return $this->dataProvider;
86 86
 	}
87 87
 }
Please login to merge, or discard this patch.
includes/Logger/IFlushingAwareLogger.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Logger;
4 4
 
@@ -8,5 +8,5 @@  discard block
 block discarded – undo
8 8
  * Logger aware of flushing. Can be declared empty if the buffer is flushed immediately.
9 9
  */
10 10
 interface IFlushingAwareLogger extends LoggerInterface {
11
-	public function flush() : void;
11
+	public function flush () : void;
12 12
 }
Please login to merge, or discard this patch.
run.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Entry point for the bot, called by CLI
4 4
  */
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 $type = current( array_keys( $taskOpt ) );
55 55
 try {
56 56
 	if ( $type === 'task' ) {
57
-		$bot->runTask( $taskOpt['task'] );
57
+		$bot->runTask( $taskOpt[ 'task' ] );
58 58
 	} elseif ( $type === 'subtask' ) {
59
-		$bot->runSubtask( $taskOpt['subtask'] );
59
+		$bot->runSubtask( $taskOpt[ 'subtask' ] );
60 60
 	} else {
61 61
 		$bot->runAll();
62 62
 	}
Please login to merge, or discard this patch.
includes/Wiki/Page/PageBotList.php 1 patch
Spacing   +18 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Wiki\Page;
4 4
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @private Use self::get()
20 20
 	 * @param Wiki $wiki
21 21
 	 */
22
-	public function __construct( Wiki $wiki ) {
22
+	public function __construct ( Wiki $wiki ) {
23 23
 		parent::__construct( Config::getInstance()->get( 'list-title' ), $wiki );
24 24
 	}
25 25
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param Wiki $wiki
30 30
 	 * @return self
31 31
 	 */
32
-	public static function get( Wiki $wiki ) : self {
32
+	public static function get ( Wiki $wiki ) : self {
33 33
 		static $instance = null;
34 34
 		if ( $instance === null ) {
35 35
 			$instance = new self( $wiki );
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 	 * @param string[] $groups
42 42
 	 * @return int|null
43 43
 	 */
44
-	public static function getOverrideTimestamp( array $groups ) : ?int {
44
+	public static function getOverrideTimestamp ( array $groups ) : ?int {
45 45
 		if ( !array_intersect_key( $groups, [ 'override-perm' => true, 'override' => true ] ) ) {
46 46
 			return null;
47 47
 		}
48 48
 
49 49
 		// A one-time override takes precedence
50 50
 		if ( array_key_exists( 'override', $groups ) ) {
51
-			$date = $groups['override'];
51
+			$date = $groups[ 'override' ];
52 52
 		} else {
53
-			$date = $groups['override-prem'] . '/' . date( 'Y' );
53
+			$date = $groups[ 'override-prem' ] . '/' . date( 'Y' );
54 54
 		}
55 55
 		return \DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp();
56 56
 	}
@@ -61,17 +61,15 @@  discard block
 block discarded – undo
61 61
 	 * @param array $groups
62 62
 	 * @return int
63 63
 	 */
64
-	public static function getValidFlagTimestamp( array $groups ): int {
65
-		$checkuser = isset( $groups['checkuser'] ) ?
66
-			\DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() :
67
-			0;
68
-		$bureaucrat = isset( $groups['bureaucrat'] ) ?
69
-			\DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() :
70
-			0;
64
+	public static function getValidFlagTimestamp ( array $groups ): int {
65
+		$checkuser = isset( $groups[ 'checkuser' ] ) ?
66
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
67
+		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
68
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
71 69
 
72 70
 		$timestamp = max( $bureaucrat, $checkuser );
73 71
 		if ( $timestamp === 0 ) {
74
-			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp();
72
+			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp();
75 73
 		}
76 74
 		return $timestamp;
77 75
 	}
@@ -80,14 +78,14 @@  discard block
 block discarded – undo
80 78
 	 * @param array $groups
81 79
 	 * @return bool
82 80
 	 */
83
-	public static function isOverrideExpired( array $groups ) : bool {
84
-		if ( !isset( $groups['override'] ) ) {
81
+	public static function isOverrideExpired ( array $groups ) : bool {
82
+		if ( !isset( $groups[ 'override' ] ) ) {
85 83
 			return false;
86 84
 		}
87 85
 
88 86
 		$flagTS = self::getValidFlagTimestamp( $groups );
89 87
 		$usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) );
90
-		$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp();
88
+		$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp();
91 89
 		$delay = 60 * 60 * 24 * 3;
92 90
 
93 91
 		return time() > $usualTS + $delay && time() > $overrideTS + $delay;
@@ -98,9 +96,9 @@  discard block
 block discarded – undo
98 96
 	 *
99 97
 	 * @return User[]
100 98
 	 */
101
-	public function getAdminsList() : array {
99
+	public function getAdminsList () : array {
102 100
 		if ( $this->adminsList === null ) {
103
-			$this->adminsList = [];
101
+			$this->adminsList = [ ];
104 102
 			foreach ( $this->getDecodedContent() as $user => $info ) {
105 103
 				$userObj = new User( $user, $this->wiki );
106 104
 				$userObj->setInfo( $info );
@@ -115,7 +113,7 @@  discard block
 block discarded – undo
115 113
 	 *
116 114
 	 * @return array[]
117 115
 	 */
118
-	public function getDecodedContent() : array {
116
+	public function getDecodedContent () : array {
119 117
 		return json_decode( $this->getContent(), true );
120 118
 	}
121 119
 }
Please login to merge, or discard this patch.