Passed
Push — master ( 2d98cc...0986c5 )
by Daimona
01:45
created
includes/WikiController.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
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	/** @var string[] */
20 20
 	private $tokens;
21 21
 
22
-	public function __construct() {
22
+	public function __construct () {
23 23
 		$this->logger = new Logger;
24 24
 	}
25 25
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @return string
32 32
 	 * @throws MissingPageException
33 33
 	 */
34
-	public function getPageContent( string $title, int $section = null ) : string {
34
+	public function getPageContent ( string $title, int $section = null ) : string {
35 35
 		$this->logger->debug( "Retrieving page $title" );
36 36
 		$params = [
37 37
 			'action' => 'query',
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		];
43 43
 
44 44
 		if ( $section !== null ) {
45
-			$params['rvsection'] = $section;
45
+			$params[ 'rvsection' ] = $section;
46 46
 		}
47 47
 
48 48
 		$req = RequestBase::newFromParams( $params );
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			throw new MissingPageException( $title );
53 53
 		}
54 54
 
55
-		return $page->revisions[0]->slots->main->{ '*' };
55
+		return $page->revisions[ 0 ]->slots->main->{ '*' };
56 56
 	}
57 57
 
58 58
 	/**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 * @param array $params
62 62
 	 * @throws EditException
63 63
 	 */
64
-	public function editPage( array $params ) {
64
+	public function editPage ( array $params ) {
65 65
 		$this->login();
66 66
 
67 67
 		$params = [
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @return string
84 84
 	 * @fixme Not the right place for this
85 85
 	 */
86
-	public static function getTimeWithArticle( int $timestamp ) : string {
86
+	public static function getTimeWithArticle ( int $timestamp ) : string {
87 87
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
88 88
 		$timeString = strftime( '%e %B alle %R', $timestamp );
89 89
 		// Remove the left space if day has a single digit
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
 	 * @fixme Not the right place for this
103 103
 	 * @todo Is there a better way?
104 104
 	 */
105
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
105
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
106 106
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
107 107
 		$bits = strptime( $timeString, '%e %m %Y alle %H:%M' );
108 108
 		$timestamp = mktime(
109
-			$bits['tm_hour'],
110
-			$bits['tm_min'],
109
+			$bits[ 'tm_hour' ],
110
+			$bits[ 'tm_min' ],
111 111
 			0,
112
-			$bits['tm_mon'] + 1,
113
-			$bits['tm_mday'],
114
-			$bits['tm_year'] + 1900
112
+			$bits[ 'tm_mon' ] + 1,
113
+			$bits[ 'tm_mday' ],
114
+			$bits[ 'tm_year' ] + 1900
115 115
 		);
116 116
 		setlocale( LC_TIME, $oldLoc );
117 117
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
122 122
 	 * @throws LoginException
123 123
 	 */
124
-	public function login() {
124
+	public function login () {
125 125
 		if ( self::$loggedIn ) {
126 126
 			$this->logger->debug( 'Already logged in' );
127 127
 			return;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
 		self::$loggedIn = true;
150 150
 		// Clear tokens cache
151
-		$this->tokens = [];
151
+		$this->tokens = [ ];
152 152
 		$this->logger->info( 'Login succeeded' );
153 153
 	}
154 154
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @param string $type
159 159
 	 * @return string
160 160
 	 */
161
-	public function getToken( string $type ) : string {
161
+	public function getToken ( string $type ) : string {
162 162
 		if ( !isset( $this->tokens[ $type ] ) ) {
163 163
 			$params = [
164 164
 				'action' => 'query',
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @param string $title
182 182
 	 * @return int
183 183
 	 */
184
-	public function getPageCreationTS( string $title ) : int {
184
+	public function getPageCreationTS ( string $title ) : int {
185 185
 		$params = [
186 186
 			'action' => 'query',
187 187
 			'prop' => 'revisions',
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
 		$res = ( RequestBase::newFromParams( $params ) )->execute();
196 196
 		$data = $res->query->pages;
197
-		return strtotime( reset( $data )->revisions[0]->timestamp );
197
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
198 198
 	}
199 199
 
200 200
 	/**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @param string $title
204 204
 	 * @param string $reason
205 205
 	 */
206
-	public function protectPage( string $title, string $reason ) {
206
+	public function protectPage ( string $title, string $reason ) {
207 207
 		$this->logger->info( "Protecting page $title" );
208 208
 		$this->login();
209 209
 
Please login to merge, or discard this patch.
includes/ContextSource.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;
4 4
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	/** @var WikiController */
19 19
 	private $controller;
20 20
 
21
-	public function __construct() {
21
+	public function __construct () {
22 22
 		$this->setLogger( new Logger );
23 23
 		$this->setConfig( Config::getInstance() );
24 24
 		$this->setController( new WikiController );
@@ -27,42 +27,42 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @return LoggerInterface
29 29
 	 */
30
-	protected function getLogger() : LoggerInterface {
30
+	protected function getLogger () : LoggerInterface {
31 31
 		return $this->logger;
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	 * @inheritDoc
36 36
 	 */
37
-	public function setLogger( LoggerInterface $logger ) {
37
+	public function setLogger ( LoggerInterface $logger ) {
38 38
 		$this->logger = $logger;
39 39
 	}
40 40
 
41 41
 	/**
42 42
 	 * @return Config
43 43
 	 */
44
-	protected function getConfig() : Config {
44
+	protected function getConfig () : Config {
45 45
 		return $this->config;
46 46
 	}
47 47
 
48 48
 	/**
49 49
 	 * @param Config $cfg
50 50
 	 */
51
-	protected function setConfig( Config $cfg ) {
51
+	protected function setConfig ( Config $cfg ) {
52 52
 		$this->config = $cfg;
53 53
 	}
54 54
 
55 55
 	/**
56 56
 	 * @return WikiController
57 57
 	 */
58
-	protected function getController() : WikiController {
58
+	protected function getController () : WikiController {
59 59
 		return $this->controller;
60 60
 	}
61 61
 
62 62
 	/**
63 63
 	 * @param WikiController $controller
64 64
 	 */
65
-	protected function setController( WikiController $controller ) {
65
+	protected function setController ( WikiController $controller ) {
66 66
 		$this->controller = $controller;
67 67
 	}
68 68
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param string $key
73 73
 	 * @return Message
74 74
 	 */
75
-	protected function msg( string $key ) : Message {
75
+	protected function msg ( string $key ) : Message {
76 76
 		return new Message( $key );
77 77
 	}
78 78
 }
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
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function run() : TaskResult {
17
+	public function run () : TaskResult {
18 18
 		$this->getLogger()->info( 'Starting task UpdatesAround' );
19 19
 
20 20
 		$pages = $this->getDataProvider()->getCreatedPages();
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param PageRiconferma[] $pages
40 40
 	 */
41
-	protected function addToMainPage( array $pages ) {
41
+	protected function addToMainPage ( array $pages ) {
42 42
 		$this->getLogger()->info(
43 43
 			'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) )
44 44
 		);
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param PageRiconferma[] $pages
67 67
 	 */
68
-	protected function addVote( array $pages ) {
68
+	protected function addVote ( array $pages ) {
69 69
 		$this->getLogger()->info(
70 70
 			'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) )
71 71
 		);
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 );
87 87
 		} else {
88 88
 			// Start section
89
-			$matches = [];
89
+			$matches = [ ];
90 90
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
91 91
 				throw new TaskException( 'Intro not found in vote page' );
92 92
 			}
93 93
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
94 94
 			// Replace semicolon with full stop
95 95
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
96
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 );
96
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 );
97 97
 		}
98 98
 
99 99
 		$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 = $this->getConfig()->get( 'ric-news-page' );
119 119
 
120 120
 		$content = $this->getController()->getPageContent( $newsPage );
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/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
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function run() : TaskResult {
17
+	public function run () : TaskResult {
18 18
 		$this->getLogger()->info( 'Starting task StartVote' );
19 19
 
20 20
 		$pages = $this->getDataProvider()->getOpenPages();
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @param PageRiconferma[] $pages
34 34
 	 */
35
-	protected function processPages( array $pages ) {
36
-		$actualPages = [];
35
+	protected function processPages ( array $pages ) {
36
+		$actualPages = [ ];
37 37
 		foreach ( $pages as $page ) {
38 38
 			if ( $page->hasOpposition() && !$page->isVote() ) {
39 39
 				$this->openVote( $page );
40
-				$actualPages[] = $page;
40
+				$actualPages[ ] = $page;
41 41
 			}
42 42
 		}
43 43
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @param PageRiconferma $page
56 56
 	 */
57
-	protected function openVote( PageRiconferma $page ) {
57
+	protected function openVote ( PageRiconferma $page ) {
58 58
 		$this->getLogger()->info( "Starting vote on $page" );
59 59
 
60 60
 		$content = $page->getContent();
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 	 * @see ClosePages::updateVote()
94 94
 	 * @see UpdatesAround::addVote()
95 95
 	 */
96
-	protected function updateVotePage( array $pages ) {
96
+	protected function updateVotePage ( array $pages ) {
97 97
 		$votePage = $this->getConfig()->get( 'ric-vote-page' );
98 98
 		$content = $this->getController()->getPageContent( $votePage );
99 99
 
100
-		$titles = [];
100
+		$titles = [ ];
101 101
 		foreach ( $pages as $page ) {
102
-			$titles[] = preg_quote( $page->getTitle() );
102
+			$titles[ ] = preg_quote( $page->getTitle() );
103 103
 		}
104 104
 		$titleReg = implode( '|', array_map( 'preg_quote', $titles ) );
105 105
 		$search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!gm";
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 );
123 123
 		} else {
124 124
 			// Start section
125
-			$matches = [];
125
+			$matches = [ ];
126 126
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
127 127
 				throw new TaskException( 'Intro not found in vote page' );
128 128
 			}
129 129
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
130 130
 			// Replace semicolon with full stop
131 131
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
132
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 );
132
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 );
133 133
 		}
134 134
 
135 135
 		$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 = $this->getConfig()->get( 'ric-news-page' );
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   +53 added lines, -54 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 run() : TaskResult {
17
+	public function run () : TaskResult {
18 18
 		$this->getLogger()->info( 'Starting task ClosePages' );
19 19
 
20 20
 		$pages = $this->getPagesList();
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @return PageRiconferma[]
53 53
 	 */
54
-	protected function getPagesList() : array {
54
+	protected function getPagesList () : array {
55 55
 		$allPages = $this->getDataProvider()->getOpenPages();
56
-		$ret = [];
56
+		$ret = [ ];
57 57
 		foreach ( $allPages as $page ) {
58 58
 			if ( time() > $page->getEndTimestamp() ) {
59
-				$ret[] = $page;
59
+				$ret[ ] = $page;
60 60
 			}
61 61
 		}
62 62
 		return $ret;
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 	 * @param PageRiconferma[] $pages
69 69
 	 * @return PageRiconferma[]
70 70
 	 */
71
-	private function getFailures( array $pages ) : array {
72
-		$ret = [];
71
+	private function getFailures ( array $pages ) : array {
72
+		$ret = [ ];
73 73
 		foreach ( $pages as $page ) {
74 74
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
75
-				$ret[] = $page;
75
+				$ret[ ] = $page;
76 76
 			}
77 77
 		}
78 78
 		return $ret;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	/**
82 82
 	 * @param PageRiconferma $page
83 83
 	 */
84
-	protected function addVoteCloseText( PageRiconferma $page ) {
84
+	protected function addVoteCloseText ( PageRiconferma $page ) {
85 85
 		$content = $page->getContent();
86 86
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!';
87 87
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
 	 * @param PageRiconferma[] $pages
100 100
 	 * @see UpdatesAround::addToMainPage()
101 101
 	 */
102
-	protected function removeFromMainPage( array $pages ) {
102
+	protected function removeFromMainPage ( array $pages ) {
103 103
 		$this->getLogger()->info(
104 104
 			'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) )
105 105
 		);
106 106
 
107 107
 		$mainPage = $this->getConfig()->get( 'ric-main-page' );
108 108
 		$content = $this->getController()->getPageContent( $mainPage );
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,14 +184,13 @@  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
 		$current = $this->getController()->getPageContent( $page->getBaseTitle() );
191 191
 
192 192
 		$outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ?
193
-			'non riconfermato' :
194
-			'riconfermato';
193
+			'non riconfermato' : 'riconfermato';
195 194
 		$text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita';
196 195
 
197 196
 		$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 = $this->getConfig()->get( 'ric-vote-page' );
216 215
 		$content = $this->getController()->getPageContent( $votePage );
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 ) );
@@ -249,7 +248,7 @@  discard block
 block discarded – undo
249 248
 	 * @param array $pages
250 249
 	 * @see UpdatesAround::addNews()
251 250
 	 */
252
-	protected function updateNews( array $pages ) {
251
+	protected function updateNews ( array $pages ) {
253 252
 		$simpleAmount = $voteAmount = 0;
254 253
 		foreach ( $pages as $page ) {
255 254
 			if ( $page->isVote() ) {
@@ -269,12 +268,12 @@  discard block
 block discarded – undo
269 268
 		$simpleReg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
270 269
 		$voteReg = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!';
271 270
 
272
-		$simpleMatches = $voteMatches = [];
271
+		$simpleMatches = $voteMatches = [ ];
273 272
 		preg_match( $simpleReg, $content, $simpleMatches );
274 273
 		preg_match( $voteReg, $content, $voteMatches );
275 274
 
276
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
277
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
275
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
276
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
278 277
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content );
279 278
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
280 279
 
@@ -295,7 +294,7 @@  discard block
 block discarded – undo
295 294
 	 *
296 295
 	 * @param PageRiconferma[] $pages
297 296
 	 */
298
-	protected function updateAdminList( array $pages ) {
297
+	protected function updateAdminList ( array $pages ) {
299 298
 		$this->getLogger()->info(
300 299
 			'Updating admin list: ' . implode( ', ', array_map( 'strval', $pages ) )
301 300
 		);
@@ -303,17 +302,17 @@  discard block
 block discarded – undo
303 302
 		$newContent = $this->getController()->getPageContent( $listTitle );
304 303
 		$newDate = date( 'Ymd', strtotime( '+1 year' ) );
305 304
 
306
-		$riconfNames = $removeNames = [];
305
+		$riconfNames = $removeNames = [ ];
307 306
 		foreach ( $pages as $page ) {
308 307
 			$user = $page->getUser();
309 308
 			$reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!";
310 309
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
311 310
 				// Remove the line
312 311
 				$newContent = preg_replace( $reg, '', $newContent );
313
-				$removeNames[] = $user;
312
+				$removeNames[ ] = $user;
314 313
 			} else {
315 314
 				$newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent );
316
-				$riconfNames[] = $user;
315
+				$riconfNames[ ] = $user;
317 316
 			}
318 317
 		}
319 318
 
@@ -321,7 +320,7 @@  discard block
 block discarded – undo
321 320
 			$lastUser = array_pop( $riconfNames );
322 321
 			$riconfList = implode( ', ', $riconfNames ) . " e $lastUser";
323 322
 		} elseif ( $riconfNames ) {
324
-			$riconfList = $riconfNames[0];
323
+			$riconfList = $riconfNames[ 0 ];
325 324
 		} else {
326 325
 			$riconfList = 'nessuno';
327 326
 		}
@@ -330,7 +329,7 @@  discard block
 block discarded – undo
330 329
 			$lastUser = array_pop( $removeNames );
331 330
 			$removeList = implode( ', ', $removeNames ) . " e $lastUser";
332 331
 		} elseif ( $removeNames ) {
333
-			$removeList = $removeNames[0];
332
+			$removeList = $removeNames[ 0 ];
334 333
 		} else {
335 334
 			$removeList = 'nessuno';
336 335
 		}
@@ -354,14 +353,14 @@  discard block
 block discarded – undo
354 353
 	/**
355 354
 	 * @param PageRiconferma[] $pages
356 355
 	 */
357
-	protected function updateCUList( array $pages ) {
356
+	protected function updateCUList ( array $pages ) {
358 357
 		$this->getLogger()->info( 'Checking if CU list needs updating.' );
359 358
 		$cuListTitle = $this->getConfig()->get( 'cu-list-title' );
360 359
 		$listTitle = $this->getConfig()->get( 'list-title' );
361 360
 		$admins = json_decode( $this->getController()->getPageContent( $listTitle ), true );
362 361
 		$newContent = $this->getController()->getPageContent( $cuListTitle );
363 362
 
364
-		$riconfNames = $removeNames = [];
363
+		$riconfNames = $removeNames = [ ];
365 364
 		foreach ( $pages as $page ) {
366 365
 			$user = $page->getUser();
367 366
 			if ( array_key_exists( 'checkuser', $admins[ $user ] ) ) {
@@ -369,10 +368,10 @@  discard block
 block discarded – undo
369 368
 				if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
370 369
 					// Remove the line
371 370
 					$newContent = preg_replace( $reg, '', $newContent );
372
-					$removeNames[] = $user;
371
+					$removeNames[ ] = $user;
373 372
 				} else {
374 373
 					$newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent );
375
-					$riconfNames[] = $user;
374
+					$riconfNames[ ] = $user;
376 375
 				}
377 376
 			}
378 377
 		}
@@ -389,7 +388,7 @@  discard block
 block discarded – undo
389 388
 			$lastUser = array_pop( $riconfNames );
390 389
 			$riconfList = implode( ', ', $riconfNames ) . " e $lastUser";
391 390
 		} elseif ( $riconfNames ) {
392
-			$riconfList = $riconfNames[0];
391
+			$riconfList = $riconfNames[ 0 ];
393 392
 		} else {
394 393
 			$riconfList = 'nessuno';
395 394
 		}
@@ -398,7 +397,7 @@  discard block
 block discarded – undo
398 397
 			$lastUser = array_pop( $removeNames );
399 398
 			$removeList = implode( ', ', $removeNames ) . " e $lastUser";
400 399
 		} elseif ( $removeNames ) {
401
-			$removeList = $removeNames[0];
400
+			$removeList = $removeNames[ 0 ];
402 401
 		} else {
403 402
 			$removeList = 'nessuno';
404 403
 		}
@@ -421,18 +420,18 @@  discard block
 block discarded – undo
421 420
 	/**
422 421
 	 * @param PageRiconferma[] $pages
423 422
 	 */
424
-	protected function updateBurList( array $pages ) {
423
+	protected function updateBurList ( array $pages ) {
425 424
 		$this->getLogger()->info( 'Checking if bur list needs updating.' );
426 425
 		$listTitle = $this->getConfig()->get( 'list-title' );
427 426
 		$admins = json_decode( $this->getController()->getPageContent( $listTitle ), true );
428 427
 
429
-		$remove = [];
428
+		$remove = [ ];
430 429
 		foreach ( $pages as $page ) {
431 430
 			$user = $page->getUser();
432 431
 			if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) &&
433 432
 				$page->getOutcome() & PageRiconferma::OUTCOME_FAIL
434 433
 			) {
435
-				$remove[] = $user;
434
+				$remove[ ] = $user;
436 435
 			}
437 436
 		}
438 437
 
@@ -451,7 +450,7 @@  discard block
 block discarded – undo
451 450
 			$lastUser = array_pop( $remove );
452 451
 			$removeList = implode( ', ', $remove ) . " e $lastUser";
453 452
 		} else {
454
-			$removeList = $remove[0];
453
+			$removeList = $remove[ 0 ];
455 454
 		}
456 455
 
457 456
 		$summary = $this->msg( 'bur-list-update-summary' )
@@ -471,7 +470,7 @@  discard block
 block discarded – undo
471 470
 	 *
472 471
 	 * @param PageRiconferma[] $pages
473 472
 	 */
474
-	protected function requestRemoval( array $pages ) {
473
+	protected function requestRemoval ( array $pages ) {
475 474
 		$this->getLogger()->info(
476 475
 			'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) )
477 476
 		);
@@ -516,15 +515,15 @@  discard block
 block discarded – undo
516 515
 	 *
517 516
 	 * @param PageRiconferma[] $pages
518 517
 	 */
519
-	protected function updateAnnunci( array $pages ) {
518
+	protected function updateAnnunci ( array $pages ) {
520 519
 		$this->getLogger()->info( 'Updating annunci' );
521 520
 		$title = $this->getConfig()->get( 'annunci-title' );
522 521
 
523
-		$names = [];
522
+		$names = [ ];
524 523
 		$text = '';
525 524
 		foreach ( $pages as $page ) {
526 525
 			$user = $page->getUser();
527
-			$names[] = $user;
526
+			$names[ ] = $user;
528 527
 			$text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " .
529 528
 				"non è stato riconfermato [[WP:A|amministratore]].}}\n";
530 529
 		}
@@ -546,7 +545,7 @@  discard block
 block discarded – undo
546 545
 			$lastUser = array_pop( $names );
547 546
 			$namesList = implode( ', ', $names ) . " e $lastUser";
548 547
 		} else {
549
-			$namesList = $names[0];
548
+			$namesList = $names[ 0 ];
550 549
 		}
551 550
 
552 551
 		$summary = $this->msg( 'annunci-summary' )
@@ -566,16 +565,16 @@  discard block
 block discarded – undo
566 565
 	 *
567 566
 	 * @param PageRiconferma[] $pages
568 567
 	 */
569
-	protected function updateUltimeNotizie( array $pages ) {
568
+	protected function updateUltimeNotizie ( array $pages ) {
570 569
 		$this->getLogger()->info( 'Updating ultime notizie' );
571 570
 		$title = $this->getConfig()->get( 'ultimenotizie-title' );
572 571
 
573
-		$names = [];
572
+		$names = [ ];
574 573
 		$text = '';
575 574
 		foreach ( $pages as $page ) {
576 575
 			$user = $page->getUser();
577 576
 			$title = $page->getTitle();
578
-			$names[] = $user;
577
+			$names[ ] = $user;
579 578
 			$text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " .
580 579
 				'[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.';
581 580
 		}
@@ -594,7 +593,7 @@  discard block
 block discarded – undo
594 593
 			$lastUser = array_pop( $names );
595 594
 			$namesList = implode( ', ', $names ) . " e $lastUser";
596 595
 		} else {
597
-			$namesList = $names[0];
596
+			$namesList = $names[ 0 ];
598 597
 		}
599 598
 
600 599
 		$summary = $this->msg( 'ultimenotizie-summary' )
Please login to merge, or discard this patch.
includes/Message.php 1 patch
Spacing   +6 added lines, -6 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,11 +39,11 @@  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
 		$this->value = preg_replace_callback(
44 44
 			'!\{\{$plur|(?P<amount>\d+)|(?P<sing>[^}|]+)|(?P<plur>[^|}]+)}}!',
45 45
 			function ( $matches ) {
46
-				return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
46
+				return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
47 47
 			},
48 48
 			$this->value
49 49
 		);
Please login to merge, or discard this patch.
includes/Task/UserNotice.php 1 patch
Spacing   +4 added lines, -4 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,13 +11,13 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @inheritDoc
13 13
 	 */
14
-	public function run() : TaskResult {
14
+	public function run () : TaskResult {
15 15
 		$this->getLogger()->info( 'Starting task UserNotice' );
16 16
 
17 17
 		$pages = $this->getDataProvider()->getCreatedPages();
18 18
 		$users = $this->getDataProvider()->getUsersToProcess();
19 19
 		if ( $pages && $users ) {
20
-			$ricNums = [];
20
+			$ricNums = [ ];
21 21
 			foreach ( $pages as $page ) {
22 22
 				$ricNums[ $page->getUser() ] = $page->getNum();
23 23
 			}
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param string $user
40 40
 	 * @param int $ricNum
41 41
 	 */
42
-	protected function addMsg( string $user, int $ricNum ) {
42
+	protected function addMsg ( string $user, int $ricNum ) {
43 43
 		$this->getLogger()->info( "Leaving msg to $user" );
44 44
 		$msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text();
45 45
 
Please login to merge, or discard this patch.
includes/Config.php 1 patch
Spacing   +13 added lines, -13 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
 
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 	/** @var self */
13 13
 	private static $instance;
14 14
 	/** @var array */
15
-	private $opts = [];
15
+	private $opts = [ ];
16 16
 
17 17
 	/**
18 18
 	 * Use self::init() and self::getInstance()
19 19
 	 */
20
-	private function __construct() {
20
+	private function __construct () {
21 21
 	}
22 22
 
23 23
 	/**
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
 	 * @param array $defaults
27 27
 	 * @throws ConfigException
28 28
 	 */
29
-	public static function init( array $defaults ) {
29
+	public static function init ( array $defaults ) {
30 30
 		if ( self::$instance ) {
31 31
 			throw new ConfigException( 'Config was already initialized' );
32 32
 		}
33 33
 
34 34
 		$inst = new self;
35
-		$inst->set( 'list-title', $defaults['list-title'] );
36
-		$inst->set( 'msg-title', $defaults['msg-title'] );
37
-		$inst->set( 'username', $defaults['username'] );
38
-		$inst->set( 'password', $defaults['password'] );
35
+		$inst->set( 'list-title', $defaults[ 'list-title' ] );
36
+		$inst->set( 'msg-title', $defaults[ 'msg-title' ] );
37
+		$inst->set( 'username', $defaults[ 'username' ] );
38
+		$inst->set( 'password', $defaults[ 'password' ] );
39 39
 		self::$instance = $inst;
40 40
 
41 41
 		// On-wiki values
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param string $key
55 55
 	 * @return string
56 56
 	 */
57
-	public function getWikiMessage( string $key ) : string {
57
+	public function getWikiMessage ( string $key ) : string {
58 58
 		static $messages = null;
59 59
 		if ( $messages === null ) {
60 60
 			try {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 				throw new ConfigException( 'Please create a messages page.' );
64 64
 			}
65 65
 		}
66
-		return $messages[$key];
66
+		return $messages[ $key ];
67 67
 	}
68 68
 	/**
69 69
 	 * Set a config value.
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @param string $key
72 72
 	 * @param mixed $value
73 73
 	 */
74
-	protected function set( string $key, $value ) {
74
+	protected function set ( string $key, $value ) {
75 75
 		$this->opts[ $key ] = $value;
76 76
 	}
77 77
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @return self
82 82
 	 * @throws ConfigException
83 83
 	 */
84
-	public static function getInstance() : self {
84
+	public static function getInstance () : self {
85 85
 		if ( !self::$instance ) {
86 86
 			throw new ConfigException( 'Config not yet initialized' );
87 87
 		}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @return mixed
96 96
 	 * @throws ConfigException
97 97
 	 */
98
-	public function get( string $opt ) {
98
+	public function get ( string $opt ) {
99 99
 		if ( !isset( $this->opts[ $opt ] ) ) {
100 100
 			throw new ConfigException( "Config option '$opt' not set." );
101 101
 		}
Please login to merge, or discard this patch.