Passed
Push — master ( 6f44ea...591692 )
by Daimona
01:45
created
includes/Task/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;
4 4
 
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @inheritDoc
13 13
 	 */
14
-	public function run() : TaskResult {
14
+	public function run () : TaskResult {
15 15
 		$this->getLogger()->info( 'Starting task UserNotice' );
16 16
 
17 17
 		$pages = $this->getDataProvider()->getCreatedPages();
18 18
 		$users = $this->getDataProvider()->getUsersToProcess();
19 19
 		if ( $pages && $users ) {
20
-			$ricNums = [];
20
+			$ricNums = [ ];
21 21
 			foreach ( $pages as $page ) {
22 22
 				$ricNums[ $page->getUser() ] = $page->getNum();
23 23
 			}
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param string $user
40 40
 	 * @param int $ricNum
41 41
 	 */
42
-	protected function addMsg( string $user, int $ricNum ) {
42
+	protected function addMsg ( string $user, int $ricNum ) {
43 43
 		$this->getLogger()->info( "Leaving msg to $user" );
44 44
 		$msg = str_replace( '$num', "$ricNum", $this->getConfig()->get( 'user-notice-msg' ) );
45 45
 
Please login to merge, or discard this patch.
includes/Task/UpdatesAround.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;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function run() : TaskResult {
17
+	public function run () : TaskResult {
18 18
 		$this->getLogger()->info( 'Starting task UpdatesAround' );
19 19
 
20 20
 		$pages = $this->getDataProvider()->getCreatedPages();
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param PageRiconferma[] $pages
40 40
 	 */
41
-	protected function addToMainPage( array $pages ) {
41
+	protected function addToMainPage ( array $pages ) {
42 42
 		$this->getLogger()->info(
43 43
 			'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) )
44 44
 		);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		$summary = preg_replace_callback(
56 56
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
57 57
 			function ( $matches ) {
58
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
58
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
59 59
 			},
60 60
 			$summary
61 61
 		);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @param PageRiconferma[] $pages
76 76
 	 */
77
-	protected function addVote( array $pages ) {
77
+	protected function addVote ( array $pages ) {
78 78
 		$this->getLogger()->info(
79 79
 			'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) )
80 80
 		);
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 );
95 95
 		} else {
96 96
 			// Start section
97
-			$matches = [];
97
+			$matches = [ ];
98 98
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
99 99
 				throw new TaskException( 'Intro not found in vote page' );
100 100
 			}
101 101
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
102 102
 			// Replace semicolon with full stop
103 103
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
104
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 );
104
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 );
105 105
 		}
106 106
 
107 107
 		$summary = strtr(
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$summary = preg_replace_callback(
112 112
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
113 113
 			function ( $matches ) {
114
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
114
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
115 115
 			},
116 116
 			$summary
117 117
 		);
@@ -130,26 +130,26 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @param int $amount
132 132
 	 */
133
-	protected function addNews( int $amount ) {
133
+	protected function addNews ( int $amount ) {
134 134
 		$this->getLogger()->info( "Increasing the news counter by $amount" );
135 135
 		$newsPage = $this->getConfig()->get( 'ric-news-page' );
136 136
 
137 137
 		$content = $this->getController()->getPageContent( $newsPage );
138 138
 		$reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
139 139
 
140
-		$matches = [];
140
+		$matches = [ ];
141 141
 		if ( preg_match( $reg, $content, $matches ) === false ) {
142 142
 			throw new TaskException( 'Param not found in news page' );
143 143
 		}
144 144
 
145
-		$newNum = (int)$matches[2] + $amount;
145
+		$newNum = (int)$matches[ 2 ] + $amount;
146 146
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
147 147
 
148 148
 		$summary = strtr( $this->getConfig()->get( 'ric-news-page-summary' ), [ '$num' => $amount ] );
149 149
 		$summary = preg_replace_callback(
150 150
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
151 151
 			function ( $matches ) {
152
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
152
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
153 153
 			},
154 154
 			$summary
155 155
 		);
Please login to merge, or discard this patch.
includes/PageRiconferma.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
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @param string $title
20 20
 	 * @param WikiController $controller
21 21
 	 */
22
-	public function __construct( string $title, WikiController $controller ) {
22
+	public function __construct ( string $title, WikiController $controller ) {
23 23
 		$this->title = $title;
24 24
 		$this->controller = $controller;
25 25
 	}
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @return string
29 29
 	 */
30
-	public function getTitle() : string {
30
+	public function getTitle () : string {
31 31
 		return $this->title;
32 32
 	}
33 33
 
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return string
38 38
 	 */
39
-	public function getUser() : string {
40
-		return explode( '/', $this->title )[2];
39
+	public function getUser () : string {
40
+		return explode( '/', $this->title )[ 2 ];
41 41
 	}
42 42
 
43 43
 	/**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @return int
47 47
 	 */
48
-	public function getNum() : int {
48
+	public function getNum () : int {
49 49
 		$bits = explode( '/', $this->getTitle() );
50 50
 		return end( $bits );
51 51
 	}
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return string
57 57
 	 */
58
-	public function getUserNum() : string {
59
-		return explode( '/', $this->getTitle(), 3 )[2];
58
+	public function getUserNum () : string {
59
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
60 60
 	}
61 61
 
62 62
 	/**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string
66 66
 	 */
67
-	public function getBaseTitle() : string {
67
+	public function getBaseTitle () : string {
68 68
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
69 69
 	}
70 70
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return string
75 75
 	 */
76
-	public function getContent() : string {
76
+	public function getContent () : string {
77 77
 		if ( $this->content === null ) {
78 78
 			$this->content = $this->controller->getPageContent( $this->title );
79 79
 		}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return bool
87 87
 	 */
88
-	public function hasOpposition() : bool {
88
+	public function hasOpposition () : bool {
89 89
 		$params = [
90 90
 			'action' => 'query',
91 91
 			'prop' => 'revisions',
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		];
97 97
 		$res = RequestBase::newFromParams( $params )->execute();
98 98
 		$page = reset( $res->query->pages );
99
-		$content = $page->revisions[0]->slots->main->{ '*' };
99
+		$content = $page->revisions[ 0 ]->slots->main->{ '*' };
100 100
 		// Let's hope that this is good enough...
101 101
 		$votes = substr_count( $content, "\n\# *(?![#*])" );
102 102
 		return $votes >= 15;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return bool
109 109
 	 */
110
-	public function isVote() : bool {
110
+	public function isVote () : bool {
111 111
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
112 112
 		return preg_match( $sectionReg, $this->getContent() ) === false;
113 113
 	}
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @return int
119 119
 	 */
120
-	public function getEndTimestamp() : int {
120
+	public function getEndTimestamp () : int {
121 121
 		if ( $this->isVote() ) {
122
-			$matches = [];
122
+			$matches = [ ];
123 123
 			$reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!";
124 124
 			preg_match( $reg, $this->getContent(), $matches );
125 125
 			list( , $day, $hours ) = $matches;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		}
132 132
 	}
133 133
 
134
-	public function __toString() {
134
+	public function __toString () {
135 135
 		return $this->getTitle();
136 136
 	}
137 137
 }
Please login to merge, or discard this patch.
includes/TaskDataProvider.php 1 patch
Spacing   +14 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
 
@@ -12,20 +12,20 @@  discard block
 block discarded – undo
12 12
 	private $users;
13 13
 
14 14
 	/** @var PageRiconferma[] */
15
-	private $createdPages = [];
15
+	private $createdPages = [ ];
16 16
 
17 17
 	/**
18 18
 	 * Get a list of users to execute tasks on.
19 19
 	 *
20 20
 	 * @return array[]
21 21
 	 */
22
-	public function getUsersToProcess() : array {
22
+	public function getUsersToProcess () : array {
23 23
 		if ( $this->users === null ) {
24 24
 			$this->getLogger()->debug( 'Retrieving users list' );
25 25
 			$content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) );
26 26
 			$listUsers = json_decode( $content, true );
27 27
 
28
-			$this->users = [];
28
+			$this->users = [ ];
29 29
 			foreach ( $listUsers as $user => $groups ) {
30 30
 				$timestamp = $this->getValidTimestamp( $groups );
31 31
 
@@ -47,13 +47,11 @@  discard block
 block discarded – undo
47 47
 	 * @param array $groups
48 48
 	 * @return int
49 49
 	 */
50
-	private function getValidTimestamp( array $groups ) : int {
50
+	private function getValidTimestamp ( array $groups ) : int {
51 51
 		$checkuser = isset( $groups[ 'checkuser' ] ) ?
52
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() :
53
-			0;
52
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
54 53
 		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
55
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() :
56
-			0;
54
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
57 55
 
58 56
 		$timestamp = max( $bureaucrat, $checkuser );
59 57
 		if ( $timestamp === 0 ) {
@@ -67,7 +65,7 @@  discard block
 block discarded – undo
67 65
 	 *
68 66
 	 * @return PageRiconferma[]
69 67
 	 */
70
-	public function getOpenPages() : array {
68
+	public function getOpenPages () : array {
71 69
 		$baseTitle = $this->getConfig()->get( 'ric-main-page' );
72 70
 		$params = [
73 71
 			'action' => 'query',
@@ -79,10 +77,10 @@  discard block
 block discarded – undo
79 77
 
80 78
 		$res = RequestBase::newFromParams( $params )->execute();
81 79
 		$pages = $res->query->pages;
82
-		$ret = [];
80
+		$ret = [ ];
83 81
 		foreach ( reset( $pages )->templates as $page ) {
84 82
 			if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) {
85
-				$ret[] = new PageRiconferma( $page->title, $this->getController() );
83
+				$ret[ ] = new PageRiconferma( $page->title, $this->getController() );
86 84
 			}
87 85
 		}
88 86
 		return $ret;
@@ -93,21 +91,21 @@  discard block
 block discarded – undo
93 91
 	 *
94 92
 	 * @param string $name
95 93
 	 */
96
-	public function removeUser( string $name ) {
94
+	public function removeUser ( string $name ) {
97 95
 		unset( $this->users[ $name ] );
98 96
 	}
99 97
 
100 98
 	/**
101 99
 	 * @return PageRiconferma[]
102 100
 	 */
103
-	public function getCreatedPages() : array {
101
+	public function getCreatedPages () : array {
104 102
 		return $this->createdPages;
105 103
 	}
106 104
 
107 105
 	/**
108 106
 	 * @param PageRiconferma $page
109 107
 	 */
110
-	public function addCreatedPages( PageRiconferma $page ) {
111
-		$this->createdPages[] = $page;
108
+	public function addCreatedPages ( PageRiconferma $page ) {
109
+		$this->createdPages[ ] = $page;
112 110
 	}
113 111
 }
Please login to merge, or discard this patch.