Passed
Push — master ( 10aa7b...8214a5 )
by Daimona
01:42
created
includes/Task/Subtask/FailedUpdates.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task\Subtask;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function runInternal() : int {
17
+	public function runInternal () : int {
18 18
 		$failed = $this->getFailures();
19 19
 		if ( $failed ) {
20 20
 			$this->updateBurList( $failed );
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @return PageRiconferma[]
33 33
 	 */
34
-	private function getFailures() : array {
35
-		$ret = [];
34
+	private function getFailures () : array {
35
+		$ret = [ ];
36 36
 		$allPages = $this->getDataProvider()->getPagesToClose();
37 37
 		foreach ( $allPages as $page ) {
38 38
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
39
-				$ret[] = $page;
39
+				$ret[ ] = $page;
40 40
 			}
41 41
 		}
42 42
 		return $ret;
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 	/**
46 46
 	 * @param PageRiconferma[] $pages
47 47
 	 */
48
-	protected function updateBurList( array $pages ) {
48
+	protected function updateBurList ( array $pages ) {
49 49
 		$this->getLogger()->info( 'Checking if bur list needs updating.' );
50 50
 
51
-		$remove = [];
51
+		$remove = [ ];
52 52
 		foreach ( $pages as $page ) {
53 53
 			$user = $page->getUser();
54 54
 			if ( $user->inGroup( 'bureaucrat' ) &&
55 55
 				( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL )
56 56
 			) {
57
-				$remove[] = $user->getName();
57
+				$remove[ ] = $user->getName();
58 58
 			}
59 59
 		}
60 60
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @param PageRiconferma[] $pages
86 86
 	 */
87
-	protected function requestRemoval( array $pages ) {
87
+	protected function requestRemoval ( array $pages ) {
88 88
 		$this->getLogger()->info(
89 89
 			'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) )
90 90
 		);
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @param PageRiconferma[] $pages
124 124
 	 */
125
-	protected function updateAnnunci( array $pages ) {
125
+	protected function updateAnnunci ( array $pages ) {
126 126
 		$this->getLogger()->info( 'Updating annunci' );
127 127
 
128
-		$names = [];
128
+		$names = [ ];
129 129
 		$text = '';
130 130
 		foreach ( $pages as $page ) {
131 131
 			$user = $page->getUser()->getName();
132
-			$names[] = $user;
132
+			$names[ ] = $user;
133 133
 			$text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " .
134 134
 				"non è stato riconfermato [[WP:A|amministratore]].}}\n";
135 135
 		}
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @param PageRiconferma[] $pages
165 165
 	 */
166
-	protected function updateUltimeNotizie( array $pages ) {
166
+	protected function updateUltimeNotizie ( array $pages ) {
167 167
 		$this->getLogger()->info( 'Updating ultime notizie' );
168 168
 		$notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-page-title' ) );
169 169
 
170
-		$names = [];
170
+		$names = [ ];
171 171
 		$text = '';
172 172
 		foreach ( $pages as $page ) {
173 173
 			$user = $page->getUser()->getName();
174 174
 			$title = $page->getTitle();
175
-			$names[] = $user;
175
+			$names[ ] = $user;
176 176
 			$text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " .
177 177
 				'[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.';
178 178
 		}
Please login to merge, or discard this patch.
includes/Wiki/Page/PageRiconferma.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Wiki\Page;
4 4
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * @param string $title
24 24
 	 */
25
-	public function __construct( string $title ) {
25
+	public function __construct ( string $title ) {
26 26
 		parent::__construct( $title );
27 27
 		$this->supportSection = $this->isVote() ? 3 : 0;
28 28
 		$this->opposeSection = $this->isVote() ? 4 : 3;
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @return User
35 35
 	 */
36
-	public function getUser() : User {
37
-		$name = explode( '/', $this->title )[2];
36
+	public function getUser () : User {
37
+		$name = explode( '/', $this->title )[ 2 ];
38 38
 		return new User( $name );
39 39
 	}
40 40
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 *
44 44
 	 * @return int
45 45
 	 */
46
-	public function getNum() : int {
46
+	public function getNum () : int {
47 47
 		$bits = explode( '/', $this->getTitle() );
48 48
 		return intval( end( $bits ) );
49 49
 	}
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return string
55 55
 	 */
56
-	public function getUserNum() : string {
57
-		return explode( '/', $this->getTitle(), 3 )[2];
56
+	public function getUserNum () : string {
57
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
58 58
 	}
59 59
 
60 60
 	/**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return string
64 64
 	 */
65
-	public function getBaseTitle() : string {
65
+	public function getBaseTitle () : string {
66 66
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug
67 67
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
68 68
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return int
74 74
 	 */
75
-	public function getOpposingCount() : int {
75
+	public function getOpposingCount () : int {
76 76
 		return $this->getCountForSection( $this->opposeSection );
77 77
 	}
78 78
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @return int
83 83
 	 * @throws \BadMethodCallException
84 84
 	 */
85
-	public function getSupportCount() : int {
85
+	public function getSupportCount () : int {
86 86
 		if ( !$this->isVote() ) {
87 87
 			throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' );
88 88
 		}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @param int $secNum
96 96
 	 * @return int
97 97
 	 */
98
-	protected function getCountForSection( int $secNum ) : int {
98
+	protected function getCountForSection ( int $secNum ) : int {
99 99
 		$content = $this->controller->getPageContent( $this->title, $secNum );
100 100
 		// Let's hope that this is good enough...
101 101
 		return substr_count( $content, "\n\# *(?![#*])" );
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return int
108 108
 	 */
109
-	protected function getQuorum() : int {
109
+	protected function getQuorum () : int {
110 110
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
111
-		return intval( $this->getMatch( $reg )[1] );
111
+		return intval( $this->getMatch( $reg )[ 1 ] );
112 112
 	}
113 113
 
114 114
 	/**
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return bool
118 118
 	 */
119
-	public function hasOpposition() : bool {
119
+	public function hasOpposition () : bool {
120 120
 		return $this->getOpposingCount() >= 15;
121 121
 	}
122 122
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @return int One of the OUTCOME_* constants
127 127
 	 * @throws \BadMethodCallException
128 128
 	 */
129
-	public function getOutcome() : int {
129
+	public function getOutcome () : int {
130 130
 		if ( !$this->isVote() ) {
131 131
 			throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' );
132 132
 		}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @throws \BadMethodCallException
147 147
 	 * @throws \LogicException
148 148
 	 */
149
-	public function getOutcomeText() : string {
149
+	public function getOutcomeText () : string {
150 150
 		if ( !$this->isVote() ) {
151 151
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
152 152
 		}
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return bool
182 182
 	 */
183
-	public function isVote() : bool {
183
+	public function isVote () : bool {
184 184
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
185 185
 		return !$this->matches( $sectionReg );
186 186
 	}
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return int
192 192
 	 */
193
-	public function getCreationTimestamp() : int {
193
+	public function getCreationTimestamp () : int {
194 194
 		return $this->controller->getPageCreationTS( $this->title );
195 195
 	}
196 196
 	/**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @return int
200 200
 	 */
201
-	public function getEndTimestamp() : int {
201
+	public function getEndTimestamp () : int {
202 202
 		if ( $this->isVote() ) {
203 203
 			$reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!";
204 204
 			list( , $day, $hours ) = $this->getMatch( $reg );
Please login to merge, or discard this patch.
includes/TaskDataProvider.php 1 patch
Spacing   +18 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme;
4 4
 
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 	/** @var array[] */
16 16
 	private $allUsers;
17 17
 	/** @var PageRiconferma[] */
18
-	private $createdPages = [];
18
+	private $createdPages = [ ];
19 19
 
20 20
 	/**
21 21
 	 * Get the full content of the JSON users list
22 22
 	 *
23 23
 	 * @return array[]
24 24
 	 */
25
-	public function getUsersList() : array {
25
+	public function getUsersList () : array {
26 26
 		if ( $this->allUsers === null ) {
27 27
 			$this->getLogger()->debug( 'Retrieving users list' );
28 28
 			$this->allUsers = PageBotList::get()->getAdminsList();
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return array[]
38 38
 	 */
39
-	public function getUsersToProcess() : array {
39
+	public function getUsersToProcess () : array {
40 40
 		if ( $this->processUsers === null ) {
41
-			$this->processUsers = [];
41
+			$this->processUsers = [ ];
42 42
 			foreach ( $this->getUsersList() as $user => $groups ) {
43 43
 				$timestamp = $this->getValidTimestamp( $groups );
44 44
 
@@ -60,13 +60,11 @@  discard block
 block discarded – undo
60 60
 	 * @param array $groups
61 61
 	 * @return int
62 62
 	 */
63
-	private function getValidTimestamp( array $groups ) : int {
63
+	private function getValidTimestamp ( array $groups ) : int {
64 64
 		$checkuser = isset( $groups[ 'checkuser' ] ) ?
65
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() :
66
-			0;
65
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
67 66
 		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
68
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() :
69
-			0;
67
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
70 68
 
71 69
 		$timestamp = max( $bureaucrat, $checkuser );
72 70
 		if ( $timestamp === 0 ) {
@@ -80,7 +78,7 @@  discard block
 block discarded – undo
80 78
 	 *
81 79
 	 * @return PageRiconferma[]
82 80
 	 */
83
-	public function getOpenPages() : array {
81
+	public function getOpenPages () : array {
84 82
 		static $list = null;
85 83
 		if ( $list === null ) {
86 84
 			$mainTitle = $this->getConfig()->get( 'main-page-title' );
@@ -93,10 +91,10 @@  discard block
 block discarded – undo
93 91
 			];
94 92
 
95 93
 			$pages = RequestBase::newFromParams( $params )->execute()->query->pages;
96
-			$list = [];
94
+			$list = [ ];
97 95
 			foreach ( reset( $pages )->templates as $page ) {
98 96
 				if ( preg_match( "!$mainTitle\/[^\/]+\/\d!", $page->title ) ) {
99
-					$list[] = new PageRiconferma( $page->title );
97
+					$list[ ] = new PageRiconferma( $page->title );
100 98
 				}
101 99
 			}
102 100
 		}
@@ -109,14 +107,14 @@  discard block
 block discarded – undo
109 107
 	 *
110 108
 	 * @return PageRiconferma[]
111 109
 	 */
112
-	public function getPagesToClose() : array {
110
+	public function getPagesToClose () : array {
113 111
 		static $list = null;
114 112
 		if ( $list === null ) {
115 113
 			$allPages = $this->getOpenPages();
116
-			$list = [];
114
+			$list = [ ];
117 115
 			foreach ( $allPages as $page ) {
118 116
 				if ( time() > $page->getEndTimestamp() ) {
119
-					$list[] = $page;
117
+					$list[ ] = $page;
120 118
 				}
121 119
 			}
122 120
 		}
@@ -128,21 +126,21 @@  discard block
 block discarded – undo
128 126
 	 *
129 127
 	 * @param string $name
130 128
 	 */
131
-	public function removeUser( string $name ) {
129
+	public function removeUser ( string $name ) {
132 130
 		unset( $this->processUsers[ $name ] );
133 131
 	}
134 132
 
135 133
 	/**
136 134
 	 * @return PageRiconferma[]
137 135
 	 */
138
-	public function getCreatedPages() : array {
136
+	public function getCreatedPages () : array {
139 137
 		return $this->createdPages;
140 138
 	}
141 139
 
142 140
 	/**
143 141
 	 * @param PageRiconferma $page
144 142
 	 */
145
-	public function addCreatedPages( PageRiconferma $page ) {
146
-		$this->createdPages[] = $page;
143
+	public function addCreatedPages ( PageRiconferma $page ) {
144
+		$this->createdPages[ ] = $page;
147 145
 	}
148 146
 }
Please login to merge, or discard this patch.