Passed
Push — master ( 0986c5...31e6ff )
by Daimona
01:50
created
includes/TaskDataProvider.php 1 patch
Spacing   +15 added lines, -17 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
 
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 	/** @var array[] */
14 14
 	private $allUsers;
15 15
 	/** @var PageRiconferma[] */
16
-	private $createdPages = [];
16
+	private $createdPages = [ ];
17 17
 
18 18
 	/**
19 19
 	 * Get the full content of the JSON users list
20 20
 	 *
21 21
 	 * @return array[]
22 22
 	 */
23
-	public function getUsersList() : array {
23
+	public function getUsersList () : array {
24 24
 		if ( $this->allUsers === null ) {
25 25
 			$this->getLogger()->debug( 'Retrieving users list' );
26 26
 			$content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) );
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return array[]
37 37
 	 */
38
-	public function getUsersToProcess() : array {
38
+	public function getUsersToProcess () : array {
39 39
 		if ( $this->processUsers === null ) {
40
-			$this->processUsers = [];
40
+			$this->processUsers = [ ];
41 41
 			foreach ( $this->getUsersList() as $user => $groups ) {
42 42
 				$timestamp = $this->getValidTimestamp( $groups );
43 43
 
@@ -59,13 +59,11 @@  discard block
 block discarded – undo
59 59
 	 * @param array $groups
60 60
 	 * @return int
61 61
 	 */
62
-	private function getValidTimestamp( array $groups ) : int {
62
+	private function getValidTimestamp ( array $groups ) : int {
63 63
 		$checkuser = isset( $groups[ 'checkuser' ] ) ?
64
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() :
65
-			0;
64
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
66 65
 		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
67
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() :
68
-			0;
66
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
69 67
 
70 68
 		$timestamp = max( $bureaucrat, $checkuser );
71 69
 		if ( $timestamp === 0 ) {
@@ -79,7 +77,7 @@  discard block
 block discarded – undo
79 77
 	 *
80 78
 	 * @return PageRiconferma[]
81 79
 	 */
82
-	public function getOpenPages() : array {
80
+	public function getOpenPages () : array {
83 81
 		$baseTitle = $this->getConfig()->get( 'ric-main-page' );
84 82
 		$params = [
85 83
 			'action' => 'query',
@@ -91,10 +89,10 @@  discard block
 block discarded – undo
91 89
 
92 90
 		$res = RequestBase::newFromParams( $params )->execute();
93 91
 		$pages = $res->query->pages;
94
-		$ret = [];
92
+		$ret = [ ];
95 93
 		foreach ( reset( $pages )->templates as $page ) {
96 94
 			if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) {
97
-				$ret[] = new PageRiconferma( $page->title, $this->getController() );
95
+				$ret[ ] = new PageRiconferma( $page->title, $this->getController() );
98 96
 			}
99 97
 		}
100 98
 		return $ret;
@@ -105,21 +103,21 @@  discard block
 block discarded – undo
105 103
 	 *
106 104
 	 * @param string $name
107 105
 	 */
108
-	public function removeUser( string $name ) {
106
+	public function removeUser ( string $name ) {
109 107
 		unset( $this->processUsers[ $name ] );
110 108
 	}
111 109
 
112 110
 	/**
113 111
 	 * @return PageRiconferma[]
114 112
 	 */
115
-	public function getCreatedPages() : array {
113
+	public function getCreatedPages () : array {
116 114
 		return $this->createdPages;
117 115
 	}
118 116
 
119 117
 	/**
120 118
 	 * @param PageRiconferma $page
121 119
 	 */
122
-	public function addCreatedPages( PageRiconferma $page ) {
123
-		$this->createdPages[] = $page;
120
+	public function addCreatedPages ( PageRiconferma $page ) {
121
+		$this->createdPages[ ] = $page;
124 122
 	}
125 123
 }
Please login to merge, or discard this patch.
includes/PageRiconferma.php 1 patch
Spacing   +19 added lines, -19 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
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @return string
23 23
 	 */
24
-	public function getUser() : string {
25
-		return explode( '/', $this->title )[2];
24
+	public function getUser () : string {
25
+		return explode( '/', $this->title )[ 2 ];
26 26
 	}
27 27
 
28 28
 	/**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return int
32 32
 	 */
33
-	public function getNum() : int {
33
+	public function getNum () : int {
34 34
 		$bits = explode( '/', $this->getTitle() );
35 35
 		return intval( end( $bits ) );
36 36
 	}
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return string
42 42
 	 */
43
-	public function getUserNum() : string {
44
-		return explode( '/', $this->getTitle(), 3 )[2];
43
+	public function getUserNum () : string {
44
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
45 45
 	}
46 46
 
47 47
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @return string
51 51
 	 */
52
-	public function getBaseTitle() : string {
52
+	public function getBaseTitle () : string {
53 53
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug
54 54
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
55 55
 	}
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return int
61 61
 	 */
62
-	public function getOpposingCount() : int {
62
+	public function getOpposingCount () : int {
63 63
 		return $this->getCountForSection( self::SECTION_OPPOSE );
64 64
 	}
65 65
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @return int
70 70
 	 */
71
-	public function getSupportCount() : int {
71
+	public function getSupportCount () : int {
72 72
 		return $this->getCountForSection( self::SECTION_SUPPORT );
73 73
 	}
74 74
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param int $secNum
79 79
 	 * @return int
80 80
 	 */
81
-	protected function getCountForSection( int $secNum ) : int {
81
+	protected function getCountForSection ( int $secNum ) : int {
82 82
 		$content = $this->controller->getPageContent( $this->title, $secNum );
83 83
 		// Let's hope that this is good enough...
84 84
 		return substr_count( $content, "\n\# *(?![#*])" );
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return int
91 91
 	 */
92
-	protected function getQuorum() : int {
92
+	protected function getQuorum () : int {
93 93
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
94
-		$matches = [];
94
+		$matches = [ ];
95 95
 		preg_match( $reg, $this->getContent(), $matches );
96
-		return intval( $matches[1] );
96
+		return intval( $matches[ 1 ] );
97 97
 	}
98 98
 
99 99
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return bool
103 103
 	 */
104
-	public function hasOpposition() : bool {
104
+	public function hasOpposition () : bool {
105 105
 		return $this->getOpposingCount() >= 15;
106 106
 	}
107 107
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @return int One of the OUTCOME_* constants
112 112
 	 * @throws \BadMethodCallException
113 113
 	 */
114
-	public function getOutcome() : int {
114
+	public function getOutcome () : int {
115 115
 		if ( !$this->isVote() ) {
116 116
 			throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' );
117 117
 		}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @return string
131 131
 	 * @throws \BadMethodCallException
132 132
 	 */
133
-	public function getOutcomeText() : string {
133
+	public function getOutcomeText () : string {
134 134
 		if ( !$this->isVote() ) {
135 135
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
136 136
 		}
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 *
163 163
 	 * @return bool
164 164
 	 */
165
-	public function isVote() : bool {
165
+	public function isVote () : bool {
166 166
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
167 167
 		return preg_match( $sectionReg, $this->getContent() ) === false;
168 168
 	}
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return int
174 174
 	 */
175
-	public function getEndTimestamp() : int {
175
+	public function getEndTimestamp () : int {
176 176
 		if ( $this->isVote() ) {
177
-			$matches = [];
177
+			$matches = [ ];
178 178
 			$reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!";
179 179
 			preg_match( $reg, $this->getContent(), $matches );
180 180
 			list( , $day, $hours ) = $matches;
Please login to merge, or discard this patch.
includes/Page.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;
4 4
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 * @param string $title
18 18
 	 * @param WikiController $controller
19 19
 	 */
20
-	public function __construct( string $title, WikiController $controller ) {
20
+	public function __construct ( string $title, WikiController $controller ) {
21 21
 		$this->title = $title;
22 22
 		$this->controller = $controller;
23 23
 	}
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * @return string
27 27
 	 */
28
-	public function getTitle() : string {
28
+	public function getTitle () : string {
29 29
 		return $this->title;
30 30
 	}
31 31
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param int|null $section A section number to retrieve the content of that section
36 36
 	 * @return string
37 37
 	 */
38
-	public function getContent( int $section = null ) : string {
38
+	public function getContent ( int $section = null ) : string {
39 39
 		if ( $this->content === null ) {
40 40
 			$this->content = $this->controller->getPageContent( $this->title, $section );
41 41
 		}
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @param array $params
49 49
 	 */
50
-	public function edit( array $params ) {
50
+	public function edit ( array $params ) {
51 51
 		$params = [
52 52
 			'title' => $this->getTitle()
53 53
 		] + $params;
54 54
 
55 55
 		$this->controller->editPage( $params );
56
-		if ( isset( $params['text'] ) ) {
57
-			$this->content = $params['text'];
58
-		} elseif ( isset( $params['appendtext'] ) ) {
59
-			$this->content .= $params['appendtext'];
56
+		if ( isset( $params[ 'text' ] ) ) {
57
+			$this->content = $params[ 'text' ];
58
+		} elseif ( isset( $params[ 'appendtext' ] ) ) {
59
+			$this->content .= $params[ 'appendtext' ];
60 60
 		} else {
61 61
 			// Clear the cache anyway
62 62
 			( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) );
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return string
71 71
 	 */
72
-	public function __toString() {
72
+	public function __toString () {
73 73
 		return $this->getTitle();
74 74
 	}
75 75
 }
Please login to merge, or discard this patch.
includes/Task/UpdatesAround.php 1 patch
Spacing   +9 added lines, -9 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,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	public function run() : TaskResult {
18
+	public function run () : TaskResult {
19 19
 		$this->getLogger()->info( 'Starting task UpdatesAround' );
20 20
 
21 21
 		$pages = $this->getDataProvider()->getCreatedPages();
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @param PageRiconferma[] $pages
41 41
 	 */
42
-	protected function addToMainPage( array $pages ) {
42
+	protected function addToMainPage ( array $pages ) {
43 43
 		$this->getLogger()->info(
44 44
 			'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) )
45 45
 		);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param PageRiconferma[] $pages
68 68
 	 */
69
-	protected function addVote( array $pages ) {
69
+	protected function addVote ( array $pages ) {
70 70
 		$this->getLogger()->info(
71 71
 			'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) )
72 72
 		);
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 );
88 88
 		} else {
89 89
 			// Start section
90
-			$matches = [];
90
+			$matches = [ ];
91 91
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
92 92
 				throw new TaskException( 'Intro not found in vote page' );
93 93
 			}
94 94
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
95 95
 			// Replace semicolon with full stop
96 96
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
97
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 );
97
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 );
98 98
 		}
99 99
 
100 100
 		$summary = $this->msg( 'ric-vote-page-summary' )
@@ -113,19 +113,19 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @param int $amount
115 115
 	 */
116
-	protected function addNews( int $amount ) {
116
+	protected function addNews ( int $amount ) {
117 117
 		$this->getLogger()->info( "Increasing the news counter by $amount" );
118 118
 		$newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ), $this->getController() );
119 119
 
120 120
 		$content = $newsPage->getContent();
121 121
 		$reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
122 122
 
123
-		$matches = [];
123
+		$matches = [ ];
124 124
 		if ( preg_match( $reg, $content, $matches ) === false ) {
125 125
 			throw new TaskException( 'Param not found in news page' );
126 126
 		}
127 127
 
128
-		$newNum = (int)$matches[2] + $amount;
128
+		$newNum = (int)$matches[ 2 ] + $amount;
129 129
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
130 130
 
131 131
 		$summary = $this->msg( 'ric-news-page-summary' )
Please login to merge, or discard this patch.
includes/Task/UpdateList.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	/**
19 19
 	 * @inheritDoc
20 20
 	 */
21
-	public function run() : TaskResult {
21
+	public function run () : TaskResult {
22 22
 		$this->getLogger()->info( 'Starting task UpdateList' );
23 23
 		$this->actualList = $this->getActualAdmins();
24 24
 		$this->botList = $this->getDataProvider()->getUsersList();
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * @return array
55 55
 	 */
56
-	protected function getActualAdmins() : array {
56
+	protected function getActualAdmins () : array {
57 57
 		$this->getLogger()->debug( 'Retrieving admins - API' );
58 58
 		$params = [
59 59
 			'action' => 'query',
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 * @param \stdClass $data
72 72
 	 * @return array
73 73
 	 */
74
-	protected function extractAdmins( \stdClass $data ) : array {
75
-		$ret = [];
74
+	protected function extractAdmins ( \stdClass $data ) : array {
75
+		$ret = [ ];
76 76
 		$blacklist = $this->getConfig()->get( 'exclude-admins' );
77 77
 		foreach ( $data->query->allusers as $u ) {
78 78
 			if ( in_array( $u->name, $blacklist ) ) {
@@ -89,22 +89,22 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return array[]
91 91
 	 */
92
-	protected function getMissingGroups() : array {
93
-		$missing = [];
92
+	protected function getMissingGroups () : array {
93
+		$missing = [ ];
94 94
 		foreach ( $this->actualList as $adm => $groups ) {
95
-			$groupsList = [];
95
+			$groupsList = [ ];
96 96
 			if ( !isset( $this->botList[ $adm ] ) ) {
97 97
 				$groupsList = $groups;
98
-			} elseif ( count( $groups ) > count( $this->botList[$adm] ) ) {
98
+			} elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) {
99 99
 				// Only some groups are missing
100
-				$groupsList = array_diff_key( $groups, $this->botList[$adm] );
100
+				$groupsList = array_diff_key( $groups, $this->botList[ $adm ] );
101 101
 			}
102 102
 
103 103
 			foreach ( $groupsList as $group ) {
104 104
 				try {
105 105
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
106 106
 				} catch ( TaskException $e ) {
107
-					$this->errors[] = $e->getMessage();
107
+					$this->errors[ ] = $e->getMessage();
108 108
 				}
109 109
 			}
110 110
 		}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @return string
120 120
 	 * @throws TaskException
121 121
 	 */
122
-	protected function getFlagDate( string $admin, string $group ) : string {
122
+	protected function getFlagDate ( string $admin, string $group ) : string {
123 123
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
124 124
 
125 125
 		if ( $group === 'checkuser' ) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @param string $group
160 160
 	 * @return string|null
161 161
 	 */
162
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
162
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
163 163
 		$ts = null;
164 164
 		foreach ( $data->query->logevents as $entry ) {
165 165
 			if ( !isset( $entry->params ) ) {
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return array[]
183 183
 	 */
184
-	protected function getExtraGroups() : array {
185
-		$extra = [];
184
+	protected function getExtraGroups () : array {
185
+		$extra = [ ];
186 186
 		foreach ( $this->botList as $name => $groups ) {
187 187
 			if ( !isset( $this->actualList[ $name ] ) ) {
188 188
 				$extra[ $name ] = $groups;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @param array $newContent
200 200
 	 */
201
-	protected function doUpdateList( array $newContent ) {
201
+	protected function doUpdateList ( array $newContent ) {
202 202
 		$this->getLogger()->info( 'Updating admin list' );
203 203
 
204 204
 		$params = [
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * @param array[] $extra
218 218
 	 * @return array[]
219 219
 	 */
220
-	protected function getNewContent( array $missing, array $extra ) : array {
220
+	protected function getNewContent ( array $missing, array $extra ) : array {
221 221
 		$newContent = $this->botList;
222 222
 		foreach ( $newContent as $user => $groups ) {
223 223
 			if ( isset( $missing[ $user ] ) ) {
Please login to merge, or discard this patch.
includes/Task/StartVote.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;
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	public function run() : TaskResult {
18
+	public function run () : TaskResult {
19 19
 		$this->getLogger()->info( 'Starting task StartVote' );
20 20
 
21 21
 		$pages = $this->getDataProvider()->getOpenPages();
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @param PageRiconferma[] $pages
35 35
 	 */
36
-	protected function processPages( array $pages ) {
37
-		$actualPages = [];
36
+	protected function processPages ( array $pages ) {
37
+		$actualPages = [ ];
38 38
 		foreach ( $pages as $page ) {
39 39
 			if ( $page->hasOpposition() && !$page->isVote() ) {
40 40
 				$this->openVote( $page );
41
-				$actualPages[] = $page;
41
+				$actualPages[ ] = $page;
42 42
 			}
43 43
 		}
44 44
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param PageRiconferma $page
57 57
 	 */
58
-	protected function openVote( PageRiconferma $page ) {
58
+	protected function openVote ( PageRiconferma $page ) {
59 59
 		$this->getLogger()->info( "Starting vote on $page" );
60 60
 
61 61
 		$content = $page->getContent();
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 	 * @see ClosePages::updateVote()
95 95
 	 * @see UpdatesAround::addVote()
96 96
 	 */
97
-	protected function updateVotePage( array $pages ) {
97
+	protected function updateVotePage ( array $pages ) {
98 98
 		$votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ), $this->getController() );
99 99
 		$content = $votePage->getContent();
100 100
 
101
-		$titles = [];
101
+		$titles = [ ];
102 102
 		foreach ( $pages as $page ) {
103
-			$titles[] = preg_quote( $page->getTitle() );
103
+			$titles[ ] = preg_quote( $page->getTitle() );
104 104
 		}
105 105
 		$titleReg = implode( '|', array_map( 'preg_quote', $titles ) );
106 106
 		$search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!gm";
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 );
124 124
 		} else {
125 125
 			// Start section
126
-			$matches = [];
126
+			$matches = [ ];
127 127
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
128 128
 				throw new TaskException( 'Intro not found in vote page' );
129 129
 			}
130 130
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
131 131
 			// Replace semicolon with full stop
132 132
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
133
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 );
133
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 );
134 134
 		}
135 135
 
136 136
 		$summary = $this->msg( 'vote-start-vote-page-summary' )
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @see UpdatesAround::addNews()
153 153
 	 * @see ClosePages::updateNews()
154 154
 	 */
155
-	protected function updateNews( int $amount ) {
155
+	protected function updateNews ( int $amount ) {
156 156
 		$this->getLogger()->info( "Turning $amount pages into votes" );
157 157
 		$newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ), $this->getController() );
158 158
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		$regTac = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
161 161
 		$regVot = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!';
162 162
 
163
-		$tacMatches = $votMatches = [];
163
+		$tacMatches = $votMatches = [ ];
164 164
 		if ( preg_match( $regTac, $content, $tacMatches ) === false ) {
165 165
 			throw new TaskException( 'Param "tacite" not found in news page' );
166 166
 		}
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 			throw new TaskException( 'Param "voto" not found in news page' );
169 169
 		}
170 170
 
171
-		$newTac = (int)$tacMatches[2] - $amount ?: '';
172
-		$newVot = (int)$votMatches[2] + $amount ?: '';
171
+		$newTac = (int)$tacMatches[ 2 ] - $amount ?: '';
172
+		$newVot = (int)$votMatches[ 2 ] + $amount ?: '';
173 173
 
174 174
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
175 175
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/Task/ClosePages.php 1 patch
Spacing   +54 added lines, -55 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,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	public function run() : TaskResult {
18
+	public function run () : TaskResult {
19 19
 		$this->getLogger()->info( 'Starting task ClosePages' );
20 20
 
21 21
 		$pages = $this->getPagesList();
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return PageRiconferma[]
54 54
 	 */
55
-	protected function getPagesList() : array {
55
+	protected function getPagesList () : array {
56 56
 		$allPages = $this->getDataProvider()->getOpenPages();
57
-		$ret = [];
57
+		$ret = [ ];
58 58
 		foreach ( $allPages as $page ) {
59 59
 			if ( time() > $page->getEndTimestamp() ) {
60
-				$ret[] = $page;
60
+				$ret[ ] = $page;
61 61
 			}
62 62
 		}
63 63
 		return $ret;
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 	 * @param PageRiconferma[] $pages
70 70
 	 * @return PageRiconferma[]
71 71
 	 */
72
-	private function getFailures( array $pages ) : array {
73
-		$ret = [];
72
+	private function getFailures ( array $pages ) : array {
73
+		$ret = [ ];
74 74
 		foreach ( $pages as $page ) {
75 75
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
76
-				$ret[] = $page;
76
+				$ret[ ] = $page;
77 77
 			}
78 78
 		}
79 79
 		return $ret;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	/**
83 83
 	 * @param PageRiconferma $page
84 84
 	 */
85
-	protected function addVoteCloseText( PageRiconferma $page ) {
85
+	protected function addVoteCloseText ( PageRiconferma $page ) {
86 86
 		$content = $page->getContent();
87 87
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!';
88 88
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	 * @param PageRiconferma[] $pages
101 101
 	 * @see UpdatesAround::addToMainPage()
102 102
 	 */
103
-	protected function removeFromMainPage( array $pages ) {
103
+	protected function removeFromMainPage ( array $pages ) {
104 104
 		$this->getLogger()->info(
105 105
 			'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) )
106 106
 		);
107 107
 
108 108
 		$mainPage = new Page( $this->getConfig()->get( 'ric-main-page' ), $this->getController() );
109
-		$translations = [];
109
+		$translations = [ ];
110 110
 		foreach ( $pages as $page ) {
111 111
 			$translations[ '{{' . $page->getTitle() . '}}' ] = '';
112 112
 		}
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @param PageRiconferma[] $pages
126 126
 	 */
127
-	protected function addToArchive( array $pages ) {
127
+	protected function addToArchive ( array $pages ) {
128 128
 		$this->getLogger()->info(
129 129
 			'Adding to archive: ' . implode( ', ', array_map( 'strval', $pages ) )
130 130
 		);
131 131
 
132
-		$simple = $votes = [];
132
+		$simple = $votes = [ ];
133 133
 		foreach ( $pages as $page ) {
134 134
 			if ( $page->isVote() ) {
135
-				$votes[] = $page;
135
+				$votes[ ] = $page;
136 136
 			} else {
137
-				$simple[] = $page;
137
+				$simple[ ] = $page;
138 138
 			}
139 139
 		}
140 140
 
@@ -151,21 +151,21 @@  discard block
 block discarded – undo
151 151
 	 * @param string $archiveTitle
152 152
 	 * @param array $pages
153 153
 	 */
154
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) {
154
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) {
155 155
 		$curTitle = "$archiveTitle/" . date( 'Y' );
156 156
 
157 157
 		$append = '';
158
-		$archivedList = [];
158
+		$archivedList = [ ];
159 159
 		foreach ( $pages as $page ) {
160 160
 			$append .= '{{' . $page->getTitle() . "}}\n";
161
-			$archivedList[] = $page->getUserNum();
161
+			$archivedList[ ] = $page->getUserNum();
162 162
 		}
163 163
 
164 164
 		if ( count( $archivedList ) > 1 ) {
165 165
 			$last = array_pop( $archivedList );
166 166
 			$userNums = implode( ', ', $archivedList ) . " e $last";
167 167
 		} else {
168
-			$userNums = $archivedList[0];
168
+			$userNums = $archivedList[ 0 ];
169 169
 		}
170 170
 
171 171
 		$summary = $this->msg( 'close-archive-summary' )
@@ -184,15 +184,14 @@  discard block
 block discarded – undo
184 184
 	 * @param PageRiconferma $page
185 185
 	 * @see CreatePages::updateBasePage()
186 186
 	 */
187
-	protected function updateBasePage( PageRiconferma $page ) {
187
+	protected function updateBasePage ( PageRiconferma $page ) {
188 188
 		$this->getLogger()->info( "Updating base page for $page" );
189 189
 
190 190
 		$basePage = new Page( $page->getBaseTitle(), $this->getController() );
191 191
 		$current = $basePage->getContent();
192 192
 
193 193
 		$outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ?
194
-			'non riconfermato' :
195
-			'riconfermato';
194
+			'non riconfermato' : 'riconfermato';
196 195
 		$text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita';
197 196
 
198 197
 		$newContent = str_replace( 'riconferma in corso', $text, $current );
@@ -208,16 +207,16 @@  discard block
 block discarded – undo
208 207
 	 * @param PageRiconferma[] $pages
209 208
 	 * @see UpdatesAround::addVote()
210 209
 	 */
211
-	protected function updateVote( array $pages ) {
210
+	protected function updateVote ( array $pages ) {
212 211
 		$this->getLogger()->info(
213 212
 			'Updating votazioni: ' . implode( ', ', array_map( 'strval', $pages ) )
214 213
 		);
215 214
 		$votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ), $this->getController() );
216 215
 		$content = $votePage->getContent();
217 216
 
218
-		$titles = [];
217
+		$titles = [ ];
219 218
 		foreach ( $pages as $page ) {
220
-			$titles[] = preg_quote( $page->getTitle() );
219
+			$titles[ ] = preg_quote( $page->getTitle() );
221 220
 		}
222 221
 
223 222
 		$titleReg = implode( '|', array_map( 'preg_quote', $titles ) );
@@ -248,7 +247,7 @@  discard block
 block discarded – undo
248 247
 	 * @param array $pages
249 248
 	 * @see UpdatesAround::addNews()
250 249
 	 */
251
-	protected function updateNews( array $pages ) {
250
+	protected function updateNews ( array $pages ) {
252 251
 		$simpleAmount = $voteAmount = 0;
253 252
 		foreach ( $pages as $page ) {
254 253
 			if ( $page->isVote() ) {
@@ -268,12 +267,12 @@  discard block
 block discarded – undo
268 267
 		$simpleReg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
269 268
 		$voteReg = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!';
270 269
 
271
-		$simpleMatches = $voteMatches = [];
270
+		$simpleMatches = $voteMatches = [ ];
272 271
 		preg_match( $simpleReg, $content, $simpleMatches );
273 272
 		preg_match( $voteReg, $content, $voteMatches );
274 273
 
275
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
276
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
274
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
275
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
277 276
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content );
278 277
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
279 278
 
@@ -293,7 +292,7 @@  discard block
 block discarded – undo
293 292
 	 *
294 293
 	 * @param PageRiconferma[] $pages
295 294
 	 */
296
-	protected function updateAdminList( array $pages ) {
295
+	protected function updateAdminList ( array $pages ) {
297 296
 		$this->getLogger()->info(
298 297
 			'Updating admin list: ' . implode( ', ', array_map( 'strval', $pages ) )
299 298
 		);
@@ -301,17 +300,17 @@  discard block
 block discarded – undo
301 300
 		$newContent = $adminsPage->getContent();
302 301
 		$newDate = date( 'Ymd', strtotime( '+1 year' ) );
303 302
 
304
-		$riconfNames = $removeNames = [];
303
+		$riconfNames = $removeNames = [ ];
305 304
 		foreach ( $pages as $page ) {
306 305
 			$user = $page->getUser();
307 306
 			$reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!";
308 307
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
309 308
 				// Remove the line
310 309
 				$newContent = preg_replace( $reg, '', $newContent );
311
-				$removeNames[] = $user;
310
+				$removeNames[ ] = $user;
312 311
 			} else {
313 312
 				$newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent );
314
-				$riconfNames[] = $user;
313
+				$riconfNames[ ] = $user;
315 314
 			}
316 315
 		}
317 316
 
@@ -319,7 +318,7 @@  discard block
 block discarded – undo
319 318
 			$lastUser = array_pop( $riconfNames );
320 319
 			$riconfList = implode( ', ', $riconfNames ) . " e $lastUser";
321 320
 		} elseif ( $riconfNames ) {
322
-			$riconfList = $riconfNames[0];
321
+			$riconfList = $riconfNames[ 0 ];
323 322
 		} else {
324 323
 			$riconfList = 'nessuno';
325 324
 		}
@@ -328,7 +327,7 @@  discard block
 block discarded – undo
328 327
 			$lastUser = array_pop( $removeNames );
329 328
 			$removeList = implode( ', ', $removeNames ) . " e $lastUser";
330 329
 		} elseif ( $removeNames ) {
331
-			$removeList = $removeNames[0];
330
+			$removeList = $removeNames[ 0 ];
332 331
 		} else {
333 332
 			$removeList = 'nessuno';
334 333
 		}
@@ -351,13 +350,13 @@  discard block
 block discarded – undo
351 350
 	/**
352 351
 	 * @param PageRiconferma[] $pages
353 352
 	 */
354
-	protected function updateCUList( array $pages ) {
353
+	protected function updateCUList ( array $pages ) {
355 354
 		$this->getLogger()->info( 'Checking if CU list needs updating.' );
356 355
 		$cuList = new Page( $this->getConfig()->get( 'cu-list-title' ), $this->getController() );
357 356
 		$admins = $this->getDataProvider()->getUsersList();
358 357
 		$newContent = $cuList->getContent();
359 358
 
360
-		$riconfNames = $removeNames = [];
359
+		$riconfNames = $removeNames = [ ];
361 360
 		foreach ( $pages as $page ) {
362 361
 			$user = $page->getUser();
363 362
 			if ( array_key_exists( 'checkuser', $admins[ $user ] ) ) {
@@ -365,10 +364,10 @@  discard block
 block discarded – undo
365 364
 				if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
366 365
 					// Remove the line
367 366
 					$newContent = preg_replace( $reg, '', $newContent );
368
-					$removeNames[] = $user;
367
+					$removeNames[ ] = $user;
369 368
 				} else {
370 369
 					$newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent );
371
-					$riconfNames[] = $user;
370
+					$riconfNames[ ] = $user;
372 371
 				}
373 372
 			}
374 373
 		}
@@ -385,7 +384,7 @@  discard block
 block discarded – undo
385 384
 			$lastUser = array_pop( $riconfNames );
386 385
 			$riconfList = implode( ', ', $riconfNames ) . " e $lastUser";
387 386
 		} elseif ( $riconfNames ) {
388
-			$riconfList = $riconfNames[0];
387
+			$riconfList = $riconfNames[ 0 ];
389 388
 		} else {
390 389
 			$riconfList = 'nessuno';
391 390
 		}
@@ -394,7 +393,7 @@  discard block
 block discarded – undo
394 393
 			$lastUser = array_pop( $removeNames );
395 394
 			$removeList = implode( ', ', $removeNames ) . " e $lastUser";
396 395
 		} elseif ( $removeNames ) {
397
-			$removeList = $removeNames[0];
396
+			$removeList = $removeNames[ 0 ];
398 397
 		} else {
399 398
 			$removeList = 'nessuno';
400 399
 		}
@@ -416,17 +415,17 @@  discard block
 block discarded – undo
416 415
 	/**
417 416
 	 * @param PageRiconferma[] $pages
418 417
 	 */
419
-	protected function updateBurList( array $pages ) {
418
+	protected function updateBurList ( array $pages ) {
420 419
 		$this->getLogger()->info( 'Checking if bur list needs updating.' );
421
-		$admins =  $this->getDataProvider()->getUsersList();
420
+		$admins = $this->getDataProvider()->getUsersList();
422 421
 
423
-		$remove = [];
422
+		$remove = [ ];
424 423
 		foreach ( $pages as $page ) {
425 424
 			$user = $page->getUser();
426 425
 			if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) &&
427 426
 				$page->getOutcome() & PageRiconferma::OUTCOME_FAIL
428 427
 			) {
429
-				$remove[] = $user;
428
+				$remove[ ] = $user;
430 429
 			}
431 430
 		}
432 431
 
@@ -445,7 +444,7 @@  discard block
 block discarded – undo
445 444
 			$lastUser = array_pop( $remove );
446 445
 			$removeList = implode( ', ', $remove ) . " e $lastUser";
447 446
 		} else {
448
-			$removeList = $remove[0];
447
+			$removeList = $remove[ 0 ];
449 448
 		}
450 449
 
451 450
 		$summary = $this->msg( 'bur-list-update-summary' )
@@ -464,7 +463,7 @@  discard block
 block discarded – undo
464 463
 	 *
465 464
 	 * @param PageRiconferma[] $pages
466 465
 	 */
467
-	protected function requestRemoval( array $pages ) {
466
+	protected function requestRemoval ( array $pages ) {
468 467
 		$this->getLogger()->info(
469 468
 			'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) )
470 469
 		);
@@ -508,14 +507,14 @@  discard block
 block discarded – undo
508 507
 	 *
509 508
 	 * @param PageRiconferma[] $pages
510 509
 	 */
511
-	protected function updateAnnunci( array $pages ) {
510
+	protected function updateAnnunci ( array $pages ) {
512 511
 		$this->getLogger()->info( 'Updating annunci' );
513 512
 
514
-		$names = [];
513
+		$names = [ ];
515 514
 		$text = '';
516 515
 		foreach ( $pages as $page ) {
517 516
 			$user = $page->getUser();
518
-			$names[] = $user;
517
+			$names[ ] = $user;
519 518
 			$text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " .
520 519
 				"non è stato riconfermato [[WP:A|amministratore]].}}\n";
521 520
 		}
@@ -538,7 +537,7 @@  discard block
 block discarded – undo
538 537
 			$lastUser = array_pop( $names );
539 538
 			$namesList = implode( ', ', $names ) . " e $lastUser";
540 539
 		} else {
541
-			$namesList = $names[0];
540
+			$namesList = $names[ 0 ];
542 541
 		}
543 542
 
544 543
 		$summary = $this->msg( 'annunci-summary' )
@@ -557,16 +556,16 @@  discard block
 block discarded – undo
557 556
 	 *
558 557
 	 * @param PageRiconferma[] $pages
559 558
 	 */
560
-	protected function updateUltimeNotizie( array $pages ) {
559
+	protected function updateUltimeNotizie ( array $pages ) {
561 560
 		$this->getLogger()->info( 'Updating ultime notizie' );
562 561
 		$notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-title' ), $this->getController() );
563 562
 
564
-		$names = [];
563
+		$names = [ ];
565 564
 		$text = '';
566 565
 		foreach ( $pages as $page ) {
567 566
 			$user = $page->getUser();
568 567
 			$title = $page->getTitle();
569
-			$names[] = $user;
568
+			$names[ ] = $user;
570 569
 			$text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " .
571 570
 				'[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.';
572 571
 		}
@@ -585,7 +584,7 @@  discard block
 block discarded – undo
585 584
 			$lastUser = array_pop( $names );
586 585
 			$namesList = implode( ', ', $names ) . " e $lastUser";
587 586
 		} else {
588
-			$namesList = $names[0];
587
+			$namesList = $names[ 0 ];
589 588
 		}
590 589
 
591 590
 		$summary = $this->msg( 'ultimenotizie-summary' )
Please login to merge, or discard this patch.