Passed
Push — master ( 853cce...2ef02f )
by Daimona
01:54
created
includes/Message.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
 
@@ -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
 
Please login to merge, or discard this patch.
includes/Task/StartVote.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;
4 4
 
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	protected function getSubtasksMap(): array {
18
+	protected function getSubtasksMap (): array {
19 19
 		// Everything is done here.
20
-		return [];
20
+		return [ ];
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @inheritDoc
25 25
 	 */
26
-	public function run() : TaskResult {
26
+	public function run () : TaskResult {
27 27
 		$this->getLogger()->info( 'Starting task StartVote' );
28 28
 
29 29
 		$pages = $this->getDataProvider()->getOpenPages();
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	/**
42 42
 	 * @param PageRiconferma[] $pages
43 43
 	 */
44
-	protected function processPages( array $pages ) {
45
-		$actualPages = [];
44
+	protected function processPages ( array $pages ) {
45
+		$actualPages = [ ];
46 46
 		foreach ( $pages as $page ) {
47 47
 			if ( $page->hasOpposition() && !$page->isVote() ) {
48 48
 				$this->openVote( $page );
49
-				$actualPages[] = $page;
49
+				$actualPages[ ] = $page;
50 50
 			}
51 51
 		}
52 52
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @param PageRiconferma $page
65 65
 	 */
66
-	protected function openVote( PageRiconferma $page ) {
66
+	protected function openVote ( PageRiconferma $page ) {
67 67
 		$this->getLogger()->info( "Starting vote on $page" );
68 68
 
69 69
 		$content = $page->getContent();
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
 	 * @see SimpleUpdates::updateVote()
103 103
 	 * @see UpdatesAround::addVote()
104 104
 	 */
105
-	protected function updateVotePage( array $pages ) {
105
+	protected function updateVotePage ( array $pages ) {
106 106
 		$votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) );
107 107
 		$content = $votePage->getContent();
108 108
 
109
-		$titles = [];
109
+		$titles = [ ];
110 110
 		foreach ( $pages as $page ) {
111
-			$titles[] = preg_quote( $page->getTitle() );
111
+			$titles[ ] = preg_quote( $page->getTitle() );
112 112
 		}
113 113
 		$titleReg = implode( '|', $titles );
114 114
 		$search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!gm";
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 );
132 132
 		} else {
133 133
 			// Start section
134
-			$matches = [];
134
+			$matches = [ ];
135 135
 			if ( preg_match( $introReg, $newContent, $matches ) === false ) {
136 136
 				throw new TaskException( 'Intro not found in vote page' );
137 137
 			}
138 138
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
139 139
 			// Replace semicolon with full stop
140 140
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
141
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 );
141
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 );
142 142
 		}
143 143
 
144 144
 		$summary = $this->msg( 'vote-start-vote-page-summary' )
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @see UpdatesAround::addNews()
161 161
 	 * @see SimpleUpdates::updateNews()
162 162
 	 */
163
-	protected function updateNews( int $amount ) {
163
+	protected function updateNews ( int $amount ) {
164 164
 		$this->getLogger()->info( "Turning $amount pages into votes" );
165 165
 		$newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) );
166 166
 
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 			throw new TaskException( 'Param "voto" not found in news page' );
176 176
 		}
177 177
 
178
-		$newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: '';
179
-		$newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: '';
178
+		$newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: '';
179
+		$newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: '';
180 180
 
181 181
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
182 182
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
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.