Passed
Push — master ( 1a35de...b3e686 )
by Daimona
01:36
created
includes/Task/Subtask/SimpleUpdates.php 1 patch
Spacing   +16 added lines, -16 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\Subtask;
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
 		$pages = $this->getDataProvider()->getPagesToClose();
19 19
 
20 20
 		if ( !$pages ) {
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	 * @param PageRiconferma[] $pages
34 34
 	 * @see UpdatesAround::addToVotazioni()
35 35
 	 */
36
-	protected function updateVotazioni( array $pages ) {
36
+	protected function updateVotazioni ( array $pages ) {
37 37
 		$this->getLogger()->info(
38 38
 			'Updating votazioni: ' . implode( ', ', array_map( 'strval', $pages ) )
39 39
 		);
40 40
 		$votePage = new Page( $this->getConfig()->get( 'vote-page-title' ) );
41 41
 
42
-		$titles = [];
42
+		$titles = [ ];
43 43
 		foreach ( $pages as $page ) {
44
-			$titles[] = preg_quote( $page->getTitle() );
44
+			$titles[ ] = preg_quote( $page->getTitle() );
45 45
 		}
46 46
 
47 47
 		$titleReg = implode( '|', $titles );
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * @param array $pages
71 71
 	 * @see UpdatesAround::addToNews()
72 72
 	 */
73
-	protected function updateNews( array $pages ) {
73
+	protected function updateNews ( array $pages ) {
74 74
 		$simpleAmount = $voteAmount = 0;
75 75
 		foreach ( $pages as $page ) {
76 76
 			if ( $page->isVote() ) {
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 		$simpleMatches = $newsPage->getMatch( $simpleReg );
94 94
 		$voteMatches = $newsPage->getMatch( $voteReg );
95 95
 
96
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
97
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
96
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
97
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
98 98
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content );
99 99
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
100 100
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @param PageRiconferma[] $pages
114 114
 	 */
115
-	protected function updateAdminList( array $pages ) {
115
+	protected function updateAdminList ( array $pages ) {
116 116
 		$this->getLogger()->info(
117 117
 			'Updating admin list: ' . implode( ', ', array_map( 'strval', $pages ) )
118 118
 		);
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
 		$newContent = $adminsPage->getContent();
121 121
 		$newDate = date( 'Ymd', strtotime( '+1 year' ) );
122 122
 
123
-		$riconfNames = $removeNames = [];
123
+		$riconfNames = $removeNames = [ ];
124 124
 		foreach ( $pages as $page ) {
125 125
 			$user = $page->getUser()->getName();
126 126
 			$reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!";
127 127
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
128 128
 				// Remove the line
129 129
 				$newContent = preg_replace( $reg, '', $newContent );
130
-				$removeNames[] = $user;
130
+				$removeNames[ ] = $user;
131 131
 			} else {
132 132
 				$newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent );
133
-				$riconfNames[] = $user;
133
+				$riconfNames[ ] = $user;
134 134
 			}
135 135
 		}
136 136
 
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
 	/**
151 151
 	 * @param PageRiconferma[] $pages
152 152
 	 */
153
-	protected function updateCUList( array $pages ) {
153
+	protected function updateCUList ( array $pages ) {
154 154
 		$this->getLogger()->info( 'Checking if CU list needs updating.' );
155 155
 		$cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) );
156 156
 		$newContent = $cuList->getContent();
157 157
 
158
-		$riconfNames = $removeNames = [];
158
+		$riconfNames = $removeNames = [ ];
159 159
 		foreach ( $pages as $page ) {
160 160
 			$user = $page->getUser();
161 161
 			if ( $user->inGroup( 'checkuser' ) ) {
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 				if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
164 164
 					// Remove the line
165 165
 					$newContent = preg_replace( $reg, '', $newContent );
166
-					$removeNames[] = $user->getName();
166
+					$removeNames[ ] = $user->getName();
167 167
 				} else {
168 168
 					$newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent );
169
-					$riconfNames[] = $user->getName();
169
+					$riconfNames[ ] = $user->getName();
170 170
 				}
171 171
 			}
172 172
 		}
Please login to merge, or discard this patch.
includes/TaskDataProvider.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;
4 4
 
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 	/** @var array[] */
16 16
 	private $allUsers;
17 17
 	/** @var PageRiconferma[] */
18
-	private $createdPages = [];
18
+	private $createdPages = [ ];
19 19
 
20 20
 	/**
21 21
 	 * Get the full content of the JSON users list
22 22
 	 *
23 23
 	 * @return array[]
24 24
 	 */
25
-	public function getUsersList() : array {
25
+	public function getUsersList () : array {
26 26
 		if ( $this->allUsers === null ) {
27 27
 			$this->getLogger()->debug( 'Retrieving users list' );
28 28
 			$this->allUsers = PageBotList::get()->getAdminsList();
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return array[]
38 38
 	 */
39
-	public function getUsersToProcess() : array {
39
+	public function getUsersToProcess () : array {
40 40
 		if ( $this->processUsers === null ) {
41
-			$this->processUsers = [];
41
+			$this->processUsers = [ ];
42 42
 			foreach ( $this->getUsersList() as $user => $groups ) {
43 43
 				$timestamp = $this->getValidTimestamp( $groups );
44 44
 
@@ -60,13 +60,11 @@  discard block
 block discarded – undo
60 60
 	 * @param array $groups
61 61
 	 * @return int
62 62
 	 */
63
-	private function getValidTimestamp( array $groups ) : int {
63
+	private function getValidTimestamp ( array $groups ) : int {
64 64
 		$checkuser = isset( $groups[ 'checkuser' ] ) ?
65
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() :
66
-			0;
65
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
67 66
 		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
68
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() :
69
-			0;
67
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
70 68
 
71 69
 		$timestamp = max( $bureaucrat, $checkuser );
72 70
 		if ( $timestamp === 0 ) {
@@ -80,7 +78,7 @@  discard block
 block discarded – undo
80 78
 	 *
81 79
 	 * @return PageRiconferma[]
82 80
 	 */
83
-	public function getOpenPages() : array {
81
+	public function getOpenPages () : array {
84 82
 		static $list = null;
85 83
 		if ( $list === null ) {
86 84
 			$mainTitle = $this->getConfig()->get( 'main-page-title' );
@@ -93,10 +91,10 @@  discard block
 block discarded – undo
93 91
 			];
94 92
 
95 93
 			$pages = RequestBase::newFromParams( $params )->execute()->query->pages;
96
-			$list = [];
94
+			$list = [ ];
97 95
 			foreach ( reset( $pages )->templates as $page ) {
98 96
 				if ( preg_match( "!$mainTitle\/[^\/]+\/\d!", $page->title ) ) {
99
-					$list[] = new PageRiconferma( $page->title );
97
+					$list[ ] = new PageRiconferma( $page->title );
100 98
 				}
101 99
 			}
102 100
 		}
@@ -109,14 +107,14 @@  discard block
 block discarded – undo
109 107
 	 *
110 108
 	 * @return PageRiconferma[]
111 109
 	 */
112
-	public function getPagesToClose() : array {
110
+	public function getPagesToClose () : array {
113 111
 		static $list = null;
114 112
 		if ( $list === null ) {
115 113
 			$allPages = $this->getOpenPages();
116
-			$list = [];
114
+			$list = [ ];
117 115
 			foreach ( $allPages as $page ) {
118 116
 				if ( time() > $page->getEndTimestamp() ) {
119
-					$list[] = $page;
117
+					$list[ ] = $page;
120 118
 				}
121 119
 			}
122 120
 		}
@@ -128,21 +126,21 @@  discard block
 block discarded – undo
128 126
 	 *
129 127
 	 * @param string $name
130 128
 	 */
131
-	public function removeUser( string $name ) {
129
+	public function removeUser ( string $name ) {
132 130
 		unset( $this->processUsers[ $name ] );
133 131
 	}
134 132
 
135 133
 	/**
136 134
 	 * @return PageRiconferma[]
137 135
 	 */
138
-	public function getCreatedPages() : array {
136
+	public function getCreatedPages () : array {
139 137
 		return $this->createdPages;
140 138
 	}
141 139
 
142 140
 	/**
143 141
 	 * @param PageRiconferma $page
144 142
 	 */
145
-	public function addCreatedPages( PageRiconferma $page ) {
146
-		$this->createdPages[] = $page;
143
+	public function addCreatedPages ( PageRiconferma $page ) {
144
+		$this->createdPages[ ] = $page;
147 145
 	}
148 146
 }
Please login to merge, or discard this patch.
includes/Message.php 1 patch
Spacing   +11 added lines, -11 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
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @param string $key
16 16
 	 */
17
-	public function __construct( string $key ) {
17
+	public function __construct ( string $key ) {
18 18
 		$this->key = $key;
19 19
 		$this->value = Config::getInstance()->getWikiMessage( $key );
20 20
 	}
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @param array $args
24 24
 	 * @return self
25 25
 	 */
26
-	public function params( array $args ) : self {
26
+	public function params ( array $args ) : self {
27 27
 		$this->value = strtr( $this->value, $args );
28 28
 		return $this;
29 29
 	}
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	/**
32 32
 	 * @return string
33 33
 	 */
34
-	public function text() : string {
34
+	public function text () : string {
35 35
 		$this->parsePlurals();
36 36
 		return $this->value;
37 37
 	}
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * Replace {{$plur|<amount>|sing|plur}}
41 41
 	 */
42
-	protected function parsePlurals() {
42
+	protected function parsePlurals () {
43 43
 		$reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!';
44 44
 
45 45
 		if ( preg_match( $reg, $this->value ) === 0 ) {
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		$this->value = preg_replace_callback(
49 49
 			$reg,
50 50
 			function ( $matches ) {
51
-				return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
51
+				return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
52 52
 			},
53 53
 			$this->value
54 54
 		);
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @param int $timestamp
61 61
 	 * @return string
62 62
 	 */
63
-	public static function getTimeWithArticle( int $timestamp ) : string {
63
+	public static function getTimeWithArticle ( int $timestamp ) : string {
64 64
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
65 65
 		$timeString = strftime( '%e %B alle %R', $timestamp );
66 66
 		// Remove the left space if day has a single digit
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @param string $timeString
78 78
 	 * @return int
79 79
 	 */
80
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
80
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
81 81
 		$months = [
82 82
 			'gennaio' => 'January',
83 83
 			'febbraio' => 'February',
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
 	 * @param string $emptyText
108 108
 	 * @return string
109 109
 	 */
110
-	public static function commaList( array $data, string $emptyText = 'nessuno' ) : string {
110
+	public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string {
111 111
 		if ( count( $data ) > 1 ) {
112 112
 			$last = array_pop( $data );
113 113
 			$ret = implode( ', ', $data ) . " e $last";
114 114
 		} elseif ( $data ) {
115
-			$ret = $data[0];
115
+			$ret = $data[ 0 ];
116 116
 		} else {
117 117
 			$ret = $emptyText;
118 118
 		}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		return $ret;
121 121
 	}
122 122
 
123
-	public function __toString() {
123
+	public function __toString () {
124 124
 		return $this->text();
125 125
 	}
126 126
 }
Please login to merge, or discard this patch.
includes/Task/StartVote.php 1 patch
Spacing   +16 added lines, -16 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
 
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	protected function getSubtasksMap(): array {
18
+	protected function getSubtasksMap (): array {
19 19
 		// Everything is done here.
20
-		return [];
20
+		return [ ];
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @inheritDoc
25 25
 	 */
26
-	public function runInternal() : int {
26
+	public function runInternal () : int {
27 27
 		$pages = $this->getDataProvider()->getOpenPages();
28 28
 
29 29
 		if ( !$pages ) {
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	 * @param PageRiconferma[] $pages
38 38
 	 * @return int a STATUS_* constant
39 39
 	 */
40
-	protected function processPages( array $pages ) : int {
41
-		$actualPages = [];
40
+	protected function processPages ( array $pages ) : int {
41
+		$actualPages = [ ];
42 42
 		foreach ( $pages as $page ) {
43 43
 			if ( $page->hasOpposition() && !$page->isVote() ) {
44 44
 				$this->openVote( $page );
45
-				$actualPages[] = $page;
45
+				$actualPages[ ] = $page;
46 46
 			}
47 47
 		}
48 48
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param PageRiconferma $page
62 62
 	 */
63
-	protected function openVote( PageRiconferma $page ) {
63
+	protected function openVote ( PageRiconferma $page ) {
64 64
 		$this->getLogger()->info( "Starting vote on $page" );
65 65
 
66 66
 		$content = $page->getContent();
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 	 * @see SimpleUpdates::updateVotazioni()
100 100
 	 * @see UpdatesAround::addToVotazioni()
101 101
 	 */
102
-	protected function updateVotePage( array $pages ) {
102
+	protected function updateVotePage ( array $pages ) {
103 103
 		$votePage = new Page( $this->getConfig()->get( 'vote-page-title' ) );
104 104
 		$content = $votePage->getContent();
105 105
 
106
-		$titles = [];
106
+		$titles = [ ];
107 107
 		foreach ( $pages as $page ) {
108
-			$titles[] = preg_quote( $page->getTitle() );
108
+			$titles[ ] = preg_quote( $page->getTitle() );
109 109
 		}
110 110
 		$titleReg = implode( '|', $titles );
111 111
 		$search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!m";
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 );
131 131
 		} else {
132 132
 			// Start section
133
-			$matches = [];
133
+			$matches = [ ];
134 134
 			if ( preg_match( $introReg, $newContent, $matches ) === 0 ) {
135 135
 				throw new TaskException( 'Intro not found in vote page' );
136 136
 			}
137 137
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
138 138
 			// Replace semicolon with full stop
139 139
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
140
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 );
140
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 );
141 141
 		}
142 142
 
143 143
 		$summary = $this->msg( 'vote-start-vote-page-summary' )
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @see UpdatesAround::addToNews()
160 160
 	 * @see SimpleUpdates::updateNews()
161 161
 	 */
162
-	protected function updateNews( int $amount ) {
162
+	protected function updateNews ( int $amount ) {
163 163
 		$this->getLogger()->info( "Turning $amount pages into votes" );
164 164
 		$newsPage = new Page( $this->getConfig()->get( 'news-page-title' ) );
165 165
 
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 			throw new TaskException( 'Param "voto" not found in news page' );
175 175
 		}
176 176
 
177
-		$newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: '';
178
-		$newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: '';
177
+		$newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: '';
178
+		$newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: '';
179 179
 
180 180
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
181 181
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/Task/Subtask/ArchivePages.php 1 patch
Spacing   +12 added lines, -12 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\Subtask;
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
 		$pages = $this->getDataProvider()->getPagesToClose();
19 19
 
20 20
 		if ( !$pages ) {
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	 * @param PageRiconferma[] $pages
34 34
 	 * @see UpdatesAround::addToMainPage()
35 35
 	 */
36
-	protected function removeFromMainPage( array $pages ) {
36
+	protected function removeFromMainPage ( array $pages ) {
37 37
 		$this->getLogger()->info(
38 38
 			'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) )
39 39
 		);
40 40
 
41 41
 		$mainPage = new Page( $this->getConfig()->get( 'main-page-title' ) );
42
-		$remove = [];
42
+		$remove = [ ];
43 43
 		foreach ( $pages as $page ) {
44
-			$remove[] = '{{' . $page->getTitle() . '}}';
44
+			$remove[ ] = '{{' . $page->getTitle() . '}}';
45 45
 		}
46 46
 
47 47
 		$summary = $this->msg( 'close-main-summary' )
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @param PageRiconferma[] $pages
61 61
 	 */
62
-	protected function addToArchive( array $pages ) {
62
+	protected function addToArchive ( array $pages ) {
63 63
 		$this->getLogger()->info(
64 64
 			'Adding to archive: ' . implode( ', ', array_map( 'strval', $pages ) )
65 65
 		);
66 66
 
67
-		$simple = $votes = [];
67
+		$simple = $votes = [ ];
68 68
 		foreach ( $pages as $page ) {
69 69
 			if ( $page->isVote() ) {
70
-				$votes[] = $page;
70
+				$votes[ ] = $page;
71 71
 			} else {
72
-				$simple[] = $page;
72
+				$simple[ ] = $page;
73 73
 			}
74 74
 		}
75 75
 
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
 	 * @param string $archiveTitle
87 87
 	 * @param array $pages
88 88
 	 */
89
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) {
89
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) {
90 90
 		$archivePage = new Page( "$archiveTitle/" . date( 'Y' ) );
91 91
 
92 92
 		$append = "\n";
93
-		$archivedList = [];
93
+		$archivedList = [ ];
94 94
 		foreach ( $pages as $page ) {
95 95
 			$append .= '{{' . $page->getTitle() . "}}\n";
96
-			$archivedList[] = $page->getUserNum();
96
+			$archivedList[ ] = $page->getUserNum();
97 97
 		}
98 98
 
99 99
 		$summary = $this->msg( 'close-archive-summary' )
Please login to merge, or discard this patch.
includes/Task/TaskBase.php 1 patch
Spacing   +10 added lines, -10 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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 abstract class TaskBase extends ContextSource {
13 13
 	/** @var string[] */
14
-	protected $errors = [];
14
+	protected $errors = [ ];
15 15
 	/** @var TaskDataProvider */
16 16
 	protected $dataProvider;
17 17
 
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param TaskDataProvider $dataProvider
22 22
 	 */
23
-	final public function __construct( TaskDataProvider $dataProvider ) {
23
+	final public function __construct ( TaskDataProvider $dataProvider ) {
24 24
 		set_exception_handler( [ $this, 'handleException' ] );
25 25
 		set_error_handler( [ $this, 'handleError' ] );
26 26
 		parent::__construct();
27 27
 		$this->dataProvider = $dataProvider;
28 28
 	}
29 29
 
30
-	public function __destruct() {
30
+	public function __destruct () {
31 31
 		restore_error_handler();
32 32
 		restore_exception_handler();
33 33
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return TaskResult
39 39
 	 */
40
-	final public function run() : TaskResult {
40
+	final public function run () : TaskResult {
41 41
 		$class = ( new \ReflectionClass( $this ) )->getShortName();
42 42
 		$opName = $this->getOperationName();
43 43
 		$this->getLogger()->info( "Starting $opName $class" );
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @return int One of the STATUS_* constants
70 70
 	 */
71
-	abstract protected function runInternal() : int;
71
+	abstract protected function runInternal () : int;
72 72
 
73 73
 	/**
74 74
 	 * How this operation should be called in logs
75 75
 	 *
76 76
 	 * @return string
77 77
 	 */
78
-	abstract public function getOperationName() : string;
78
+	abstract public function getOperationName () : string;
79 79
 
80 80
 	/**
81 81
 	 * Exception handler.
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param \Throwable $ex
84 84
 	 * @protected
85 85
 	 */
86
-	public function handleException( \Throwable $ex ) {
86
+	public function handleException ( \Throwable $ex ) {
87 87
 		$this->getLogger()->error(
88 88
 			( new \ReflectionClass( $ex ) )->getShortName() . ': ' .
89 89
 			$ex->getMessage() . "\nin " . $ex->getFile() . ' line ' .
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 * @param int $errline
101 101
 	 * @protected
102 102
 	 */
103
-	public function handleError( $errno, $errstr, $errfile, $errline ) {
103
+	public function handleError ( $errno, $errstr, $errfile, $errline ) {
104 104
 		throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
105 105
 	}
106 106
 
107 107
 	/**
108 108
 	 * @return TaskDataProvider
109 109
 	 */
110
-	protected function getDataProvider() : TaskDataProvider {
110
+	protected function getDataProvider () : TaskDataProvider {
111 111
 		return $this->dataProvider;
112 112
 	}
113 113
 }
Please login to merge, or discard this patch.
includes/Task/Subtask/FailedUpdates.php 1 patch
Spacing   +15 added lines, -15 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\Subtask;
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
 		$failed = $this->getFailures();
19 19
 		if ( $failed ) {
20 20
 			$this->updateBurList( $failed );
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @return PageRiconferma[]
33 33
 	 */
34
-	private function getFailures() : array {
35
-		$ret = [];
34
+	private function getFailures () : array {
35
+		$ret = [ ];
36 36
 		$allPages = $this->getDataProvider()->getPagesToClose();
37 37
 		foreach ( $allPages as $page ) {
38 38
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
39
-				$ret[] = $page;
39
+				$ret[ ] = $page;
40 40
 			}
41 41
 		}
42 42
 		return $ret;
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 	/**
46 46
 	 * @param PageRiconferma[] $pages
47 47
 	 */
48
-	protected function updateBurList( array $pages ) {
48
+	protected function updateBurList ( array $pages ) {
49 49
 		$this->getLogger()->info( 'Checking if bur list needs updating.' );
50 50
 
51
-		$remove = [];
51
+		$remove = [ ];
52 52
 		foreach ( $pages as $page ) {
53 53
 			$user = $page->getUser();
54 54
 			if ( $user->inGroup( 'bureaucrat' ) &&
55 55
 				( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL )
56 56
 			) {
57
-				$remove[] = $user->getName();
57
+				$remove[ ] = $user->getName();
58 58
 			}
59 59
 		}
60 60
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @param PageRiconferma[] $pages
86 86
 	 */
87
-	protected function requestRemoval( array $pages ) {
87
+	protected function requestRemoval ( array $pages ) {
88 88
 		$this->getLogger()->info(
89 89
 			'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) )
90 90
 		);
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @param PageRiconferma[] $pages
125 125
 	 */
126
-	protected function updateAnnunci( array $pages ) {
126
+	protected function updateAnnunci ( array $pages ) {
127 127
 		$this->getLogger()->info( 'Updating annunci' );
128 128
 		$section = 1;
129 129
 
130
-		$names = [];
130
+		$names = [ ];
131 131
 		$text = '';
132 132
 		foreach ( $pages as $page ) {
133 133
 			$user = $page->getUser()->getName();
134
-			$names[] = $user;
134
+			$names[ ] = $user;
135 135
 			$text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " .
136 136
 				"non è stato riconfermato [[WP:A|amministratore]].}}\n";
137 137
 		}
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @param PageRiconferma[] $pages
168 168
 	 */
169
-	protected function updateUltimeNotizie( array $pages ) {
169
+	protected function updateUltimeNotizie ( array $pages ) {
170 170
 		$this->getLogger()->info( 'Updating ultime notizie' );
171 171
 		$notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-page-title' ) );
172 172
 
173
-		$names = [];
173
+		$names = [ ];
174 174
 		$text = '';
175 175
 		foreach ( $pages as $page ) {
176 176
 			$user = $page->getUser()->getName();
177 177
 			$title = $page->getTitle();
178
-			$names[] = $user;
178
+			$names[ ] = $user;
179 179
 			$text .= "*'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " .
180 180
 				"[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{subst:NUMBEROFADMINS}} - 1}}.\n";
181 181
 		}
Please login to merge, or discard this patch.
includes/Wiki/Controller.php 1 patch
Spacing   +12 added lines, -12 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;
4 4
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @param string $domain The URL of the wiki, if different from default
29 29
 	 */
30
-	public function __construct( string $domain = DEFAULT_URL ) {
30
+	public function __construct ( string $domain = DEFAULT_URL ) {
31 31
 		$this->logger = new Logger;
32 32
 		$this->domain = $domain;
33 33
 	}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @return string
41 41
 	 * @throws MissingPageException
42 42
 	 */
43
-	public function getPageContent( string $title, int $section = null ) : string {
43
+	public function getPageContent ( string $title, int $section = null ) : string {
44 44
 		$msg = "Retrieving content of page $title" . ( $section !== null ? ", section $section" : '' );
45 45
 		$this->logger->debug( $msg );
46 46
 		$params = [
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		];
53 53
 
54 54
 		if ( $section !== null ) {
55
-			$params['rvsection'] = $section;
55
+			$params[ 'rvsection' ] = $section;
56 56
 		}
57 57
 
58 58
 		$req = RequestBase::newFromParams( $params )->setUrl( $this->domain );
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 			throw new MissingPageException( $title );
63 63
 		}
64 64
 
65
-		$mainSlot = $page->revisions[0]->slots->main;
65
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
66 66
 
67 67
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
68 68
 			throw new MissingSectionException( $title, $section );
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param array $params
77 77
 	 * @throws EditException
78 78
 	 */
79
-	public function editPage( array $params ) {
79
+	public function editPage ( array $params ) {
80 80
 		$this->login();
81 81
 
82 82
 		$params = [
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
99 99
 	 * @throws LoginException
100 100
 	 */
101
-	public function login() {
101
+	public function login () {
102 102
 		if ( self::$loggedIn ) {
103 103
 			return;
104 104
 		}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
 		self::$loggedIn = true;
126 126
 		// Clear tokens cache
127
-		$this->tokens = [];
127
+		$this->tokens = [ ];
128 128
 		$this->logger->info( 'Login succeeded' );
129 129
 	}
130 130
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @param string $type
135 135
 	 * @return string
136 136
 	 */
137
-	public function getToken( string $type ) : string {
137
+	public function getToken ( string $type ) : string {
138 138
 		if ( !isset( $this->tokens[ $type ] ) ) {
139 139
 			$params = [
140 140
 				'action' => 'query',
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @param string $title
158 158
 	 * @return int
159 159
 	 */
160
-	public function getPageCreationTS( string $title ) : int {
160
+	public function getPageCreationTS ( string $title ) : int {
161 161
 		$params = [
162 162
 			'action' => 'query',
163 163
 			'prop' => 'revisions',
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
 		$res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute();
172 172
 		$data = $res->query->pages;
173
-		return strtotime( reset( $data )->revisions[0]->timestamp );
173
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
174 174
 	}
175 175
 
176 176
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @param string $title
180 180
 	 * @param string $reason
181 181
 	 */
182
-	public function protectPage( string $title, string $reason ) {
182
+	public function protectPage ( string $title, string $reason ) {
183 183
 		$this->logger->info( "Protecting page $title" );
184 184
 		$this->login();
185 185
 
Please login to merge, or discard this patch.
includes/Wiki/Page/PageRiconferma.php 1 patch
Spacing   +22 added lines, -22 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
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @param string $title
29 29
 	 */
30
-	public function __construct( string $title ) {
30
+	public function __construct ( string $title ) {
31 31
 		parent::__construct( $title );
32 32
 		$this->supportSection = $this->isVote() ? 3 : 0;
33 33
 		$this->opposeSection = $this->isVote() ? 4 : 3;
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return User
40 40
 	 */
41
-	public function getUser() : User {
42
-		$name = explode( '/', $this->title )[2];
41
+	public function getUser () : User {
42
+		$name = explode( '/', $this->title )[ 2 ];
43 43
 		return new User( $name );
44 44
 	}
45 45
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @return int
50 50
 	 */
51
-	public function getNum() : int {
51
+	public function getNum () : int {
52 52
 		$bits = explode( '/', $this->getTitle() );
53 53
 		return intval( end( $bits ) );
54 54
 	}
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return string
60 60
 	 */
61
-	public function getUserNum() : string {
62
-		return explode( '/', $this->getTitle(), 3 )[2];
61
+	public function getUserNum () : string {
62
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
63 63
 	}
64 64
 
65 65
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return string
69 69
 	 */
70
-	public function getBaseTitle() : string {
70
+	public function getBaseTitle () : string {
71 71
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug
72 72
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
73 73
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return int
79 79
 	 */
80
-	public function getOpposingCount() : int {
80
+	public function getOpposingCount () : int {
81 81
 		return $this->getCountForSection( $this->opposeSection );
82 82
 	}
83 83
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @return int
88 88
 	 * @throws \BadMethodCallException
89 89
 	 */
90
-	public function getSupportCount() : int {
90
+	public function getSupportCount () : int {
91 91
 		if ( !$this->isVote() ) {
92 92
 			throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' );
93 93
 		}
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 * @param int $secNum
101 101
 	 * @return int
102 102
 	 */
103
-	protected function getCountForSection( int $secNum ) : int {
104
-		static $cache = [];
103
+	protected function getCountForSection ( int $secNum ) : int {
104
+		static $cache = [ ];
105 105
 		if ( !isset( $cache[ $secNum ] ) ) {
106 106
 			$content = $this->controller->getPageContent( $this->title, $secNum );
107 107
 			// Let's hope that this is good enough...
108
-			$cache[$secNum] = preg_match_all( "/^\# *(?![# *]|\.\.\.$)/m", $content );
108
+			$cache[ $secNum ] = preg_match_all( "/^\# *(?![# *]|\.\.\.$)/m", $content );
109 109
 		}
110
-		return $cache[$secNum];
110
+		return $cache[ $secNum ];
111 111
 	}
112 112
 
113 113
 	/**
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return int
117 117
 	 */
118
-	protected function getQuorum() : int {
118
+	protected function getQuorum () : int {
119 119
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
120
-		return intval( $this->getMatch( $reg )[1] );
120
+		return intval( $this->getMatch( $reg )[ 1 ] );
121 121
 	}
122 122
 
123 123
 	/**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @return bool
127 127
 	 */
128
-	public function hasOpposition() : bool {
128
+	public function hasOpposition () : bool {
129 129
 		return $this->getOpposingCount() >= self::REQUIRED_OPPOSE;
130 130
 	}
131 131
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return int One of the OUTCOME_* constants
136 136
 	 * @throws \BadMethodCallException
137 137
 	 */
138
-	public function getOutcome() : int {
138
+	public function getOutcome () : int {
139 139
 		if ( !$this->isVote() ) {
140 140
 			throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' );
141 141
 		}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @throws \BadMethodCallException
156 156
 	 * @throws \LogicException
157 157
 	 */
158
-	public function getOutcomeText() : string {
158
+	public function getOutcomeText () : string {
159 159
 		if ( !$this->isVote() ) {
160 160
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
161 161
 		}
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return bool
191 191
 	 */
192
-	public function isVote() : bool {
192
+	public function isVote () : bool {
193 193
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
194 194
 		return !$this->matches( $sectionReg );
195 195
 	}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return int
201 201
 	 */
202
-	public function getCreationTimestamp() : int {
202
+	public function getCreationTimestamp () : int {
203 203
 		return $this->controller->getPageCreationTS( $this->title );
204 204
 	}
205 205
 	/**
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @return int
209 209
 	 */
210
-	public function getEndTimestamp() : int {
210
+	public function getEndTimestamp () : int {
211 211
 		if ( $this->isVote() ) {
212 212
 			$reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!";
213 213
 			list( , $hours, $day ) = $this->getMatch( $reg );
Please login to merge, or discard this patch.