Passed
Push — master ( 1a47f4...ba2710 )
by Daimona
01:58
created
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
 
@@ -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
 		$protectReason = $this->msg( 'close-protect-summary' )->text();
20 20
 		foreach ( $pages as $page ) {
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	/**
32 32
 	 * @param PageRiconferma $page
33 33
 	 */
34
-	protected function addVoteCloseText( PageRiconferma $page ) {
34
+	protected function addVoteCloseText ( PageRiconferma $page ) {
35 35
 		$content = $page->getContent();
36 36
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!';
37 37
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -46,15 +46,14 @@  discard block
 block discarded – undo
46 46
 	 * @param PageRiconferma $page
47 47
 	 * @see CreatePages::updateBasePage()
48 48
 	 */
49
-	protected function updateBasePage( PageRiconferma $page ) {
49
+	protected function updateBasePage ( PageRiconferma $page ) {
50 50
 		$this->getLogger()->info( "Updating base page for $page" );
51 51
 
52 52
 		$basePage = new Page( $page->getBaseTitle() );
53 53
 		$current = $basePage->getContent();
54 54
 
55 55
 		$outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ?
56
-			'non riconfermato' :
57
-			'riconfermato';
56
+			'non riconfermato' : 'riconfermato';
58 57
 		$text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita';
59 58
 
60 59
 		$newContent = str_replace( 'riconferma in corso', $text, $current );
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
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * @param string $domain The URL of the wiki, if different from default
27 27
 	 */
28
-	public function __construct( string $domain = DEFAULT_URL ) {
28
+	public function __construct ( string $domain = DEFAULT_URL ) {
29 29
 		$this->logger = new Logger;
30 30
 		$this->domain = $domain;
31 31
 	}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @return string
39 39
 	 * @throws MissingPageException
40 40
 	 */
41
-	public function getPageContent( string $title, int $section = null ) : string {
41
+	public function getPageContent ( string $title, int $section = null ) : string {
42 42
 		$this->logger->debug( "Retrieving content of page $title" );
43 43
 		$params = [
44 44
 			'action' => 'query',
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		];
50 50
 
51 51
 		if ( $section !== null ) {
52
-			$params['rvsection'] = $section;
52
+			$params[ 'rvsection' ] = $section;
53 53
 		}
54 54
 
55 55
 		$req = RequestBase::newFromParams( $params )->setUrl( $this->domain );
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 			throw new MissingPageException( $title );
60 60
 		}
61 61
 
62
-		$mainSlot = $page->revisions[0]->slots->main;
62
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
63 63
 
64 64
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
65 65
 			throw new MissingSectionException( $title, $section );
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param array $params
74 74
 	 * @throws EditException
75 75
 	 */
76
-	public function editPage( array $params ) {
76
+	public function editPage ( array $params ) {
77 77
 		$this->login();
78 78
 
79 79
 		$params = [
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
96 96
 	 * @throws LoginException
97 97
 	 */
98
-	public function login() {
98
+	public function login () {
99 99
 		if ( self::$loggedIn ) {
100 100
 			$this->logger->debug( 'Already logged in' );
101 101
 			return;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
 		self::$loggedIn = true;
124 124
 		// Clear tokens cache
125
-		$this->tokens = [];
125
+		$this->tokens = [ ];
126 126
 		$this->logger->info( 'Login succeeded' );
127 127
 	}
128 128
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @param string $type
133 133
 	 * @return string
134 134
 	 */
135
-	public function getToken( string $type ) : string {
135
+	public function getToken ( string $type ) : string {
136 136
 		if ( !isset( $this->tokens[ $type ] ) ) {
137 137
 			$params = [
138 138
 				'action' => 'query',
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @param string $title
156 156
 	 * @return int
157 157
 	 */
158
-	public function getPageCreationTS( string $title ) : int {
158
+	public function getPageCreationTS ( string $title ) : int {
159 159
 		$params = [
160 160
 			'action' => 'query',
161 161
 			'prop' => 'revisions',
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
 		$res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute();
170 170
 		$data = $res->query->pages;
171
-		return strtotime( reset( $data )->revisions[0]->timestamp );
171
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
172 172
 	}
173 173
 
174 174
 	/**
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 * @param string $title
178 178
 	 * @param string $reason
179 179
 	 */
180
-	public function protectPage( string $title, string $reason ) {
180
+	public function protectPage ( string $title, string $reason ) {
181 181
 		$this->logger->info( "Protecting page $title" );
182 182
 		$this->login();
183 183
 
Please login to merge, or discard this patch.
includes/Task/Subtask/ArchivePages.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
 
@@ -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 ) {
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	 * @param PageRiconferma[] $pages
34 34
 	 * @see UpdatesAround::addToMainPage()
35 35
 	 */
36
-	protected function removeFromMainPage( array $pages ) {
36
+	protected function removeFromMainPage ( array $pages ) {
37 37
 		$this->getLogger()->info(
38 38
 			'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) )
39 39
 		);
40 40
 
41 41
 		$mainPage = new Page( $this->getConfig()->get( 'main-page-title' ) );
42
-		$remove = [];
42
+		$remove = [ ];
43 43
 		foreach ( $pages as $page ) {
44
-			$remove[] = '{{' . $page->getTitle() . '}}';
44
+			$remove[ ] = '{{' . $page->getTitle() . '}}';
45 45
 		}
46 46
 
47 47
 		$mainPage->edit( [
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param PageRiconferma[] $pages
57 57
 	 */
58
-	protected function addToArchive( array $pages ) {
58
+	protected function addToArchive ( array $pages ) {
59 59
 		$this->getLogger()->info(
60 60
 			'Adding to archive: ' . implode( ', ', array_map( 'strval', $pages ) )
61 61
 		);
62 62
 
63
-		$simple = $votes = [];
63
+		$simple = $votes = [ ];
64 64
 		foreach ( $pages as $page ) {
65 65
 			if ( $page->isVote() ) {
66
-				$votes[] = $page;
66
+				$votes[ ] = $page;
67 67
 			} else {
68
-				$simple[] = $page;
68
+				$simple[ ] = $page;
69 69
 			}
70 70
 		}
71 71
 
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 	 * @param string $archiveTitle
83 83
 	 * @param array $pages
84 84
 	 */
85
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) {
85
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) {
86 86
 		$archivePage = new Page( "$archiveTitle/" . date( 'Y' ) );
87 87
 
88 88
 		$append = '';
89
-		$archivedList = [];
89
+		$archivedList = [ ];
90 90
 		foreach ( $pages as $page ) {
91 91
 			$append .= '{{' . $page->getTitle() . "}}\n";
92
-			$archivedList[] = $page->getUserNum();
92
+			$archivedList[ ] = $page->getUserNum();
93 93
 		}
94 94
 
95 95
 		$summary = $this->msg( 'close-archive-summary' )
Please login to merge, or discard this patch.
includes/Task/Subtask/CreatePages.php 1 patch
Spacing   +11 added lines, -11 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
 		$users = $this->getDataProvider()->getUsersToProcess();
19 19
 
20 20
 		if ( !$users ) {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param string $user
35 35
 	 * @param array $groups
36 36
 	 */
37
-	protected function processUser( string $user, array $groups ) {
37
+	protected function processUser ( string $user, array $groups ) {
38 38
 		try {
39 39
 			$num = $this->getLastPageNum( $user ) + 1;
40 40
 		} catch ( TaskException $e ) {
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 * @return int
67 67
 	 * @throws TaskException
68 68
 	 */
69
-	protected function getLastPageNum( string $user ) : int {
69
+	protected function getLastPageNum ( string $user ) : int {
70 70
 		$this->getLogger()->debug( "Retrieving previous pages for $user" );
71
-		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'main-page-title' ), 2 )[1];
71
+		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'main-page-title' ), 2 )[ 1 ];
72 72
 		$params = [
73 73
 			'action' => 'query',
74 74
 			'list' => 'allpages',
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 	 * @param string $user
104 104
 	 * @param array $groups
105 105
 	 */
106
-	protected function createPage( string $title, string $user, array $groups ) {
106
+	protected function createPage ( string $title, string $user, array $groups ) {
107 107
 		$this->getLogger()->info( "Creating page $title" );
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
 
115 115
 		$params = [
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @param string $title
128 128
 	 * @param string $newText
129 129
 	 */
130
-	protected function createBasePage( string $title, string $newText ) {
130
+	protected function createBasePage ( string $title, string $newText ) {
131 131
 		$this->getLogger()->info( "Creating base page $title" );
132 132
 
133 133
 		$params = [
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @param string $title
145 145
 	 * @param string $newText
146 146
 	 */
147
-	protected function updateBasePage( string $title, string $newText ) {
147
+	protected function updateBasePage ( string $title, string $newText ) {
148 148
 		$this->getLogger()->info( "Updating base page $title" );
149 149
 
150 150
 		$params = [
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
 
@@ -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,17 +45,17 @@  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
 		$admins = $this->getDataProvider()->getUsersList();
51 51
 
52
-		$remove = [];
52
+		$remove = [ ];
53 53
 		foreach ( $pages as $page ) {
54 54
 			$user = $page->getUser();
55 55
 			if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) &&
56 56
 				$page->getOutcome() & PageRiconferma::OUTCOME_FAIL
57 57
 			) {
58
-				$remove[] = $user;
58
+				$remove[ ] = $user;
59 59
 			}
60 60
 		}
61 61
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @param PageRiconferma[] $pages
87 87
 	 */
88
-	protected function requestRemoval( array $pages ) {
88
+	protected function requestRemoval ( array $pages ) {
89 89
 		$this->getLogger()->info(
90 90
 			'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) )
91 91
 		);
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @param PageRiconferma[] $pages
126 126
 	 */
127
-	protected function updateAnnunci( array $pages ) {
127
+	protected function updateAnnunci ( array $pages ) {
128 128
 		$this->getLogger()->info( 'Updating annunci' );
129 129
 
130
-		$names = [];
130
+		$names = [ ];
131 131
 		$text = '';
132 132
 		foreach ( $pages as $page ) {
133 133
 			$user = $page->getUser();
134
-			$names[] = $user;
134
+			$names[ ] = $user;
135 135
 			$text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " .
136 136
 				"non è stato riconfermato [[WP:A|amministratore]].}}\n";
137 137
 		}
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @param PageRiconferma[] $pages
167 167
 	 */
168
-	protected function updateUltimeNotizie( array $pages ) {
168
+	protected function updateUltimeNotizie ( array $pages ) {
169 169
 		$this->getLogger()->info( 'Updating ultime notizie' );
170 170
 		$notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-page-title' ) );
171 171
 
172
-		$names = [];
172
+		$names = [ ];
173 173
 		$text = '';
174 174
 		foreach ( $pages as $page ) {
175 175
 			$user = $page->getUser();
176 176
 			$title = $page->getTitle();
177
-			$names[] = $user;
177
+			$names[ ] = $user;
178 178
 			$text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " .
179 179
 				'[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.';
180 180
 		}
Please login to merge, or discard this patch.
includes/Config.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme;
4 4
 
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 	/** @var self */
13 13
 	private static $instance;
14 14
 	/** @var array */
15
-	private $opts = [];
15
+	private $opts = [ ];
16 16
 
17 17
 	/**
18 18
 	 * Use self::init() and self::getInstance()
19 19
 	 */
20
-	private function __construct() {
20
+	private function __construct () {
21 21
 	}
22 22
 
23 23
 	/**
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
 	 * @param array $defaults
27 27
 	 * @throws ConfigException
28 28
 	 */
29
-	public static function init( array $defaults ) {
29
+	public static function init ( array $defaults ) {
30 30
 		if ( self::$instance ) {
31 31
 			throw new ConfigException( 'Config was already initialized' );
32 32
 		}
33 33
 
34 34
 		$inst = new self;
35
-		$inst->set( 'list-title', $defaults['list-title'] );
36
-		$inst->set( 'msg-title', $defaults['msg-title'] );
37
-		$inst->set( 'username', $defaults['username'] );
38
-		$inst->set( 'password', $defaults['password'] );
35
+		$inst->set( 'list-title', $defaults[ 'list-title' ] );
36
+		$inst->set( 'msg-title', $defaults[ 'msg-title' ] );
37
+		$inst->set( 'username', $defaults[ 'username' ] );
38
+		$inst->set( 'password', $defaults[ 'password' ] );
39 39
 		self::$instance = $inst;
40 40
 
41 41
 		// On-wiki values
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param string $key
55 55
 	 * @return string
56 56
 	 */
57
-	public function getWikiMessage( string $key ) : string {
57
+	public function getWikiMessage ( string $key ) : string {
58 58
 		static $messages = null;
59 59
 		if ( $messages === null ) {
60 60
 			try {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		if ( !isset( $messages[ $key ] ) ) {
68 68
 			throw new ConfigException( "Message '$key' does not exist." );
69 69
 		}
70
-		return $messages[$key];
70
+		return $messages[ $key ];
71 71
 	}
72 72
 	/**
73 73
 	 * Set a config value.
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @param string $key
76 76
 	 * @param mixed $value
77 77
 	 */
78
-	protected function set( string $key, $value ) {
78
+	protected function set ( string $key, $value ) {
79 79
 		$this->opts[ $key ] = $value;
80 80
 	}
81 81
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @return self
86 86
 	 * @throws ConfigException
87 87
 	 */
88
-	public static function getInstance() : self {
88
+	public static function getInstance () : self {
89 89
 		if ( !self::$instance ) {
90 90
 			throw new ConfigException( 'Config not yet initialized' );
91 91
 		}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @return mixed
100 100
 	 * @throws ConfigException
101 101
 	 */
102
-	public function get( string $opt ) {
102
+	public function get ( string $opt ) {
103 103
 		if ( !isset( $this->opts[ $opt ] ) ) {
104 104
 			throw new ConfigException( "Config option '$opt' not set." );
105 105
 		}
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' );
@@ -94,10 +92,10 @@  discard block
 block discarded – undo
94 92
 
95 93
 			$res = RequestBase::newFromParams( $params )->execute();
96 94
 			$pages = $res->query->pages;
97
-			$list = [];
95
+			$list = [ ];
98 96
 			foreach ( reset( $pages )->templates as $page ) {
99 97
 				if ( preg_match( "!$mainTitle\/[^\/]+\/\d!", $page->title ) ) {
100
-					$list[] = new PageRiconferma( $page->title );
98
+					$list[ ] = new PageRiconferma( $page->title );
101 99
 				}
102 100
 			}
103 101
 		}
@@ -110,14 +108,14 @@  discard block
 block discarded – undo
110 108
 	 *
111 109
 	 * @return PageRiconferma[]
112 110
 	 */
113
-	public function getPagesToClose() : array {
111
+	public function getPagesToClose () : array {
114 112
 		static $list = null;
115 113
 		if ( $list === null ) {
116 114
 			$allPages = $this->getOpenPages();
117
-			$list = [];
115
+			$list = [ ];
118 116
 			foreach ( $allPages as $page ) {
119 117
 				if ( time() > $page->getEndTimestamp() ) {
120
-					$list[] = $page;
118
+					$list[ ] = $page;
121 119
 				}
122 120
 			}
123 121
 		}
@@ -129,21 +127,21 @@  discard block
 block discarded – undo
129 127
 	 *
130 128
 	 * @param string $name
131 129
 	 */
132
-	public function removeUser( string $name ) {
130
+	public function removeUser ( string $name ) {
133 131
 		unset( $this->processUsers[ $name ] );
134 132
 	}
135 133
 
136 134
 	/**
137 135
 	 * @return PageRiconferma[]
138 136
 	 */
139
-	public function getCreatedPages() : array {
137
+	public function getCreatedPages () : array {
140 138
 		return $this->createdPages;
141 139
 	}
142 140
 
143 141
 	/**
144 142
 	 * @param PageRiconferma $page
145 143
 	 */
146
-	public function addCreatedPages( PageRiconferma $page ) {
147
-		$this->createdPages[] = $page;
144
+	public function addCreatedPages ( PageRiconferma $page ) {
145
+		$this->createdPages[ ] = $page;
148 146
 	}
149 147
 }
Please login to merge, or discard this patch.
includes/Message.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;
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,7 +39,7 @@  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
 		$reg = '!\{\{$plur|(?P<amount>\d+)|(?P<sing>[^}|]+)|(?P<plur>[^|}]+)}}!';
44 44
 
45 45
 		if ( preg_match( $reg, $this->value ) === 0 ) {
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		$this->value = preg_replace_callback(
49 49
 			$reg,
50 50
 			function ( $matches ) {
51
-				return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
51
+				return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
52 52
 			},
53 53
 			$this->value
54 54
 		);
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @param int $timestamp
61 61
 	 * @return string
62 62
 	 */
63
-	public static function getTimeWithArticle( int $timestamp ) : string {
63
+	public static function getTimeWithArticle ( int $timestamp ) : string {
64 64
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
65 65
 		$timeString = strftime( '%e %B alle %R', $timestamp );
66 66
 		// Remove the left space if day has a single digit
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
 	 * @return int
79 79
 	 * @todo Is there a better way?
80 80
 	 */
81
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
81
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
82 82
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
83 83
 		$bits = strptime( $timeString, '%e %m %Y alle %H:%M' );
84 84
 		$timestamp = mktime(
85
-			$bits['tm_hour'],
86
-			$bits['tm_min'],
85
+			$bits[ 'tm_hour' ],
86
+			$bits[ 'tm_min' ],
87 87
 			0,
88
-			$bits['tm_mon'] + 1,
89
-			$bits['tm_mday'],
90
-			$bits['tm_year'] + 1900
88
+			$bits[ 'tm_mon' ] + 1,
89
+			$bits[ 'tm_mday' ],
90
+			$bits[ 'tm_year' ] + 1900
91 91
 		);
92 92
 		setlocale( LC_TIME, $oldLoc );
93 93
 
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	 * @param string $emptyText
103 103
 	 * @return string
104 104
 	 */
105
-	public static function commaList( array $data, string $emptyText = 'nessuno' ) : string {
105
+	public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string {
106 106
 		if ( count( $data ) > 1 ) {
107 107
 			$last = array_pop( $data );
108 108
 			$ret = implode( ', ', $data ) . " e $last";
109 109
 		} elseif ( $data ) {
110
-			$ret = $data[0];
110
+			$ret = $data[ 0 ];
111 111
 		} else {
112 112
 			$ret = $emptyText;
113 113
 		}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		return $ret;
116 116
 	}
117 117
 
118
-	public function __toString() {
118
+	public function __toString () {
119 119
 		return $this->text();
120 120
 	}
121 121
 }
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 (bool)preg_match( $regex, $this->getContent() );
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 ) === 0 ) {
91 91
 			throw new \Exception( 'The content does not match the given regex' );
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.