Passed
Push — master ( 10aa7b...8214a5 )
by Daimona
01:42
created
includes/Request/NativeRequest.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\Request;
4 4
 
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	/**
10 10
 	 * @inheritDoc
11 11
 	 */
12
-	protected function reallyMakeRequest( string $params ) : string {
12
+	protected function reallyMakeRequest ( string $params ) : string {
13 13
 		$context = [
14 14
 			'http' => [
15 15
 				'method' => $this->method,
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 		];
19 19
 		$url = $this->url;
20 20
 		if ( $this->method === 'POST' ) {
21
-			$context['http']['content'] = $params;
21
+			$context[ 'http' ][ 'content' ] = $params;
22 22
 		} else {
23 23
 			$url = "$url?$params";
24 24
 		}
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 
28 28
 		foreach ( $http_response_header as $header ) {
29 29
 			$bits = explode( ':', $header, 2 );
30
-			if ( trim( $bits[0] ) === 'Set-Cookie' ) {
31
-				$this->newCookies[] = $bits[1];
30
+			if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) {
31
+				$this->newCookies[ ] = $bits[ 1 ];
32 32
 			}
33 33
 		}
34 34
 
Please login to merge, or discard this patch.
includes/Task/CloseOld.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
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	public function runInternal() : int {
18
+	public function runInternal () : int {
19 19
 		$orderedList = [
20 20
 			'close-pages',
21 21
 			'archive-pages',
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * @inheritDoc
36 36
 	 */
37
-	protected function getSubtasksMap(): array {
37
+	protected function getSubtasksMap (): array {
38 38
 		return [
39 39
 			'archive-pages' => ArchivePages::class,
40 40
 			'close-pages' => ClosePages::class,
Please login to merge, or discard this patch.
includes/Task/UpdateList.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;
4 4
 
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
 	/**
19 19
 	 * @inheritDoc
20 20
 	 */
21
-	protected function getSubtasksMap(): array {
21
+	protected function getSubtasksMap (): array {
22 22
 		// Everything is done here.
23
-		return [];
23
+		return [ ];
24 24
 	}
25 25
 
26 26
 	/**
27 27
 	 * @inheritDoc
28 28
 	 */
29
-	public function runInternal() : int {
29
+	public function runInternal () : int {
30 30
 		$this->actualList = $this->getActualAdmins();
31 31
 		$this->botList = $this->getDataProvider()->getUsersList();
32 32
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	/**
56 56
 	 * @return array
57 57
 	 */
58
-	protected function getActualAdmins() : array {
58
+	protected function getActualAdmins () : array {
59 59
 		$this->getLogger()->debug( 'Retrieving admins - API' );
60 60
 		$params = [
61 61
 			'action' => 'query',
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @param \stdClass $data
74 74
 	 * @return array
75 75
 	 */
76
-	protected function extractAdmins( \stdClass $data ) : array {
77
-		$ret = [];
76
+	protected function extractAdmins ( \stdClass $data ) : array {
77
+		$ret = [ ];
78 78
 		$blacklist = $this->getConfig()->get( 'exclude-admins' );
79 79
 		foreach ( $data->query->allusers as $u ) {
80 80
 			if ( in_array( $u->name, $blacklist ) ) {
@@ -91,22 +91,22 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @return array[]
93 93
 	 */
94
-	protected function getMissingGroups() : array {
95
-		$missing = [];
94
+	protected function getMissingGroups () : array {
95
+		$missing = [ ];
96 96
 		foreach ( $this->actualList as $adm => $groups ) {
97
-			$groupsList = [];
97
+			$groupsList = [ ];
98 98
 			if ( !isset( $this->botList[ $adm ] ) ) {
99 99
 				$groupsList = $groups;
100
-			} elseif ( count( $groups ) > count( $this->botList[$adm] ) ) {
100
+			} elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) {
101 101
 				// Only some groups are missing
102
-				$groupsList = array_diff_key( $groups, $this->botList[$adm] );
102
+				$groupsList = array_diff_key( $groups, $this->botList[ $adm ] );
103 103
 			}
104 104
 
105 105
 			foreach ( $groupsList as $group ) {
106 106
 				try {
107 107
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
108 108
 				} catch ( TaskException $e ) {
109
-					$this->errors[] = $e->getMessage();
109
+					$this->errors[ ] = $e->getMessage();
110 110
 				}
111 111
 			}
112 112
 		}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @return string
122 122
 	 * @throws TaskException
123 123
 	 */
124
-	protected function getFlagDate( string $admin, string $group ) : string {
124
+	protected function getFlagDate ( string $admin, string $group ) : string {
125 125
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
126 126
 
127 127
 		$url = DEFAULT_URL;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param string $group
157 157
 	 * @return string|null
158 158
 	 */
159
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
159
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
160 160
 		$ts = null;
161 161
 		foreach ( $data->query->logevents as $entry ) {
162 162
 			if ( !isset( $entry->params ) ) {
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 * @return array[]
180 180
 	 */
181
-	protected function getExtraGroups() : array {
182
-		$extra = [];
181
+	protected function getExtraGroups () : array {
182
+		$extra = [ ];
183 183
 		foreach ( $this->botList as $name => $groups ) {
184 184
 			if ( !isset( $this->actualList[ $name ] ) ) {
185 185
 				$extra[ $name ] = $groups;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param array[] $extra
198 198
 	 * @return array[]
199 199
 	 */
200
-	protected function getNewContent( array $missing, array $extra ) : array {
200
+	protected function getNewContent ( array $missing, array $extra ) : array {
201 201
 		$newContent = $this->botList;
202 202
 		foreach ( $newContent as $user => $groups ) {
203 203
 			if ( isset( $missing[ $user ] ) ) {
Please login to merge, or discard this patch.
includes/TaskResult.php 1 patch
Spacing   +9 added lines, -9 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
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param int $status One of the Task::STATUS_* constants
22 22
 	 * @param string[] $errors
23 23
 	 */
24
-	public function __construct( int $status, array $errors = [] ) {
24
+	public function __construct ( int $status, array $errors = [ ] ) {
25 25
 		$this->status = $status;
26 26
 		$this->errors = $errors;
27 27
 	}
@@ -29,21 +29,21 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * @return int
31 31
 	 */
32
-	public function getStatus() : int {
32
+	public function getStatus () : int {
33 33
 		return $this->status;
34 34
 	}
35 35
 
36 36
 	/**
37 37
 	 * @return string[]
38 38
 	 */
39
-	public function getErrors() {
39
+	public function getErrors () {
40 40
 		return $this->errors;
41 41
 	}
42 42
 
43 43
 	/**
44 44
 	 * @param TaskResult $that
45 45
 	 */
46
-	public function merge( TaskResult $that ) {
46
+	public function merge ( TaskResult $that ) {
47 47
 		$this->status |= $that->status;
48 48
 		$this->errors = array_merge( $this->errors, $that->errors );
49 49
 	}
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * @return string
53 53
 	 */
54
-	public function __toString() {
54
+	public function __toString () {
55 55
 		if ( $this->isOK() ) {
56 56
 			$stat = 'OK';
57 57
 			$errs = "\tNo errors.";
58 58
 		} else {
59 59
 			$stat = 'ERROR';
60
-			$formattedErrs = [];
60
+			$formattedErrs = [ ];
61 61
 			foreach ( $this->errors as $err ) {
62
-				$formattedErrs[] = "\t - $err";
62
+				$formattedErrs[ ] = "\t - $err";
63 63
 			}
64 64
 			$errs = implode( "\n", $formattedErrs );
65 65
 		}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return bool
73 73
 	 */
74
-	public function isOK() : bool {
74
+	public function isOK () : bool {
75 75
 		return ( $this->status | self::STATUS_GOOD ) === self::STATUS_GOOD;
76 76
 	}
77 77
 }
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
 			'updates-around',
@@ -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
 			'updates-around' => UpdatesAround::class,
Please login to merge, or discard this patch.
includes/Exception/MissingSectionException.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\Exception;
4 4
 
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 	 * @param string $title
11 11
 	 * @param int|string $section Number or title
12 12
 	 */
13
-	public function __construct( string $title = '[unavailable]', $section = '[unavailable]' ) {
13
+	public function __construct ( string $title = '[unavailable]', $section = '[unavailable]' ) {
14 14
 		parent::__construct( "The section $section in the page $title doesn't exist." );
15 15
 	}
16 16
 }
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
 
@@ -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/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.