Passed
Push — master ( 74427d...0c2c3a )
by Daimona
01:32
created
includes/Task/Subtask/Subtask.php 1 patch
Spacing   +2 added lines, -2 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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @inheritDoc
13 13
 	 */
14
-	final public function getOperationName(): string {
14
+	final public function getOperationName (): string {
15 15
 		return 'subtask';
16 16
 	}
17 17
 }
Please login to merge, or discard this patch.
includes/Task/Subtask/UserNotice.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task\Subtask;
4 4
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @inheritDoc
13 13
 	 */
14
-	public function runInternal() : int {
14
+	public function runInternal () : int {
15 15
 		$pages = $this->getDataProvider()->getCreatedPages();
16 16
 		$users = $this->getDataProvider()->getUsersToProcess();
17 17
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 			return TaskResult::STATUS_NOTHING;
20 20
 		}
21 21
 
22
-		$ricNums = [];
22
+		$ricNums = [ ];
23 23
 		foreach ( $pages as $page ) {
24 24
 			$ricNums[ $page->getUser()->getName() ] = $page->getNum();
25 25
 		}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param string $user
38 38
 	 * @param int $ricNum
39 39
 	 */
40
-	protected function addMsg( string $user, int $ricNum ) {
40
+	protected function addMsg ( string $user, int $ricNum ) {
41 41
 		$this->getLogger()->info( "Leaving msg to $user" );
42 42
 		$msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text();
43 43
 
Please login to merge, or discard this patch.
includes/Exception/PermissionDeniedException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Exception;
4 4
 
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->getOpt( 'main-page-title' ), 2 )[1];
71
+		$unprefixedTitle = explode( ':', $this->getOpt( '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/StartNew.php 1 patch
Spacing   +3 added lines, -3 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,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
 		$orderedList = [
19 19
 			'create-pages',
20 20
 			'open-updates',
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @inheritDoc
34 34
 	 */
35
-	protected function getSubtasksMap() : array {
35
+	protected function getSubtasksMap () : array {
36 36
 		return [
37 37
 			'create-pages' => CreatePages::class,
38 38
 			'open-updates' => OpenUpdates::class,
Please login to merge, or discard this patch.
includes/Task/Subtask/ArchivePages.php 1 patch
Spacing   +14 added lines, -14 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 ) {
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
 	 * @param PageRiconferma[] $pages
33 33
 	 * @see OpenUpdates::addToMainPage()
34 34
 	 */
35
-	protected function removeFromMainPage( array $pages ) {
35
+	protected function removeFromMainPage ( array $pages ) {
36 36
 		$this->getLogger()->info(
37 37
 			'Removing from main: ' . implode( ', ', $pages )
38 38
 		);
39 39
 
40 40
 		$mainPage = $this->getPage( $this->getOpt( 'main-page-title' ) );
41
-		$remove = [];
41
+		$remove = [ ];
42 42
 		foreach ( $pages as $page ) {
43 43
 			// Order matters here. It's not guaranteed that there'll be a newline, but avoid
44 44
 			// regexps for that single character.
45
-			$remove[] = '{{' . $page->getTitle() . "}}\n";
46
-			$remove[] = '{{' . $page->getTitle() . '}}';
45
+			$remove[ ] = '{{' . $page->getTitle() . "}}\n";
46
+			$remove[ ] = '{{' . $page->getTitle() . '}}';
47 47
 		}
48 48
 
49 49
 		$newContent = str_replace( $remove, '', $mainPage->getContent() );
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param PageRiconferma[] $pages
74 74
 	 */
75
-	protected function addToArchive( array $pages ) {
75
+	protected function addToArchive ( array $pages ) {
76 76
 		$this->getLogger()->info(
77 77
 			'Adding to archive: ' . implode( ', ', $pages )
78 78
 		);
79 79
 
80
-		$simple = $votes = [];
80
+		$simple = $votes = [ ];
81 81
 		foreach ( $pages as $page ) {
82 82
 			if ( $page->isVote() ) {
83
-				$votes[] = $page;
83
+				$votes[ ] = $page;
84 84
 			} else {
85
-				$simple[] = $page;
85
+				$simple[ ] = $page;
86 86
 			}
87 87
 		}
88 88
 
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
 	 * @param string $archiveTitle
104 104
 	 * @param array $pages
105 105
 	 */
106
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) {
106
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) {
107 107
 		$archivePage = $this->getPage( "$archiveTitle/" . date( 'Y' ) );
108 108
 		$exists = $archivePage->exists();
109 109
 
110 110
 		$append = "\n";
111
-		$archivedList = [];
111
+		$archivedList = [ ];
112 112
 		foreach ( $pages as $page ) {
113 113
 			$append .= '{{' . $page->getTitle() . "}}\n";
114
-			$archivedList[] = $page->getUserNum();
114
+			$archivedList[ ] = $page->getUserNum();
115 115
 		}
116 116
 
117 117
 		$summary = $this->msg( 'close-archive-summary' )
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @param string $archiveTitle
134 134
 	 */
135
-	private function addArchiveYear( string $archiveTitle ) {
135
+	private function addArchiveYear ( string $archiveTitle ) {
136 136
 		$page = $this->getPage( $archiveTitle );
137 137
 		$year = date( 'Y' );
138 138
 
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 ) {
38
+	protected function addVoteCloseText ( PageRiconferma $page ) {
39 39
 		$content = $page->getContent();
40 40
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!';
41 41
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -50,15 +50,14 @@  discard block
 block discarded – undo
50 50
 	 * @param PageRiconferma $page
51 51
 	 * @see CreatePages::updateBasePage()
52 52
 	 */
53
-	protected function updateBasePage( PageRiconferma $page ) {
53
+	protected function updateBasePage ( PageRiconferma $page ) {
54 54
 		$this->getLogger()->info( "Updating base page for $page" );
55 55
 
56 56
 		$basePage = $this->getPage( $page->getBaseTitle() );
57 57
 		$current = $basePage->getContent();
58 58
 
59 59
 		$outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ?
60
-			'non riconfermato' :
61
-			'riconfermato';
60
+			'non riconfermato' : 'riconfermato';
62 61
 		$text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita';
63 62
 
64 63
 		$newContent = str_replace( 'riconferma in corso', $text, $current );
Please login to merge, or discard this patch.
includes/Task/StartVote.php 1 patch
Spacing   +14 added lines, -14 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,12 +36,12 @@  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
-				$donePages[] = $page;
44
+				$donePages[ ] = $page;
45 45
 			}
46 46
 		}
47 47
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @param PageRiconferma $page
61 61
 	 */
62
-	protected function openVote( PageRiconferma $page ) {
62
+	protected function openVote ( PageRiconferma $page ) {
63 63
 		$this->getLogger()->info( "Starting vote on $page" );
64 64
 
65 65
 		$content = $page->getContent();
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
 	 * @see SimpleUpdates::updateVotazioni()
99 99
 	 * @see OpenUpdates::addToVotazioni()
100 100
 	 */
101
-	protected function updateVotazioni( array $pages ) {
101
+	protected function updateVotazioni ( array $pages ) {
102 102
 		$votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) );
103 103
 
104
-		$users = [];
104
+		$users = [ ];
105 105
 		foreach ( $pages as $page ) {
106
-			$users[] = $page->getUser();
106
+			$users[ ] = $page->getUser();
107 107
 		}
108 108
 		$usersReg = Element::regexFromArray( $users );
109 109
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @see SimpleUpdates::updateNews()
142 142
 	 * @see OpenUpdates::addToNews()
143 143
 	 */
144
-	protected function updateNews( int $amount ) {
144
+	protected function updateNews ( int $amount ) {
145 145
 		$this->getLogger()->info( "Turning $amount pages into votes" );
146 146
 		$newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) );
147 147
 
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 			throw new TaskException( 'Param "voto" not found in news page' );
157 157
 		}
158 158
 
159
-		$newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: '';
160
-		$newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: '';
159
+		$newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: '';
160
+		$newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: '';
161 161
 
162 162
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
163 163
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/Message.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;
4 4
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	/**
27 27
 	 * @param string $key
28 28
 	 */
29
-	public function __construct( string $key ) {
29
+	public function __construct ( string $key ) {
30 30
 		$this->value = Config::getInstance()->getWikiMessage( $key );
31 31
 	}
32 32
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param array $args
35 35
 	 * @return self
36 36
 	 */
37
-	public function params( array $args ) : self {
37
+	public function params ( array $args ) : self {
38 38
 		$this->value = strtr( $this->value, $args );
39 39
 		return $this;
40 40
 	}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	/**
43 43
 	 * @return string
44 44
 	 */
45
-	public function text() : string {
45
+	public function text () : string {
46 46
 		$this->parsePlurals();
47 47
 		return $this->value;
48 48
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * Replace {{$plur|<amount>|sing|plur}}
52 52
 	 */
53
-	protected function parsePlurals() {
53
+	protected function parsePlurals () {
54 54
 		$reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!';
55 55
 
56 56
 		if ( preg_match( $reg, $this->value ) === 0 ) {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$this->value = preg_replace_callback(
60 60
 			$reg,
61 61
 			function ( $matches ) {
62
-				return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
62
+				return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
63 63
 			},
64 64
 			$this->value
65 65
 		);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @suppress PhanUnreferencedPublicMethod
74 74
 	 * @fixme Is this necessary?
75 75
 	 */
76
-	public static function getTimeWithArticle( int $timestamp ) : string {
76
+	public static function getTimeWithArticle ( int $timestamp ) : string {
77 77
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
78 78
 		$timeString = strftime( '%e %B alle %R', $timestamp );
79 79
 		// Remove the left space if day has a single digit
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param string $timeString Full format, e.g. "15 aprile 2019 18:27"
91 91
 	 * @return int
92 92
 	 */
93
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
93
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
94 94
 		$englishTime = str_ireplace(
95 95
 			array_values( self::MONTHS ),
96 96
 			array_keys( self::MONTHS ),
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 	 * @param string $emptyText
109 109
 	 * @return string
110 110
 	 */
111
-	public static function commaList( array $data, string $emptyText = 'nessuno' ) : string {
111
+	public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string {
112 112
 		if ( count( $data ) > 1 ) {
113 113
 			$last = array_pop( $data );
114 114
 			$ret = implode( ', ', $data ) . " e $last";
115 115
 		} elseif ( $data ) {
116
-			$ret = (string)$data[0];
116
+			$ret = (string)$data[ 0 ];
117 117
 		} else {
118 118
 			$ret = $emptyText;
119 119
 		}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		return $ret;
122 122
 	}
123 123
 
124
-	public function __toString() {
124
+	public function __toString () {
125 125
 		return $this->text();
126 126
 	}
127 127
 }
Please login to merge, or discard this patch.