Passed
Push — master ( e26f3b...6f3cd3 )
by Daimona
01:37
created
includes/WikiController.php 1 patch
Spacing   +18 added lines, -18 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
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @return string
31 31
 	 * @throws MissingPageException
32 32
 	 */
33
-	public function getPageContent( string $title ) : string {
33
+	public function getPageContent ( string $title ) : string {
34 34
 		$this->logger->debug( "Retrieving page $title" );
35 35
 		$params = [
36 36
 			'action' => 'query',
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 			throw new MissingPageException( $title );
48 48
 		}
49 49
 
50
-		return $page->revisions[0]->slots->main->{ '*' };
50
+		return $page->revisions[ 0 ]->slots->main->{ '*' };
51 51
 	}
52 52
 
53 53
 	/**
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param array $params
57 57
 	 * @throws EditException
58 58
 	 */
59
-	public function editPage( array $params ) {
59
+	public function editPage ( array $params ) {
60 60
 		$this->login();
61 61
 
62 62
 		$params = [
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return string
79 79
 	 * @fixme Not the right place for this
80 80
 	 */
81
-	public static function getTimeWithArticle( int $timestamp ) : string {
81
+	public static function getTimeWithArticle ( int $timestamp ) : string {
82 82
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
83 83
 		$timeString = strftime( '%e %B alle %R', $timestamp );
84 84
 		// Remove the left space if day has a single digit
@@ -97,16 +97,16 @@  discard block
 block discarded – undo
97 97
 	 * @fixme Not the right place for this
98 98
 	 * @todo Is there a better way?
99 99
 	 */
100
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
100
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
101 101
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
102 102
 		$bits = strptime( $timeString, '%e %m %Y alle %H:%M' );
103 103
 		$timestamp = mktime(
104
-			$bits['tm_hour'],
105
-			$bits['tm_min'],
104
+			$bits[ 'tm_hour' ],
105
+			$bits[ 'tm_min' ],
106 106
 			0,
107
-			$bits['tm_mon'] + 1,
108
-			$bits['tm_mday'],
109
-			$bits['tm_year'] + 1900
107
+			$bits[ 'tm_mon' ] + 1,
108
+			$bits[ 'tm_mday' ],
109
+			$bits[ 'tm_year' ] + 1900
110 110
 		);
111 111
 		setlocale( LC_TIME, $oldLoc );
112 112
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
117 117
 	 * @throws LoginException
118 118
 	 */
119
-	public function login() {
119
+	public function login () {
120 120
 		if ( self::$loggedIn ) {
121 121
 			$this->logger->debug( 'Already logged in' );
122 122
 			return;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 		self::$loggedIn = true;
145 145
 		// Clear tokens cache
146
-		$this->tokens = [];
146
+		$this->tokens = [ ];
147 147
 		$this->logger->info( 'Login succeeded' );
148 148
 	}
149 149
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @param string $type
154 154
 	 * @return string
155 155
 	 */
156
-	public function getToken( string $type ) : string {
156
+	public function getToken ( string $type ) : string {
157 157
 		if ( !isset( $this->tokens[ $type ] ) ) {
158 158
 			$params = [
159 159
 				'action' => 'query',
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 * @param string $title
177 177
 	 * @return int
178 178
 	 */
179
-	public function getPageCreationTS( string $title ) : int {
179
+	public function getPageCreationTS ( string $title ) : int {
180 180
 		$params = [
181 181
 			'action' => 'query',
182 182
 			'prop' => 'revisions',
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
 		$res = ( RequestBase::newFromParams( $params ) )->execute();
191 191
 		$data = $res->query->pages;
192
-		return strtotime( reset( $data )->revisions[0]->timestamp );
192
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
193 193
 	}
194 194
 
195 195
 	/**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @param string $title
199 199
 	 * @param string $reason
200 200
 	 */
201
-	public function protectPage( string $title, string $reason ) {
201
+	public function protectPage ( string $title, string $reason ) {
202 202
 		$this->logger->info( "Protecting page $title" );
203 203
 		$this->login();
204 204
 
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 = str_replace( '$num', "$ricNum", $this->getConfig()->get( 'user-notice-msg' ) );
45 45
 
Please login to merge, or discard this patch.
includes/Task/UpdatesAround.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;
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
 		);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		$summary = preg_replace_callback(
56 56
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
57 57
 			function ( $matches ) {
58
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
58
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
59 59
 			},
60 60
 			$summary
61 61
 		);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @param PageRiconferma[] $pages
76 76
 	 */
77
-	protected function addVote( array $pages ) {
77
+	protected function addVote ( array $pages ) {
78 78
 		$this->getLogger()->info(
79 79
 			'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) )
80 80
 		);
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 );
95 95
 		} else {
96 96
 			// Start section
97
-			$matches = [];
97
+			$matches = [ ];
98 98
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
99 99
 				throw new TaskException( 'Intro not found in vote page' );
100 100
 			}
101 101
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
102 102
 			// Replace semicolon with full stop
103 103
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
104
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 );
104
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 );
105 105
 		}
106 106
 
107 107
 		$summary = strtr(
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$summary = preg_replace_callback(
112 112
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
113 113
 			function ( $matches ) {
114
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
114
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
115 115
 			},
116 116
 			$summary
117 117
 		);
@@ -130,26 +130,26 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @param int $amount
132 132
 	 */
133
-	protected function addNews( int $amount ) {
133
+	protected function addNews ( int $amount ) {
134 134
 		$this->getLogger()->info( "Increasing the news counter by $amount" );
135 135
 		$newsPage = $this->getConfig()->get( 'ric-news-page' );
136 136
 
137 137
 		$content = $this->getController()->getPageContent( $newsPage );
138 138
 		$reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
139 139
 
140
-		$matches = [];
140
+		$matches = [ ];
141 141
 		if ( preg_match( $reg, $content, $matches ) === false ) {
142 142
 			throw new TaskException( 'Param not found in news page' );
143 143
 		}
144 144
 
145
-		$newNum = (int)$matches[2] + $amount;
145
+		$newNum = (int)$matches[ 2 ] + $amount;
146 146
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
147 147
 
148 148
 		$summary = strtr( $this->getConfig()->get( 'ric-news-page-summary' ), [ '$num' => $amount ] );
149 149
 		$summary = preg_replace_callback(
150 150
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
151 151
 			function ( $matches ) {
152
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
152
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
153 153
 			},
154 154
 			$summary
155 155
 		);
Please login to merge, or discard this patch.
includes/TaskDataProvider.php 1 patch
Spacing   +14 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;
4 4
 
@@ -12,20 +12,20 @@  discard block
 block discarded – undo
12 12
 	private $users;
13 13
 
14 14
 	/** @var PageRiconferma[] */
15
-	private $createdPages = [];
15
+	private $createdPages = [ ];
16 16
 
17 17
 	/**
18 18
 	 * Get a list of users to execute tasks on.
19 19
 	 *
20 20
 	 * @return array[]
21 21
 	 */
22
-	public function getUsersToProcess() : array {
22
+	public function getUsersToProcess () : array {
23 23
 		if ( $this->users === null ) {
24 24
 			$this->getLogger()->debug( 'Retrieving users list' );
25 25
 			$content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) );
26 26
 			$listUsers = json_decode( $content, true );
27 27
 
28
-			$this->users = [];
28
+			$this->users = [ ];
29 29
 			foreach ( $listUsers as $user => $groups ) {
30 30
 				$timestamp = $this->getValidTimestamp( $groups );
31 31
 
@@ -47,13 +47,11 @@  discard block
 block discarded – undo
47 47
 	 * @param array $groups
48 48
 	 * @return int
49 49
 	 */
50
-	private function getValidTimestamp( array $groups ) : int {
50
+	private function getValidTimestamp ( array $groups ) : int {
51 51
 		$checkuser = isset( $groups[ 'checkuser' ] ) ?
52
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() :
53
-			0;
52
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
54 53
 		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
55
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() :
56
-			0;
54
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
57 55
 
58 56
 		$timestamp = max( $bureaucrat, $checkuser );
59 57
 		if ( $timestamp === 0 ) {
@@ -67,7 +65,7 @@  discard block
 block discarded – undo
67 65
 	 *
68 66
 	 * @return PageRiconferma[]
69 67
 	 */
70
-	public function getOpenPages() : array {
68
+	public function getOpenPages () : array {
71 69
 		$baseTitle = $this->getConfig()->get( 'ric-main-page' );
72 70
 		$params = [
73 71
 			'action' => 'query',
@@ -79,10 +77,10 @@  discard block
 block discarded – undo
79 77
 
80 78
 		$res = RequestBase::newFromParams( $params )->execute();
81 79
 		$pages = $res->query->pages;
82
-		$ret = [];
80
+		$ret = [ ];
83 81
 		foreach ( reset( $pages )->templates as $page ) {
84 82
 			if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) {
85
-				$ret[] = new PageRiconferma( $page->title, $this->getController() );
83
+				$ret[ ] = new PageRiconferma( $page->title, $this->getController() );
86 84
 			}
87 85
 		}
88 86
 		return $ret;
@@ -93,21 +91,21 @@  discard block
 block discarded – undo
93 91
 	 *
94 92
 	 * @param string $name
95 93
 	 */
96
-	public function removeUser( string $name ) {
94
+	public function removeUser ( string $name ) {
97 95
 		unset( $this->users[ $name ] );
98 96
 	}
99 97
 
100 98
 	/**
101 99
 	 * @return PageRiconferma[]
102 100
 	 */
103
-	public function getCreatedPages() : array {
101
+	public function getCreatedPages () : array {
104 102
 		return $this->createdPages;
105 103
 	}
106 104
 
107 105
 	/**
108 106
 	 * @param PageRiconferma $page
109 107
 	 */
110
-	public function addCreatedPages( PageRiconferma $page ) {
111
-		$this->createdPages[] = $page;
108
+	public function addCreatedPages ( PageRiconferma $page ) {
109
+		$this->createdPages[ ] = $page;
112 110
 	}
113 111
 }
Please login to merge, or discard this patch.
includes/PageRiconferma.php 1 patch
Spacing   +24 added lines, -24 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
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param string $title
30 30
 	 * @param WikiController $controller
31 31
 	 */
32
-	public function __construct( string $title, WikiController $controller ) {
32
+	public function __construct ( string $title, WikiController $controller ) {
33 33
 		$this->title = $title;
34 34
 		$this->controller = $controller;
35 35
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @return string
39 39
 	 */
40
-	public function getTitle() : string {
40
+	public function getTitle () : string {
41 41
 		return $this->title;
42 42
 	}
43 43
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @return string
48 48
 	 */
49
-	public function getUser() : string {
50
-		return explode( '/', $this->title )[2];
49
+	public function getUser () : string {
50
+		return explode( '/', $this->title )[ 2 ];
51 51
 	}
52 52
 
53 53
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return int
57 57
 	 */
58
-	public function getNum() : int {
58
+	public function getNum () : int {
59 59
 		$bits = explode( '/', $this->getTitle() );
60 60
 		return intval( end( $bits ) );
61 61
 	}
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @return string
67 67
 	 */
68
-	public function getUserNum() : string {
69
-		return explode( '/', $this->getTitle(), 3 )[2];
68
+	public function getUserNum () : string {
69
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
70 70
 	}
71 71
 
72 72
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return string
76 76
 	 */
77
-	public function getBaseTitle() : string {
77
+	public function getBaseTitle () : string {
78 78
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug
79 79
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
80 80
 	}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @return string
86 86
 	 */
87
-	public function getContent() : string {
87
+	public function getContent () : string {
88 88
 		if ( $this->content === null ) {
89 89
 			$this->content = $this->controller->getPageContent( $this->title );
90 90
 		}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return int
98 98
 	 */
99
-	public function getOpposingCount() : int {
99
+	public function getOpposingCount () : int {
100 100
 		return $this->getCountForSection( self::SECTION_OPPOSE );
101 101
 	}
102 102
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return int
107 107
 	 */
108
-	public function getSupportCount() : int {
108
+	public function getSupportCount () : int {
109 109
 		return $this->getCountForSection( self::SECTION_SUPPORT );
110 110
 	}
111 111
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @param int $secNum
116 116
 	 * @return int
117 117
 	 */
118
-	protected function getCountForSection( int $secNum ) : int {
118
+	protected function getCountForSection ( int $secNum ) : int {
119 119
 		$params = [
120 120
 			'action' => 'query',
121 121
 			'prop' => 'revisions',
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
 		$res = RequestBase::newFromParams( $params )->execute();
129 129
 		$page = reset( $res->query->pages );
130
-		$content = $page->revisions[0]->slots->main->{ '*' };
130
+		$content = $page->revisions[ 0 ]->slots->main->{ '*' };
131 131
 		// Let's hope that this is good enough...
132 132
 		return substr_count( $content, "\n\# *(?![#*])" );
133 133
 	}
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	/**
136 136
 	 * Gets the quorum used for the current page
137 137
 	 */
138
-	protected function getQuorum() : int {
138
+	protected function getQuorum () : int {
139 139
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
140
-		$matches = [];
140
+		$matches = [ ];
141 141
 		preg_match( $reg, $this->getContent(), $matches );
142
-		return intval( $matches[1] );
142
+		return intval( $matches[ 1 ] );
143 143
 	}
144 144
 
145 145
 	/**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return bool
149 149
 	 */
150
-	public function hasOpposition() : bool {
150
+	public function hasOpposition () : bool {
151 151
 		return $this->getOpposingCount() >= 15;
152 152
 	}
153 153
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @return int One of the OUTCOME_* constants
158 158
 	 * @throws \BadMethodCallException
159 159
 	 */
160
-	public function getOutcome() : int {
160
+	public function getOutcome () : int {
161 161
 		if ( !$this->isVote() ) {
162 162
 			throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' );
163 163
 		}
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 * @return string
177 177
 	 * @throws \BadMethodCallException
178 178
 	 */
179
-	public function getOutcomeText() : string {
179
+	public function getOutcomeText () : string {
180 180
 		if ( !$this->isVote() ) {
181 181
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
182 182
 		}
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 *
209 209
 	 * @return bool
210 210
 	 */
211
-	public function isVote() : bool {
211
+	public function isVote () : bool {
212 212
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
213 213
 		return preg_match( $sectionReg, $this->getContent() ) === false;
214 214
 	}
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 	 *
219 219
 	 * @return int
220 220
 	 */
221
-	public function getEndTimestamp() : int {
221
+	public function getEndTimestamp () : int {
222 222
 		if ( $this->isVote() ) {
223
-			$matches = [];
223
+			$matches = [ ];
224 224
 			$reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!";
225 225
 			preg_match( $reg, $this->getContent(), $matches );
226 226
 			list( , $day, $hours ) = $matches;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		}
233 233
 	}
234 234
 
235
-	public function __toString() {
235
+	public function __toString () {
236 236
 		return $this->getTitle();
237 237
 	}
238 238
 }
Please login to merge, or discard this patch.
includes/Task/StartVote.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
 
@@ -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( '|', $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 = strtr(
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		$summary = preg_replace_callback(
140 140
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
141 141
 			function ( $matches ) {
142
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
142
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
143 143
 			},
144 144
 			$summary
145 145
 		);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @see UpdatesAround::addNews()
161 161
 	 * @see ClosePages::updateNews()
162 162
 	 */
163
-	protected function updateNews( int $amount ) {
163
+	protected function updateNews ( int $amount ) {
164 164
 		$this->getLogger()->info( "Turning $amount pages into votes" );
165 165
 		$newsPage = $this->getConfig()->get( 'ric-news-page' );
166 166
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		$regTac = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
169 169
 		$regVot = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!';
170 170
 
171
-		$tacMatches = $votMatches = [];
171
+		$tacMatches = $votMatches = [ ];
172 172
 		if ( preg_match( $regTac, $content, $tacMatches ) === false ) {
173 173
 			throw new TaskException( 'Param "tacite" not found in news page' );
174 174
 		}
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 			throw new TaskException( 'Param "voto" not found in news page' );
177 177
 		}
178 178
 
179
-		$newTac = (int)$tacMatches[2] - $amount ?: '';
180
-		$newVot = (int)$votMatches[2] + $amount ?: '';
179
+		$newTac = (int)$tacMatches[ 2 ] - $amount ?: '';
180
+		$newVot = (int)$votMatches[ 2 ] + $amount ?: '';
181 181
 
182 182
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
183 183
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		$summary = preg_replace_callback(
190 190
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
191 191
 			function ( $matches ) {
192
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
192
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
193 193
 			},
194 194
 			$summary
195 195
 		);
Please login to merge, or discard this patch.
includes/Task/ClosePages.php 1 patch
Spacing   +33 added lines, -34 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();
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return PageRiconferma[]
44 44
 	 */
45
-	protected function getPagesList() : array {
45
+	protected function getPagesList () : array {
46 46
 		$allPages = $this->getDataProvider()->getOpenPages();
47
-		$ret = [];
47
+		$ret = [ ];
48 48
 		foreach ( $allPages as $page ) {
49 49
 			if ( time() > $page->getEndTimestamp() ) {
50
-				$ret[] = $page;
50
+				$ret[ ] = $page;
51 51
 			}
52 52
 		}
53 53
 		return $ret;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	/**
57 57
 	 * @param PageRiconferma $page
58 58
 	 */
59
-	protected function addVoteCloseText( PageRiconferma $page ) {
59
+	protected function addVoteCloseText ( PageRiconferma $page ) {
60 60
 		$content = $page->getContent();
61 61
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!';
62 62
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
 	 * @param PageRiconferma[] $pages
76 76
 	 * @see UpdatesAround::addToMainPage()
77 77
 	 */
78
-	protected function removeFromMainPage( array $pages ) {
78
+	protected function removeFromMainPage ( array $pages ) {
79 79
 		$this->getLogger()->info(
80 80
 			'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) )
81 81
 		);
82 82
 
83 83
 		$mainPage = $this->getConfig()->get( 'ric-main-page' );
84 84
 		$content = $this->getController()->getPageContent( $mainPage );
85
-		$translations = [];
85
+		$translations = [ ];
86 86
 		foreach ( $pages as $page ) {
87 87
 			$translations[ '{{' . $page->getTitle() . '}}' ] = '';
88 88
 		}
@@ -100,17 +100,17 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @param PageRiconferma[] $pages
102 102
 	 */
103
-	protected function addToArchive( array $pages ) {
103
+	protected function addToArchive ( array $pages ) {
104 104
 		$this->getLogger()->info(
105 105
 			'Adding to archive: ' . implode( ', ', array_map( 'strval', $pages ) )
106 106
 		);
107 107
 
108
-		$simple = $votes = [];
108
+		$simple = $votes = [ ];
109 109
 		foreach ( $pages as $page ) {
110 110
 			if ( $page->isVote() ) {
111
-				$votes[] = $page;
111
+				$votes[ ] = $page;
112 112
 			} else {
113
-				$simple[] = $page;
113
+				$simple[ ] = $page;
114 114
 			}
115 115
 		}
116 116
 
@@ -127,21 +127,21 @@  discard block
 block discarded – undo
127 127
 	 * @param string $archiveTitle
128 128
 	 * @param array $pages
129 129
 	 */
130
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) {
130
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) {
131 131
 		$curTitle = "$archiveTitle/" . date( 'Y' );
132 132
 
133 133
 		$append = '';
134
-		$archivedList = [];
134
+		$archivedList = [ ];
135 135
 		foreach ( $pages as $page ) {
136 136
 			$append .= '{{' . $page->getTitle() . "}}\n";
137
-			$archivedList[] = $page->getUserNum();
137
+			$archivedList[ ] = $page->getUserNum();
138 138
 		}
139 139
 
140 140
 		if ( count( $archivedList ) > 1 ) {
141 141
 			$last = array_pop( $archivedList );
142 142
 			$userNums = implode( ', ', $archivedList ) . " e $last";
143 143
 		} else {
144
-			$userNums = $archivedList[0];
144
+			$userNums = $archivedList[ 0 ];
145 145
 		}
146 146
 
147 147
 		$summary = strtr(
@@ -162,14 +162,13 @@  discard block
 block discarded – undo
162 162
 	 * @param PageRiconferma $page
163 163
 	 * @see CreatePages::updateBasePage()
164 164
 	 */
165
-	protected function updateBasePage( PageRiconferma $page ) {
165
+	protected function updateBasePage ( PageRiconferma $page ) {
166 166
 		$this->getLogger()->info( "Updating base page for $page" );
167 167
 
168 168
 		$current = $this->getController()->getPageContent( $page->getBaseTitle() );
169 169
 
170 170
 		$text = $page->isVote() ?
171
-			'votazione: ' . ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ? 'non riconfermato' : 'riconfermato' ) :
172
-			'riconferma tacita';
171
+			'votazione: ' . ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ? 'non riconfermato' : 'riconfermato' ) : 'riconferma tacita';
173 172
 
174 173
 		$newContent = str_replace( 'riconferma in corso', $text, $current );
175 174
 		$params = [
@@ -185,13 +184,13 @@  discard block
 block discarded – undo
185 184
 	 * @param PageRiconferma[] $pages
186 185
 	 * @see UpdatesAround::addVote()
187 186
 	 */
188
-	protected function updateVote( array $pages ) {
187
+	protected function updateVote ( array $pages ) {
189 188
 		$votePage = $this->getConfig()->get( 'ric-vote-page' );
190 189
 		$content = $this->getController()->getPageContent( $votePage );
191 190
 
192
-		$titles = [];
191
+		$titles = [ ];
193 192
 		foreach ( $pages as $page ) {
194
-			$titles[] = preg_quote( $page->getTitle() );
193
+			$titles[ ] = preg_quote( $page->getTitle() );
195 194
 		}
196 195
 
197 196
 		$titleReg = implode( '|', $titles );
@@ -214,7 +213,7 @@  discard block
 block discarded – undo
214 213
 		$summary = preg_replace_callback(
215 214
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
216 215
 			function ( $matches ) {
217
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
216
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
218 217
 			},
219 218
 			$summary
220 219
 		);
@@ -232,7 +231,7 @@  discard block
 block discarded – undo
232 231
 	 * @param array $pages
233 232
 	 * @see UpdatesAround::addNews()
234 233
 	 */
235
-	protected function updateNews( array $pages ) {
234
+	protected function updateNews ( array $pages ) {
236 235
 		$simpleAmount = $voteAmount = 0;
237 236
 		foreach ( $pages as $page ) {
238 237
 			if ( $page->isVote() ) {
@@ -249,12 +248,12 @@  discard block
 block discarded – undo
249 248
 		$simpleReg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
250 249
 		$voteReg = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!';
251 250
 
252
-		$simpleMatches = $voteMatched = [];
251
+		$simpleMatches = $voteMatched = [ ];
253 252
 		preg_match( $simpleReg, $content, $simpleMatches );
254 253
 		preg_match( $voteReg, $content, $voteMatches );
255 254
 
256
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
257
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
255
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
256
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
258 257
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content );
259 258
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
260 259
 
@@ -265,7 +264,7 @@  discard block
 block discarded – undo
265 264
 		$summary = preg_replace_callback(
266 265
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
267 266
 			function ( $matches ) {
268
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
267
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
269 268
 			},
270 269
 			$summary
271 270
 		);
@@ -284,22 +283,22 @@  discard block
 block discarded – undo
284 283
 	 *
285 284
 	 * @param PageRiconferma[] $pages
286 285
 	 */
287
-	protected function updateAdminList( array $pages ) {
286
+	protected function updateAdminList ( array $pages ) {
288 287
 		$listTitle = $this->getConfig()->get( 'admins-list' );
289 288
 		$newContent = $this->getController()->getPageContent( $listTitle );
290 289
 		$newDate = date( 'Ymd', strtotime( '+1 year' ) );
291 290
 
292
-		$riconfNames = $removeNames = [];
291
+		$riconfNames = $removeNames = [ ];
293 292
 		foreach ( $pages as $page ) {
294 293
 			$user = $page->getUser();
295 294
 			$reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!";
296 295
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
297 296
 				// Remove the line
298 297
 				$newContent = preg_replace( $reg, '', $newContent );
299
-				$removeNames[] = $user;
298
+				$removeNames[ ] = $user;
300 299
 			} else {
301 300
 				$newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent );
302
-				$riconfNames[] = $user;
301
+				$riconfNames[ ] = $user;
303 302
 			}
304 303
 		}
305 304
 
@@ -308,7 +307,7 @@  discard block
 block discarded – undo
308 307
 			$lastUser = array_pop( $riconfNames );
309 308
 			$riconfList = implode( ', ', $riconfNames ) . " e $lastUser";
310 309
 		} elseif ( $riconfNames ) {
311
-			$riconfList = $riconfNames[0];
310
+			$riconfList = $riconfNames[ 0 ];
312 311
 		} else {
313 312
 			$riconfList = 'nessuno';
314 313
 		}
@@ -317,7 +316,7 @@  discard block
 block discarded – undo
317 316
 			$lastUser = array_pop( $removeNames );
318 317
 			$removeList = implode( ', ', $removeNames ) . " e $lastUser";
319 318
 		} elseif ( $removeNames ) {
320
-			$removeList = $removeNames[0];
319
+			$removeList = $removeNames[ 0 ];
321 320
 		} else {
322 321
 			$removeList = 'nessuno';
323 322
 		}
Please login to merge, or discard this patch.