Passed
Push — master ( 5a2178...ae0cdc )
by Daimona
01:59
created
includes/Wiki/WikiGroup.php 1 patch
Spacing   +5 added lines, -5 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;
4 4
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @param Wiki $centralWiki
19 19
 	 * @param Wiki $privateWiki
20 20
 	 */
21
-	public function __construct( Wiki $mainWiki, Wiki $centralWiki, Wiki $privateWiki ) {
21
+	public function __construct ( Wiki $mainWiki, Wiki $centralWiki, Wiki $privateWiki ) {
22 22
 		$this->mainWiki = $mainWiki;
23 23
 		$this->centralWiki = $centralWiki;
24 24
 		$this->privateWiki = $privateWiki;
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @return Wiki
29 29
 	 */
30
-	public function getMainWiki() : Wiki {
30
+	public function getMainWiki () : Wiki {
31 31
 		return $this->mainWiki;
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	 * @return Wiki
36 36
 	 */
37
-	public function getCentralWiki() : Wiki {
37
+	public function getCentralWiki () : Wiki {
38 38
 		return $this->centralWiki;
39 39
 	}
40 40
 
41 41
 	/**
42 42
 	 * @return Wiki
43 43
 	 */
44
-	public function getPrivateWiki() : Wiki {
44
+	public function getPrivateWiki () : Wiki {
45 45
 		return $this->privateWiki;
46 46
 	}
47 47
 }
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,15 +14,15 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	protected function getSubtasksMap(): array {
17
+	protected function getSubtasksMap (): array {
18 18
 		// Everything is done here.
19
-		return [];
19
+		return [ ];
20 20
 	}
21 21
 
22 22
 	/**
23 23
 	 * @inheritDoc
24 24
 	 */
25
-	public function runInternal() : int {
25
+	public function runInternal () : int {
26 26
 		$pages = $this->getDataProvider()->getOpenPages();
27 27
 
28 28
 		if ( !$pages ) {
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
 	 * @param PageRiconferma[] $pages
37 37
 	 * @return int a STATUS_* constant
38 38
 	 */
39
-	protected function processPages( array $pages ) : int {
40
-		$donePages = [];
39
+	protected function processPages ( array $pages ) : int {
40
+		$donePages = [ ];
41 41
 		foreach ( $pages as $page ) {
42 42
 			if ( $page->hasOpposition() && !$page->isVote() ) {
43 43
 				$this->openVote( $page );
44 44
 				$this->updateBasePage( $page );
45
-				$donePages[] = $page;
45
+				$donePages[ ] = $page;
46 46
 			}
47 47
 		}
48 48
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param PageRiconferma $page
62 62
 	 */
63
-	protected function openVote( PageRiconferma $page ) : void {
63
+	protected function openVote ( PageRiconferma $page ) : void {
64 64
 		$this->getLogger()->info( "Starting vote on $page" );
65 65
 
66 66
 		$content = $page->getContent();
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
 	 * @see SimpleUpdates::updateVotazioni()
100 100
 	 * @see OpenUpdates::addToVotazioni()
101 101
 	 */
102
-	protected function updateVotazioni( array $pages ) : void {
102
+	protected function updateVotazioni ( array $pages ) : void {
103 103
 		$votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) );
104 104
 
105
-		$users = [];
105
+		$users = [ ];
106 106
 		foreach ( $pages as $page ) {
107
-			$users[] = $this->getUser( $page->getUserName() );
107
+			$users[ ] = $this->getUser( $page->getUserName() );
108 108
 		}
109 109
 		$usersReg = RegexUtils::regexFromArray( '!', ...$users );
110 110
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @param PageRiconferma $page
139 139
 	 * @see \BotRiconferme\Task\Subtask\ClosePages::updateBasePage()
140 140
 	 */
141
-	protected function updateBasePage( PageRiconferma $page ) : void {
141
+	protected function updateBasePage ( PageRiconferma $page ) : void {
142 142
 		$this->getLogger()->info( "Updating base page for $page" );
143 143
 
144 144
 		if ( $page->getNum() === 1 ) {
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @see SimpleUpdates::updateNews()
166 166
 	 * @see OpenUpdates::addToNews()
167 167
 	 */
168
-	protected function updateNews( int $amount ) : void {
168
+	protected function updateNews ( int $amount ) : void {
169 169
 		$this->getLogger()->info( "Turning $amount pages into votes" );
170 170
 		$newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) );
171 171
 
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 			throw new TaskException( 'Param "voto" not found in news page' );
181 181
 		}
182 182
 
183
-		$newTac = ( (int)$newsPage->getMatch( $regTac )[2] - $amount ) ?: '';
184
-		$newVot = ( (int)$newsPage->getMatch( $regVot )[2] + $amount ) ?: '';
183
+		$newTac = ( (int)$newsPage->getMatch( $regTac )[ 2 ] - $amount ) ?: '';
184
+		$newVot = ( (int)$newsPage->getMatch( $regVot )[ 2 ] + $amount ) ?: '';
185 185
 
186 186
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
187 187
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/Task/Subtask/ClosePages.php 1 patch
Spacing   +5 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\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
 
19 19
 		if ( !$pages ) {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @param PageRiconferma $page
37 37
 	 */
38
-	protected function addVoteCloseText( PageRiconferma $page ) : void {
38
+	protected function addVoteCloseText ( PageRiconferma $page ) : void {
39 39
 		$content = $page->getContent();
40 40
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!u';
41 41
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @param PageRiconferma $page
51 51
 	 * @see CreatePages::updateBasePage()
52 52
 	 */
53
-	protected function updateBasePage( PageRiconferma $page ) : void {
53
+	protected function updateBasePage ( PageRiconferma $page ) : void {
54 54
 		$this->getLogger()->info( "Updating base page for $page" );
55 55
 
56 56
 		if ( $page->getNum() === 1 ) {
@@ -62,8 +62,7 @@  discard block
 block discarded – undo
62 62
 		$current = $basePage->getContent();
63 63
 
64 64
 		$outcomeText = ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) ?
65
-			'non riconfermato' :
66
-			'riconfermato';
65
+			'non riconfermato' : 'riconfermato';
67 66
 		$text = $page->isVote() ? "votazione di riconferma: $outcomeText" : 'riconferma tacita';
68 67
 
69 68
 		$newContent = preg_replace( '/^(#: *)(votazione di )?riconferma in corso/m', '$1' . $text, $current );
Please login to merge, or discard this patch.
includes/Task/Subtask/CreatePages.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\Task\Subtask;
4 4
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @inheritDoc
19 19
 	 */
20
-	public function runInternal() : int {
20
+	public function runInternal () : int {
21 21
 		$users = $this->getDataProvider()->getUsersToProcess();
22 22
 
23 23
 		if ( !$users ) {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param User $user
38 38
 	 */
39
-	protected function processUser( User $user ) : void {
39
+	protected function processUser ( User $user ) : void {
40 40
 		$this->getLogger()->info( "Processing user $user" );
41 41
 		try {
42 42
 			$num = $this->getLastPageNum( $user ) + 1;
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 	 * @return int
72 72
 	 * @throws TaskException
73 73
 	 */
74
-	protected function getLastPageNum( User $user ) : int {
74
+	protected function getLastPageNum ( User $user ) : int {
75 75
 		$this->getLogger()->info( "Retrieving previous pages for $user" );
76 76
 
77
-		$unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[1];
77
+		$unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[ 1 ];
78 78
 
79 79
 		$prefixes = [ "$unprefixedTitle/$user/" ];
80 80
 		foreach ( $user->getAliases() as $alias ) {
81
-			$prefixes[] = "$unprefixedTitle/$alias/";
81
+			$prefixes[ ] = "$unprefixedTitle/$alias/";
82 82
 		}
83 83
 
84 84
 		$params = [
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		];
91 91
 		$pagesIterator = new AppendIterator();
92 92
 		foreach ( $prefixes as $prefix ) {
93
-			$params['apprefix'] = $prefix;
93
+			$params[ 'apprefix' ] = $prefix;
94 94
 			$res = $this->getRequestFactory()->newFromParams( $params )->executeAsQuery();
95 95
 			$pagesIterator->append( new NoRewindIterator( $res ) );
96 96
 		}
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 	 * @param string $title
117 117
 	 * @param User $user
118 118
 	 */
119
-	protected function createPage( string $title, User $user ) : void {
119
+	protected function createPage ( string $title, User $user ) : void {
120 120
 		$this->getLogger()->info( "Creating page $title" );
121 121
 		$groups = $user->getGroupsWithDates();
122 122
 		$textParams = [
123 123
 			'$user' => $user->getName(),
124
-			'$date' => $groups['sysop'],
125
-			'$burocrate' => $groups['bureaucrat'] ?? '',
126
-			'$checkuser' => $groups['checkuser'] ?? ''
124
+			'$date' => $groups[ 'sysop' ],
125
+			'$burocrate' => $groups[ 'bureaucrat' ] ?? '',
126
+			'$checkuser' => $groups[ 'checkuser' ] ?? ''
127 127
 		];
128 128
 
129 129
 		$params = [
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param Page $basePage
142 142
 	 * @param string $newText
143 143
 	 */
144
-	protected function createBasePage( Page $basePage, string $newText ) : void {
144
+	protected function createBasePage ( Page $basePage, string $newText ) : void {
145 145
 		$this->getLogger()->info( "Creating base page $basePage" );
146 146
 
147 147
 		$params = [
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @param Page $basePage
158 158
 	 * @param string $newText
159 159
 	 */
160
-	protected function updateBasePage( Page $basePage, string $newText ) : void {
160
+	protected function updateBasePage ( Page $basePage, string $newText ) : void {
161 161
 		$this->getLogger()->info( "Updating base page $basePage" );
162 162
 
163 163
 		$params = [
Please login to merge, or discard this patch.
includes/TaskHelper/TaskDataProvider.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\TaskHelper;
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/** @var User[]|null */
16 16
 	private $processUsers;
17 17
 	/** @var PageRiconferma[] */
18
-	private $createdPages = [];
18
+	private $createdPages = [ ];
19 19
 	/** @var PageRiconferma[]|null */
20 20
 	private $openPages;
21 21
 	/** @var PageRiconferma[]|null */
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return User[]
28 28
 	 */
29
-	public function getUsersToProcess() : array {
29
+	public function getUsersToProcess () : array {
30 30
 		if ( $this->processUsers === null ) {
31
-			$this->processUsers = [];
31
+			$this->processUsers = [ ];
32 32
 			foreach ( $this->getBotList()->getAdminsList() as $name => $userInfo ) {
33 33
 				if ( $this->shouldAddUser( $userInfo ) ) {
34 34
 					$this->processUsers[ $name ] = new User( $userInfo, $this->getWiki() );
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param UserInfo $ui
46 46
 	 * @return bool
47 47
 	 */
48
-	private function shouldAddUser( UserInfo $ui ) : bool {
48
+	private function shouldAddUser ( UserInfo $ui ) : bool {
49 49
 		$timestamp = $this->getBotList()->getOverrideTimestamp( $ui );
50 50
 		$override = $timestamp !== null;
51 51
 
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return PageRiconferma[]
65 65
 	 */
66
-	public function getOpenPages() : array {
66
+	public function getOpenPages () : array {
67 67
 		if ( $this->openPages === null ) {
68
-			$this->openPages = [];
68
+			$this->openPages = [ ];
69 69
 			$mainTitle = $this->getOpt( 'main-page-title' );
70 70
 			$params = [
71 71
 				'action' => 'query',
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			$pages = $this->getRequestFactory()->newFromParams( $params )->executeAsQuery();
80 80
 			foreach ( $pages->current()->templates as $page ) {
81 81
 				if ( preg_match( "!$titleReg/[^/]+/\d!", $page->title ) ) {
82
-					$this->openPages[] = new PageRiconferma( $page->title, $this->getWiki() );
82
+					$this->openPages[ ] = new PageRiconferma( $page->title, $this->getWiki() );
83 83
 				}
84 84
 			}
85 85
 		}
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return PageRiconferma[]
94 94
 	 */
95
-	public function getPagesToClose() : array {
95
+	public function getPagesToClose () : array {
96 96
 		if ( $this->pagesToClose === null ) {
97
-			$this->pagesToClose = [];
97
+			$this->pagesToClose = [ ];
98 98
 			foreach ( $this->getOpenPages() as $page ) {
99 99
 				if ( time() > $page->getEndTimestamp() ) {
100
-					$this->pagesToClose[] = $page;
100
+					$this->pagesToClose[ ] = $page;
101 101
 				}
102 102
 			}
103 103
 		}
@@ -109,21 +109,21 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @param string $name
111 111
 	 */
112
-	public function removeUser( string $name ) : void {
112
+	public function removeUser ( string $name ) : void {
113 113
 		unset( $this->processUsers[ $name ] );
114 114
 	}
115 115
 
116 116
 	/**
117 117
 	 * @return PageRiconferma[]
118 118
 	 */
119
-	public function getCreatedPages() : array {
119
+	public function getCreatedPages () : array {
120 120
 		return $this->createdPages;
121 121
 	}
122 122
 
123 123
 	/**
124 124
 	 * @param PageRiconferma $page
125 125
 	 */
126
-	public function addCreatedPage( PageRiconferma $page ) : void {
127
-		$this->createdPages[] = $page;
126
+	public function addCreatedPage ( PageRiconferma $page ) : void {
127
+		$this->createdPages[ ] = $page;
128 128
 	}
129 129
 }
Please login to merge, or discard this patch.
includes/Wiki/Wiki.php 1 patch
Spacing   +21 added lines, -21 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;
4 4
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param LoggerInterface $logger
37 37
 	 * @param RequestFactory $requestFactory
38 38
 	 */
39
-	public function __construct(
39
+	public function __construct (
40 40
 		LoginInfo $li,
41 41
 		LoggerInterface $logger,
42 42
 		RequestFactory $requestFactory
@@ -49,35 +49,35 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * @return LoginInfo
51 51
 	 */
52
-	public function getLoginInfo() : LoginInfo {
52
+	public function getLoginInfo () : LoginInfo {
53 53
 		return $this->loginInfo;
54 54
 	}
55 55
 
56 56
 	/**
57 57
 	 * @return RequestFactory
58 58
 	 */
59
-	public function getRequestFactory() : RequestFactory {
59
+	public function getRequestFactory () : RequestFactory {
60 60
 		return $this->requestFactory;
61 61
 	}
62 62
 
63 63
 	/**
64 64
 	 * @param string $prefix
65 65
 	 */
66
-	public function setPagePrefix( string $prefix ) : void {
66
+	public function setPagePrefix ( string $prefix ) : void {
67 67
 		$this->pagePrefix = $prefix;
68 68
 	}
69 69
 
70 70
 	/**
71 71
 	 * @param string $ident
72 72
 	 */
73
-	public function setLocalUserIdentifier( string $ident ) : void {
73
+	public function setLocalUserIdentifier ( string $ident ) : void {
74 74
 		$this->localUserIdentifier = $ident;
75 75
 	}
76 76
 
77 77
 	/**
78 78
 	 * @return string
79 79
 	 */
80
-	public function getLocalUserIdentifier() : string {
80
+	public function getLocalUserIdentifier () : string {
81 81
 		return $this->localUserIdentifier;
82 82
 	}
83 83
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @param string $title
86 86
 	 * @param int|null $section
87 87
 	 */
88
-	private function logRead( string $title, int $section = null ) : void {
88
+	private function logRead ( string $title, int $section = null ) : void {
89 89
 		$fullTitle = $this->pagePrefix . $title;
90 90
 		$msg = "Retrieving content of $fullTitle" . ( $section !== null ? ", section $section" : '' );
91 91
 		$this->logger->info( $msg );
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @throws MissingPageException
101 101
 	 * @throws MissingSectionException
102 102
 	 */
103
-	public function getPageContent( string $title, int $section = null ) : string {
103
+	public function getPageContent ( string $title, int $section = null ) : string {
104 104
 		$this->logRead( $title, $section );
105 105
 		$params = [
106 106
 			'action' => 'query',
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		];
112 112
 
113 113
 		if ( $section !== null ) {
114
-			$params['rvsection'] = $section;
114
+			$params[ 'rvsection' ] = $section;
115 115
 		}
116 116
 
117 117
 		$req = $this->buildRequest( $params );
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 			throw new MissingPageException( $title );
121 121
 		}
122 122
 
123
-		$mainSlot = $page->revisions[0]->slots->main;
123
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
124 124
 
125 125
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
126 126
 			throw new MissingSectionException( $title, $section );
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @phan-param array<int|string|bool> $params
136 136
 	 * @throws EditException
137 137
 	 */
138
-	public function editPage( array $params ) : void {
138
+	public function editPage ( array $params ) : void {
139 139
 		$this->login();
140 140
 
141 141
 		$params = [
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		] + $params;
145 145
 
146 146
 		if ( BOT_EDITS === true ) {
147
-			$params['bot'] = 1;
147
+			$params[ 'bot' ] = 1;
148 148
 		}
149 149
 
150 150
 		$res = $this->buildRequest( $params )->setPost()->executeSingle();
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
163 163
 	 * @throws LoginException
164 164
 	 */
165
-	public function login() : void {
165
+	public function login () : void {
166 166
 		if ( $this->loginInfo === null ) {
167 167
 			throw new CannotLoginException( 'Missing login data' );
168 168
 		}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$this->loggedIn = true;
194 194
 		// Clear tokens cache
195
-		$this->tokens = [];
195
+		$this->tokens = [ ];
196 196
 		$this->logger->info( 'Login succeeded' );
197 197
 	}
198 198
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 * @param string $type
203 203
 	 * @return string
204 204
 	 */
205
-	public function getToken( string $type ) : string {
205
+	public function getToken ( string $type ) : string {
206 206
 		if ( !isset( $this->tokens[ $type ] ) ) {
207 207
 			$params = [
208 208
 				'action' => 'query',
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 * @param string $title
223 223
 	 * @return int
224 224
 	 */
225
-	public function getPageCreationTS( string $title ) : int {
225
+	public function getPageCreationTS ( string $title ) : int {
226 226
 		$params = [
227 227
 			'action' => 'query',
228 228
 			'prop' => 'revisions',
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		];
235 235
 
236 236
 		$page = $this->buildRequest( $params )->executeAsQuery()->current();
237
-		return strtotime( $page->revisions[0]->timestamp );
237
+		return strtotime( $page->revisions[ 0 ]->timestamp );
238 238
 	}
239 239
 
240 240
 	/**
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @param string $title
244 244
 	 * @param string $reason
245 245
 	 */
246
-	public function protectPage( string $title, string $reason ) : void {
246
+	public function protectPage ( string $title, string $reason ) : void {
247 247
 		$fullTitle = $this->pagePrefix . $title;
248 248
 		$this->logger->info( "Protecting page $fullTitle" );
249 249
 		$this->login();
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 * @param string $username
267 267
 	 * @param string $reason
268 268
 	 */
269
-	public function blockUser( string $username, string $reason ) : void {
269
+	public function blockUser ( string $username, string $reason ) : void {
270 270
 		$this->logger->info( "Blocking user $username" );
271 271
 		$this->login();
272 272
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 * @phan-param array<int|string|bool> $params
294 294
 	 * @return RequestBase
295 295
 	 */
296
-	private function buildRequest( array $params ) : RequestBase {
296
+	private function buildRequest ( array $params ) : RequestBase {
297 297
 		return $this->requestFactory->newFromParams( $params );
298 298
 	}
299 299
 }
Please login to merge, or discard this patch.
includes/Wiki/Page/PageBotList.php 1 patch
Spacing   +25 added lines, -27 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
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @param string $listTitle
20 20
 	 * @param Wiki $wiki
21 21
 	 */
22
-	public function __construct( string $listTitle, Wiki $wiki ) {
22
+	public function __construct ( string $listTitle, Wiki $wiki ) {
23 23
 		parent::__construct( $listTitle, $wiki );
24 24
 	}
25 25
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @param string $listTitle
31 31
 	 * @return self
32 32
 	 */
33
-	public static function get( Wiki $wiki, string $listTitle ) : self {
33
+	public static function get ( Wiki $wiki, string $listTitle ) : self {
34 34
 		static $instance = null;
35 35
 		if ( $instance === null ) {
36 36
 			$instance = new self( $listTitle, $wiki );
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @param UserInfo $ui
43 43
 	 * @return int|null
44 44
 	 */
45
-	public function getOverrideTimestamp( UserInfo $ui ) : ?int {
45
+	public function getOverrideTimestamp ( UserInfo $ui ) : ?int {
46 46
 		$info = $ui->getInfo();
47 47
 		if ( !array_intersect_key( $info, [ 'override-perm' => true, 'override' => true ] ) ) {
48 48
 			return null;
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// A one-time override takes precedence
52 52
 		if ( array_key_exists( 'override', $info ) ) {
53
-			$date = $info['override'];
53
+			$date = $info[ 'override' ];
54 54
 		} else {
55
-			$date = $info['override-prem'] . '/' . date( 'Y' );
55
+			$date = $info[ 'override-prem' ] . '/' . date( 'Y' );
56 56
 		}
57 57
 		return \DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp();
58 58
 	}
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
 	 * @return int
65 65
 	 * @suppress PhanPluginComparisonObjectOrdering DateTime objects can be compared (phan issue #2907)
66 66
 	 */
67
-	public function getNextTimestamp( string $user ) : int {
67
+	public function getNextTimestamp ( string $user ) : int {
68 68
 		$userInfo = $this->getUserInfo( $user )->getInfo();
69
-		if ( isset( $userInfo['override-perm'] ) ) {
69
+		if ( isset( $userInfo[ 'override-perm' ] ) ) {
70 70
 			$date = \DateTime::createFromFormat(
71 71
 				'd/m/Y',
72
-				$userInfo['override-perm'] . '/' . date( 'Y' )
72
+				$userInfo[ 'override-perm' ] . '/' . date( 'Y' )
73 73
 			);
74 74
 		} else {
75 75
 			$date = null;
76
-			if ( isset( $userInfo['override'] ) ) {
77
-				$date = \DateTime::createFromFormat( 'd/m/Y', $userInfo['override'] );
76
+			if ( isset( $userInfo[ 'override' ] ) ) {
77
+				$date = \DateTime::createFromFormat( 'd/m/Y', $userInfo[ 'override' ] );
78 78
 			}
79 79
 			if ( !$date || $date <= new \DateTime ) {
80 80
 				$ts = self::getValidFlagTimestamp( $userInfo );
@@ -94,17 +94,15 @@  discard block
 block discarded – undo
94 94
 	 * @param string[] $groups
95 95
 	 * @return int
96 96
 	 */
97
-	public static function getValidFlagTimestamp( array $groups ): int {
98
-		$checkuser = isset( $groups['checkuser'] ) ?
99
-			\DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() :
100
-			0;
101
-		$bureaucrat = isset( $groups['bureaucrat'] ) ?
102
-			\DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() :
103
-			0;
97
+	public static function getValidFlagTimestamp ( array $groups ): int {
98
+		$checkuser = isset( $groups[ 'checkuser' ] ) ?
99
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
100
+		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
101
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
104 102
 
105 103
 		$timestamp = max( $bureaucrat, $checkuser );
106 104
 		if ( $timestamp === 0 ) {
107
-			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp();
105
+			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp();
108 106
 		}
109 107
 		return $timestamp;
110 108
 	}
@@ -118,14 +116,14 @@  discard block
 block discarded – undo
118 116
 	 * @param string[] $groups
119 117
 	 * @return bool
120 118
 	 */
121
-	public static function isOverrideExpired( array $groups ) : bool {
122
-		if ( !isset( $groups['override'] ) ) {
119
+	public static function isOverrideExpired ( array $groups ) : bool {
120
+		if ( !isset( $groups[ 'override' ] ) ) {
123 121
 			return false;
124 122
 		}
125 123
 
126 124
 		$flagTS = self::getValidFlagTimestamp( $groups );
127 125
 		$usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) );
128
-		$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp();
126
+		$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp();
129 127
 		$delay = 60 * 60 * 24 * 3;
130 128
 
131 129
 		return time() > $usualTS + $delay && time() > $overrideTS + $delay;
@@ -136,9 +134,9 @@  discard block
 block discarded – undo
136 134
 	 *
137 135
 	 * @return UserInfo[]
138 136
 	 */
139
-	public function getAdminsList() : array {
137
+	public function getAdminsList () : array {
140 138
 		if ( $this->adminsList === null ) {
141
-			$this->adminsList = [];
139
+			$this->adminsList = [ ];
142 140
 			foreach ( $this->getDecodedContent() as $user => $info ) {
143 141
 				$this->adminsList[ $user ] = new UserInfo( $user, $info );
144 142
 			}
@@ -150,8 +148,8 @@  discard block
 block discarded – undo
150 148
 	 * @param string $user
151 149
 	 * @return UserInfo
152 150
 	 */
153
-	public function getUserInfo( string $user ) : UserInfo {
154
-		return $this->getAdminsList()[$user];
151
+	public function getUserInfo ( string $user ) : UserInfo {
152
+		return $this->getAdminsList()[ $user ];
155 153
 	}
156 154
 
157 155
 	/**
@@ -159,7 +157,7 @@  discard block
 block discarded – undo
159 157
 	 *
160 158
 	 * @return string[][]
161 159
 	 */
162
-	public function getDecodedContent() : array {
160
+	public function getDecodedContent () : array {
163 161
 		return json_decode( $this->getContent(), true );
164 162
 	}
165 163
 }
Please login to merge, or discard this patch.
includes/Wiki/UserInfo.php 1 patch
Spacing   +8 added lines, -8 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;
4 4
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param array $info
22 22
 	 * @phan-param array<string,string|string[]> $info
23 23
 	 */
24
-	public function __construct( string $name, array $info ) {
24
+	public function __construct ( string $name, array $info ) {
25 25
 		$this->name = $name;
26 26
 		$this->info = $info;
27 27
 	}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * @return string
31 31
 	 */
32
-	public function getName() : string {
32
+	public function getName () : string {
33 33
 		return $this->name;
34 34
 	}
35 35
 
@@ -37,28 +37,28 @@  discard block
 block discarded – undo
37 37
 	 * @return array
38 38
 	 * @phan-return array<string,string|string[]>
39 39
 	 */
40
-	public function getInfo() : array {
40
+	public function getInfo () : array {
41 41
 		return $this->info;
42 42
 	}
43 43
 
44 44
 	/**
45 45
 	 * @return string[]
46 46
 	 */
47
-	public function extractGroups() : array {
47
+	public function extractGroups () : array {
48 48
 		return array_keys( $this->extractGroupsWithDates() );
49 49
 	}
50 50
 
51 51
 	/**
52 52
 	 * @return string[]
53 53
 	 */
54
-	public function extractGroupsWithDates() : array {
54
+	public function extractGroupsWithDates () : array {
55 55
 		return array_intersect_key( $this->getInfo(), array_fill_keys( self::GROUP_KEYS, 1 ) );
56 56
 	}
57 57
 
58 58
 	/**
59 59
 	 * @return string[]
60 60
 	 */
61
-	public function getAliases() : array {
62
-		return $this->getInfo()['aliases'] ?? [];
61
+	public function getAliases () : array {
62
+		return $this->getInfo()[ 'aliases' ] ?? [ ];
63 63
 	}
64 64
 }
Please login to merge, or discard this patch.
includes/Task/Subtask/SimpleUpdates.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\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
 		$pages = $this->getDataProvider()->getPagesToClose();
19 19
 
20 20
 		if ( !$pages ) {
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
 	 * @param PageRiconferma[] $pages
37 37
 	 * @see OpenUpdates::addToVotazioni()
38 38
 	 */
39
-	protected function updateVotazioni( array $pages ) : void {
39
+	protected function updateVotazioni ( array $pages ) : void {
40 40
 		$this->getLogger()->info(
41 41
 			'Updating votazioni: ' . implode( ', ', $pages )
42 42
 		);
43 43
 		$votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) );
44 44
 
45
-		$users = [];
45
+		$users = [ ];
46 46
 		foreach ( $pages as $page ) {
47
-			$users[] = $this->getUser( $page->getUserName() );
47
+			$users[ ] = $this->getUser( $page->getUserName() );
48 48
 		}
49 49
 		$usersReg = RegexUtils::regexFromArray( '!', ...$users );
50 50
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @param PageRiconferma[] $pages
66 66
 	 * @see OpenUpdates::addToNews()
67 67
 	 */
68
-	protected function updateNews( array $pages ) : void {
68
+	protected function updateNews ( array $pages ) : void {
69 69
 		$simpleAmount = $voteAmount = 0;
70 70
 		foreach ( $pages as $page ) {
71 71
 			if ( $page->isVote() ) {
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 		$simpleMatches = $newsPage->getMatch( $simpleReg );
86 86
 		$voteMatches = $newsPage->getMatch( $voteReg );
87 87
 
88
-		$newSimp = ( (int)$simpleMatches[2] - $simpleAmount ) ?: '';
89
-		$newVote = ( (int)$voteMatches[2] - $voteAmount ) ?: '';
88
+		$newSimp = ( (int)$simpleMatches[ 2 ] - $simpleAmount ) ?: '';
89
+		$newVote = ( (int)$voteMatches[ 2 ] - $voteAmount ) ?: '';
90 90
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() );
91 91
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
92 92
 
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @param bool[] $outcomes
106 106
 	 */
107
-	protected function updateAdminList( array $outcomes ) : void {
107
+	protected function updateAdminList ( array $outcomes ) : void {
108 108
 		$this->getLogger()->info( 'Updating admin list' );
109 109
 		$adminsPage = $this->getPage( $this->getOpt( 'admins-list-title' ) );
110 110
 		$newContent = $adminsPage->getContent();
111 111
 
112
-		$riconfNames = $removeNames = [];
112
+		$riconfNames = $removeNames = [ ];
113 113
 		foreach ( $outcomes as $username => $confirmed ) {
114 114
 			$user = $this->getUser( $username );
115 115
 			$userReg = $user->getRegex( '!' );
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 					'${1}{{subst:#timel:Ymd}}|' . $nextDate . '$2',
125 125
 					$newContent
126 126
 				);
127
-				$riconfNames[] = $username;
127
+				$riconfNames[ ] = $username;
128 128
 			} else {
129 129
 				$newContent = preg_replace( $reg, '', $newContent );
130
-				$removeNames[] = $username;
130
+				$removeNames[ ] = $username;
131 131
 			}
132 132
 		}
133 133
 
@@ -147,21 +147,21 @@  discard block
 block discarded – undo
147 147
 	/**
148 148
 	 * @param bool[] $outcomes
149 149
 	 */
150
-	protected function updateCUList( array $outcomes ) : void {
150
+	protected function updateCUList ( array $outcomes ) : void {
151 151
 		$this->getLogger()->info( 'Updating CU list.' );
152 152
 		$cuList = $this->getPage( $this->getOpt( 'cu-list-title' ) );
153 153
 		$newContent = $cuList->getContent();
154 154
 
155
-		$riconfNames = $removeNames = [];
155
+		$riconfNames = $removeNames = [ ];
156 156
 		foreach ( $outcomes as $user => $confirmed ) {
157 157
 			$userReg = $this->getUser( $user )->getRegex( '!' );
158 158
 			$reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!";
159 159
 			if ( $confirmed ) {
160 160
 				$newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent );
161
-				$riconfNames[] = $user;
161
+				$riconfNames[ ] = $user;
162 162
 			} else {
163 163
 				$newContent = preg_replace( $reg, '', $newContent );
164
-				$removeNames[] = $user;
164
+				$removeNames[ ] = $user;
165 165
 			}
166 166
 		}
167 167
 
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 	 * @param PageRiconferma[] $pages
186 186
 	 * @return bool[]
187 187
 	 */
188
-	private function getGroupOutcomes( string $group, array $pages ) : array {
189
-		$ret = [];
188
+	private function getGroupOutcomes ( string $group, array $pages ) : array {
189
+		$ret = [ ];
190 190
 		foreach ( $pages as $page ) {
191 191
 			$user = $this->getUser( $page->getUserName() );
192 192
 			if ( $user->inGroup( $group ) ) {
Please login to merge, or discard this patch.