Passed
Branch master (a4e902)
by Daimona
01:39
created
includes/Page/PageBotList.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\Page;
4 4
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @private Use self::get()
13 13
 	 */
14
-	public function __construct() {
14
+	public function __construct () {
15 15
 		parent::__construct( Config::getInstance()->get( 'list-title' ) );
16 16
 	}
17 17
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return self
22 22
 	 */
23
-	public static function get() : self {
23
+	public static function get () : self {
24 24
 		static $instance = null;
25 25
 		if ( $instance === null ) {
26 26
 			$instance = new self;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @return array[]
35 35
 	 */
36
-	public function getAdminsList() : array {
36
+	public function getAdminsList () : array {
37 37
 		return json_decode( $this->getContent(), true );
38 38
 	}
39 39
 }
Please login to merge, or discard this patch.
includes/Page/Page.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\Page;
4 4
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param string $title
21 21
 	 * @param string $domain The site where the page lives, if different from default
22 22
 	 */
23
-	public function __construct( string $title, string $domain = DEFAULT_URL ) {
23
+	public function __construct ( string $title, string $domain = DEFAULT_URL ) {
24 24
 		$this->title = $title;
25 25
 		$this->controller = new WikiController( $domain );
26 26
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @return string
30 30
 	 */
31
-	public function getTitle() : string {
31
+	public function getTitle () : string {
32 32
 		return $this->title;
33 33
 	}
34 34
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param int|null $section A section number to retrieve the content of that section
39 39
 	 * @return string
40 40
 	 */
41
-	public function getContent( int $section = null ) : string {
41
+	public function getContent ( int $section = null ) : string {
42 42
 		if ( $this->content === null ) {
43 43
 			$this->content = $this->controller->getPageContent( $this->title, $section );
44 44
 		}
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param array $params
52 52
 	 */
53
-	public function edit( array $params ) {
53
+	public function edit ( array $params ) {
54 54
 		$params = [
55 55
 			'title' => $this->getTitle()
56 56
 		] + $params;
57 57
 
58 58
 		$this->controller->editPage( $params );
59
-		if ( isset( $params['text'] ) ) {
60
-			$this->content = $params['text'];
61
-		} elseif ( isset( $params['appendtext'] ) ) {
62
-			$this->content .= $params['appendtext'];
59
+		if ( isset( $params[ 'text' ] ) ) {
60
+			$this->content = $params[ 'text' ];
61
+		} elseif ( isset( $params[ 'appendtext' ] ) ) {
62
+			$this->content .= $params[ 'appendtext' ];
63 63
 		} else {
64 64
 			// Clear the cache anyway
65 65
 			( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) );
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param string $regex
74 74
 	 * @return bool
75 75
 	 */
76
-	public function matches( string $regex ) : bool {
76
+	public function matches ( string $regex ) : bool {
77 77
 		return preg_match( $regex, $this->getContent() ) !== false;
78 78
 	}
79 79
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 * @return string[]
86 86
 	 * @throws \Exception
87 87
 	 */
88
-	public function getMatch( string $regex ) : array {
89
-		$ret = [];
88
+	public function getMatch ( string $regex ) : array {
89
+		$ret = [ ];
90 90
 		if ( preg_match( $regex, $this->getContent(), $ret ) === false ) {
91 91
 			throw new \Exception;
92 92
 		}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return string
100 100
 	 */
101
-	public function __toString() {
101
+	public function __toString () {
102 102
 		return $this->getTitle();
103 103
 	}
104 104
 }
Please login to merge, or discard this patch.
includes/Page/PageRiconferma.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\Page;
4 4
 
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @return string
25 25
 	 */
26
-	public function getUser() : string {
27
-		return explode( '/', $this->title )[2];
26
+	public function getUser () : string {
27
+		return explode( '/', $this->title )[ 2 ];
28 28
 	}
29 29
 
30 30
 	/**
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @return int
34 34
 	 */
35
-	public function getNum() : int {
35
+	public function getNum () : int {
36 36
 		$bits = explode( '/', $this->getTitle() );
37 37
 		return intval( end( $bits ) );
38 38
 	}
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return string
44 44
 	 */
45
-	public function getUserNum() : string {
46
-		return explode( '/', $this->getTitle(), 3 )[2];
45
+	public function getUserNum () : string {
46
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
47 47
 	}
48 48
 
49 49
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @return string
53 53
 	 */
54
-	public function getBaseTitle() : string {
54
+	public function getBaseTitle () : string {
55 55
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug
56 56
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
57 57
 	}
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @return int
63 63
 	 */
64
-	public function getOpposingCount() : int {
64
+	public function getOpposingCount () : int {
65 65
 		return $this->getCountForSection( self::SECTION_OPPOSE );
66 66
 	}
67 67
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return int
72 72
 	 */
73
-	public function getSupportCount() : int {
73
+	public function getSupportCount () : int {
74 74
 		return $this->getCountForSection( self::SECTION_SUPPORT );
75 75
 	}
76 76
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @param int $secNum
81 81
 	 * @return int
82 82
 	 */
83
-	protected function getCountForSection( int $secNum ) : int {
83
+	protected function getCountForSection ( int $secNum ) : int {
84 84
 		$content = $this->controller->getPageContent( $this->title, $secNum );
85 85
 		// Let's hope that this is good enough...
86 86
 		return substr_count( $content, "\n\# *(?![#*])" );
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @return int
93 93
 	 */
94
-	protected function getQuorum() : int {
94
+	protected function getQuorum () : int {
95 95
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
96
-		return intval( $this->getMatch( $reg )[1] );
96
+		return intval( $this->getMatch( $reg )[ 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
 		}
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @throws \BadMethodCallException
132 132
 	 * @throws \LogicException
133 133
 	 */
134
-	public function getOutcomeText() : string {
134
+	public function getOutcomeText () : string {
135 135
 		if ( !$this->isVote() ) {
136 136
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
137 137
 		}
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @return bool
167 167
 	 */
168
-	public function isVote() : bool {
168
+	public function isVote () : bool {
169 169
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
170 170
 		return $this->matches( $sectionReg );
171 171
 	}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @return int
177 177
 	 */
178
-	public function getEndTimestamp() : int {
178
+	public function getEndTimestamp () : int {
179 179
 		if ( $this->isVote() ) {
180 180
 			$reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!";
181 181
 			list( , $day, $hours ) = $this->getMatch( $reg );
Please login to merge, or discard this patch.
includes/WikiController.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;
4 4
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	/**
25 25
 	 * @param string $domain The URL of the wiki, if different from default
26 26
 	 */
27
-	public function __construct( string $domain = DEFAULT_URL ) {
27
+	public function __construct ( string $domain = DEFAULT_URL ) {
28 28
 		$this->logger = new Logger;
29 29
 		$this->domain = $domain;
30 30
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @return string
38 38
 	 * @throws MissingPageException
39 39
 	 */
40
-	public function getPageContent( string $title, int $section = null ) : string {
40
+	public function getPageContent ( string $title, int $section = null ) : string {
41 41
 		$this->logger->debug( "Retrieving page $title" );
42 42
 		$params = [
43 43
 			'action' => 'query',
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		];
49 49
 
50 50
 		if ( $section !== null ) {
51
-			$params['rvsection'] = $section;
51
+			$params[ 'rvsection' ] = $section;
52 52
 		}
53 53
 
54 54
 		$req = RequestBase::newFromParams( $params )->setUrl( $this->domain );
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 			throw new MissingPageException( $title );
59 59
 		}
60 60
 
61
-		return $page->revisions[0]->slots->main->{ '*' };
61
+		return $page->revisions[ 0 ]->slots->main->{ '*' };
62 62
 	}
63 63
 
64 64
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param array $params
68 68
 	 * @throws EditException
69 69
 	 */
70
-	public function editPage( array $params ) {
70
+	public function editPage ( array $params ) {
71 71
 		$this->login();
72 72
 
73 73
 		$params = [
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
90 90
 	 * @throws LoginException
91 91
 	 */
92
-	public function login() {
92
+	public function login () {
93 93
 		if ( self::$loggedIn ) {
94 94
 			$this->logger->debug( 'Already logged in' );
95 95
 			return;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
 		self::$loggedIn = true;
118 118
 		// Clear tokens cache
119
-		$this->tokens = [];
119
+		$this->tokens = [ ];
120 120
 		$this->logger->info( 'Login succeeded' );
121 121
 	}
122 122
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @param string $type
127 127
 	 * @return string
128 128
 	 */
129
-	public function getToken( string $type ) : string {
129
+	public function getToken ( string $type ) : string {
130 130
 		if ( !isset( $this->tokens[ $type ] ) ) {
131 131
 			$params = [
132 132
 				'action' => 'query',
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @param string $title
150 150
 	 * @return int
151 151
 	 */
152
-	public function getPageCreationTS( string $title ) : int {
152
+	public function getPageCreationTS ( string $title ) : int {
153 153
 		$params = [
154 154
 			'action' => 'query',
155 155
 			'prop' => 'revisions',
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
 		$res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute();
164 164
 		$data = $res->query->pages;
165
-		return strtotime( reset( $data )->revisions[0]->timestamp );
165
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
166 166
 	}
167 167
 
168 168
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * @param string $title
172 172
 	 * @param string $reason
173 173
 	 */
174
-	public function protectPage( string $title, string $reason ) {
174
+	public function protectPage ( string $title, string $reason ) {
175 175
 		$this->logger->info( "Protecting page $title" );
176 176
 		$this->login();
177 177
 
Please login to merge, or discard this patch.
includes/Message.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;
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
 		);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @param int $timestamp
56 56
 	 * @return string
57 57
 	 */
58
-	public static function getTimeWithArticle( int $timestamp ) : string {
58
+	public static function getTimeWithArticle ( int $timestamp ) : string {
59 59
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
60 60
 		$timeString = strftime( '%e %B alle %R', $timestamp );
61 61
 		// Remove the left space if day has a single digit
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 	 * @return int
74 74
 	 * @todo Is there a better way?
75 75
 	 */
76
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
76
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
77 77
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
78 78
 		$bits = strptime( $timeString, '%e %m %Y alle %H:%M' );
79 79
 		$timestamp = mktime(
80
-			$bits['tm_hour'],
81
-			$bits['tm_min'],
80
+			$bits[ 'tm_hour' ],
81
+			$bits[ 'tm_min' ],
82 82
 			0,
83
-			$bits['tm_mon'] + 1,
84
-			$bits['tm_mday'],
85
-			$bits['tm_year'] + 1900
83
+			$bits[ 'tm_mon' ] + 1,
84
+			$bits[ 'tm_mday' ],
85
+			$bits[ 'tm_year' ] + 1900
86 86
 		);
87 87
 		setlocale( LC_TIME, $oldLoc );
88 88
 
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 * @param string $emptyText
98 98
 	 * @return string
99 99
 	 */
100
-	public static function commaList( array $data, string $emptyText = 'nessuno' ) : string {
100
+	public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string {
101 101
 		if ( count( $data ) > 1 ) {
102 102
 			$last = array_pop( $data );
103 103
 			$ret = implode( ', ', $data ) . " e $last";
104 104
 		} elseif ( $data ) {
105
-			$ret = $data[0];
105
+			$ret = $data[ 0 ];
106 106
 		} else {
107 107
 			$ret = $emptyText;
108 108
 		}
Please login to merge, or discard this patch.
includes/Task/Subtask/FailedUpdates.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task\Subtask;
4 4
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * @inheritDoc
15 15
 	 */
16
-	public function runInternal() : int {
16
+	public function runInternal () : int {
17 17
 		$failed = $this->getFailures();
18 18
 		if ( $failed ) {
19 19
 			$this->updateBurList( $failed );
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return PageRiconferma[]
32 32
 	 */
33
-	private function getFailures() : array {
34
-		$ret = [];
33
+	private function getFailures () : array {
34
+		$ret = [ ];
35 35
 		$allPages = $this->getDataProvider()->getPagesToClose();
36 36
 		foreach ( $allPages as $page ) {
37 37
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
38
-				$ret[] = $page;
38
+				$ret[ ] = $page;
39 39
 			}
40 40
 		}
41 41
 		return $ret;
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * @param PageRiconferma[] $pages
46 46
 	 */
47
-	protected function updateBurList( array $pages ) {
47
+	protected function updateBurList ( array $pages ) {
48 48
 		$this->getLogger()->info( 'Checking if bur list needs updating.' );
49 49
 		$admins = $this->getDataProvider()->getUsersList();
50 50
 
51
-		$remove = [];
51
+		$remove = [ ];
52 52
 		foreach ( $pages as $page ) {
53 53
 			$user = $page->getUser();
54 54
 			if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) &&
55 55
 				$page->getOutcome() & PageRiconferma::OUTCOME_FAIL
56 56
 			) {
57
-				$remove[] = $user;
57
+				$remove[ ] = $user;
58 58
 			}
59 59
 		}
60 60
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @param PageRiconferma[] $pages
86 86
 	 */
87
-	protected function requestRemoval( array $pages ) {
87
+	protected function requestRemoval ( array $pages ) {
88 88
 		$this->getLogger()->info(
89 89
 			'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) )
90 90
 		);
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @param PageRiconferma[] $pages
128 128
 	 */
129
-	protected function updateAnnunci( array $pages ) {
129
+	protected function updateAnnunci ( array $pages ) {
130 130
 		$this->getLogger()->info( 'Updating annunci' );
131 131
 
132
-		$names = [];
132
+		$names = [ ];
133 133
 		$text = '';
134 134
 		foreach ( $pages as $page ) {
135 135
 			$user = $page->getUser();
136
-			$names[] = $user;
136
+			$names[ ] = $user;
137 137
 			$text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " .
138 138
 				"non è stato riconfermato [[WP:A|amministratore]].}}\n";
139 139
 		}
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @param PageRiconferma[] $pages
169 169
 	 */
170
-	protected function updateUltimeNotizie( array $pages ) {
170
+	protected function updateUltimeNotizie ( array $pages ) {
171 171
 		$this->getLogger()->info( 'Updating ultime notizie' );
172 172
 		$notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-title' ) );
173 173
 
174
-		$names = [];
174
+		$names = [ ];
175 175
 		$text = '';
176 176
 		foreach ( $pages as $page ) {
177 177
 			$user = $page->getUser();
178 178
 			$title = $page->getTitle();
179
-			$names[] = $user;
179
+			$names[ ] = $user;
180 180
 			$text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " .
181 181
 				'[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.';
182 182
 		}
Please login to merge, or discard this patch.
includes/Task/Subtask/CreatePages.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task\Subtask;
4 4
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * @inheritDoc
15 15
 	 */
16
-	public function runInternal() : int {
16
+	public function runInternal () : int {
17 17
 		$users = $this->getDataProvider()->getUsersToProcess();
18 18
 
19 19
 		if ( !$users ) {
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 			$this->processUser( $user, $groups );
25 25
 		}
26 26
 
27
-		return self::STATUS_GOOD ;
27
+		return self::STATUS_GOOD;
28 28
 	}
29 29
 
30 30
 	/**
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @param string $user
34 34
 	 * @param array $groups
35 35
 	 */
36
-	protected function processUser( string $user, array $groups ) {
36
+	protected function processUser ( string $user, array $groups ) {
37 37
 		try {
38 38
 			$num = $this->getLastPageNum( $user ) + 1;
39 39
 		} catch ( TaskException $e ) {
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 	 * @return int
66 66
 	 * @throws TaskException
67 67
 	 */
68
-	protected function getLastPageNum( string $user ) : int {
68
+	protected function getLastPageNum ( string $user ) : int {
69 69
 		$this->getLogger()->debug( "Retrieving previous pages for $user" );
70
-		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1];
70
+		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ];
71 71
 		$params = [
72 72
 			'action' => 'query',
73 73
 			'list' => 'allpages',
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 	 * @param string $user
103 103
 	 * @param array $groups
104 104
 	 */
105
-	protected function createPage( string $title, string $user, array $groups ) {
105
+	protected function createPage ( string $title, string $user, array $groups ) {
106 106
 		$this->getLogger()->info( "Creating page $title" );
107 107
 		$text = $this->getConfig()->get( 'ric-page-text' );
108 108
 		$textParams = [
109 109
 			'$user' => $user,
110
-			'$date' => $groups['sysop'],
111
-			'$burocrate' => $groups['bureaucrat'] ?? '',
112
-			'$checkuser' => $groups['checkuser'] ?? ''
110
+			'$date' => $groups[ 'sysop' ],
111
+			'$burocrate' => $groups[ 'bureaucrat' ] ?? '',
112
+			'$checkuser' => $groups[ 'checkuser' ] ?? ''
113 113
 		];
114 114
 		$text = strtr( $text, $textParams );
115 115
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $title
129 129
 	 * @param string $newText
130 130
 	 */
131
-	protected function createBasePage( string $title, string $newText ) {
131
+	protected function createBasePage ( string $title, string $newText ) {
132 132
 		$this->getLogger()->info( "Creating base page $title" );
133 133
 
134 134
 		$params = [
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param string $title
146 146
 	 * @param string $newText
147 147
 	 */
148
-	protected function updateBasePage( string $title, string $newText ) {
148
+	protected function updateBasePage ( string $title, string $newText ) {
149 149
 		$this->getLogger()->info( "Updating base page $title" );
150 150
 
151 151
 		$params = [
Please login to merge, or discard this patch.
includes/Task/Subtask/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\Subtask;
4 4
 
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	/**
10 10
 	 * @inheritDoc
11 11
 	 */
12
-	public function runInternal() : int {
12
+	public function runInternal () : int {
13 13
 		$pages = $this->getDataProvider()->getCreatedPages();
14 14
 		$users = $this->getDataProvider()->getUsersToProcess();
15 15
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 			return self::STATUS_NOTHING;
18 18
 		}
19 19
 
20
-		$ricNums = [];
20
+		$ricNums = [ ];
21 21
 		foreach ( $pages as $page ) {
22 22
 			$ricNums[ $page->getUser() ] = $page->getNum();
23 23
 		}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param string $user
36 36
 	 * @param int $ricNum
37 37
 	 */
38
-	protected function addMsg( string $user, int $ricNum ) {
38
+	protected function addMsg ( string $user, int $ricNum ) {
39 39
 		$this->getLogger()->info( "Leaving msg to $user" );
40 40
 		$msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text();
41 41
 
Please login to merge, or discard this patch.
includes/Task/Subtask/SimpleUpdates.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task\Subtask;
4 4
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * @inheritDoc
15 15
 	 */
16
-	public function runInternal() : int {
16
+	public function runInternal () : int {
17 17
 		$pages = $this->getDataProvider()->getPagesToClose();
18 18
 		$this->updateVote( $pages );
19 19
 		$this->updateNews( $pages );
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	 * @param PageRiconferma[] $pages
28 28
 	 * @see UpdatesAround::addVote()
29 29
 	 */
30
-	protected function updateVote( array $pages ) {
30
+	protected function updateVote ( array $pages ) {
31 31
 		$this->getLogger()->info(
32 32
 			'Updating votazioni: ' . implode( ', ', array_map( 'strval', $pages ) )
33 33
 		);
34 34
 		$votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) );
35 35
 
36
-		$titles = [];
36
+		$titles = [ ];
37 37
 		foreach ( $pages as $page ) {
38
-			$titles[] = preg_quote( $page->getTitle() );
38
+			$titles[ ] = preg_quote( $page->getTitle() );
39 39
 		}
40 40
 
41 41
 		$titleReg = implode( '|', $titles );
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @param array $pages
65 65
 	 * @see UpdatesAround::addNews()
66 66
 	 */
67
-	protected function updateNews( array $pages ) {
67
+	protected function updateNews ( array $pages ) {
68 68
 		$simpleAmount = $voteAmount = 0;
69 69
 		foreach ( $pages as $page ) {
70 70
 			if ( $page->isVote() ) {
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 		$simpleMatches = $newsPage->getMatch( $simpleReg );
88 88
 		$voteMatches = $newsPage->getMatch( $voteReg );
89 89
 
90
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
91
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
90
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
91
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
92 92
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content );
93 93
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
94 94
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param PageRiconferma[] $pages
108 108
 	 */
109
-	protected function updateAdminList( array $pages ) {
109
+	protected function updateAdminList ( array $pages ) {
110 110
 		$this->getLogger()->info(
111 111
 			'Updating admin list: ' . implode( ', ', array_map( 'strval', $pages ) )
112 112
 		);
@@ -114,17 +114,17 @@  discard block
 block discarded – undo
114 114
 		$newContent = $adminsPage->getContent();
115 115
 		$newDate = date( 'Ymd', strtotime( '+1 year' ) );
116 116
 
117
-		$riconfNames = $removeNames = [];
117
+		$riconfNames = $removeNames = [ ];
118 118
 		foreach ( $pages as $page ) {
119 119
 			$user = $page->getUser();
120 120
 			$reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!";
121 121
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
122 122
 				// Remove the line
123 123
 				$newContent = preg_replace( $reg, '', $newContent );
124
-				$removeNames[] = $user;
124
+				$removeNames[ ] = $user;
125 125
 			} else {
126 126
 				$newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent );
127
-				$riconfNames[] = $user;
127
+				$riconfNames[ ] = $user;
128 128
 			}
129 129
 		}
130 130
 
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 	/**
145 145
 	 * @param PageRiconferma[] $pages
146 146
 	 */
147
-	protected function updateCUList( array $pages ) {
147
+	protected function updateCUList ( array $pages ) {
148 148
 		$this->getLogger()->info( 'Checking if CU list needs updating.' );
149 149
 		$cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) );
150 150
 		$admins = $this->getDataProvider()->getUsersList();
151 151
 		$newContent = $cuList->getContent();
152 152
 
153
-		$riconfNames = $removeNames = [];
153
+		$riconfNames = $removeNames = [ ];
154 154
 		foreach ( $pages as $page ) {
155 155
 			$user = $page->getUser();
156 156
 			if ( array_key_exists( 'checkuser', $admins[ $user ] ) ) {
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 				if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
159 159
 					// Remove the line
160 160
 					$newContent = preg_replace( $reg, '', $newContent );
161
-					$removeNames[] = $user;
161
+					$removeNames[ ] = $user;
162 162
 				} else {
163 163
 					$newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent );
164
-					$riconfNames[] = $user;
164
+					$riconfNames[ ] = $user;
165 165
 				}
166 166
 			}
167 167
 		}
Please login to merge, or discard this patch.