Passed
Push — master ( a1b33e...10aa7b )
by Daimona
01:45
created
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/Bot.php 1 patch
Spacing   +6 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;
4 4
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 	const VERSION = 1.0;
13 13
 
14
-	public function __construct() {
14
+	public function __construct () {
15 15
 		$this->logger = new Logger;
16 16
 	}
17 17
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param string $mode
22 22
 	 * @param string|null $name
23 23
 	 */
24
-	private function run( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) {
24
+	private function run ( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) {
25 25
 		$activity = $mode === TaskManager::MODE_COMPLETE ? TaskManager::MODE_COMPLETE : "$mode $name";
26 26
 		$this->logger->info( "Starting $activity" );
27 27
 		$manager = new TaskManager;
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * Entry point for the whole process
39 39
 	 */
40
-	public function runAll() {
40
+	public function runAll () {
41 41
 		$this->run();
42 42
 	}
43 43
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @param string $task
48 48
 	 */
49
-	public function runTask( string $task ) {
49
+	public function runTask ( string $task ) {
50 50
 		$this->run( TaskManager::MODE_TASK, $task );
51 51
 	}
52 52
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param string $subtask
57 57
 	 */
58
-	public function runSubtask( string $subtask ) {
58
+	public function runSubtask ( string $subtask ) {
59 59
 		$this->run( TaskManager::MODE_SUBTASK, $subtask );
60 60
 	}
61 61
 }
Please login to merge, or discard this patch.
includes/TaskManager.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
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK
55 55
 	 * @return TaskResult
56 56
 	 */
57
-	public function run( string $mode, string $name = null ) : TaskResult {
57
+	public function run ( string $mode, string $name = null ) : TaskResult {
58 58
 		$this->provider = new TaskDataProvider;
59 59
 
60 60
 		if ( $mode === self::MODE_COMPLETE ) {
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return TaskResult
73 73
 	 */
74
-	protected function runAllTasks() : TaskResult {
74
+	protected function runAllTasks () : TaskResult {
75 75
 		if ( self::getLastFullRunDate() === date( 'd/m/Y' ) ) {
76 76
 			// Really avoid executing twice the same day
77 77
 			return new TaskResult( TaskResult::STATUS_ERROR, [ 'A full run was already executed today.' ] );
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param string $name
103 103
 	 * @return TaskResult
104 104
 	 */
105
-	protected function runTask( string $name ) : TaskResult {
105
+	protected function runTask ( string $name ) : TaskResult {
106 106
 		if ( !isset( self::TASKS_MAP[ $name ] ) ) {
107 107
 			throw new \InvalidArgumentException( "'$name' is not a valid task." );
108 108
 		}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param string $name
118 118
 	 * @return TaskResult
119 119
 	 */
120
-	protected function runSubtask( string $name ) : TaskResult {
120
+	protected function runSubtask ( string $name ) : TaskResult {
121 121
 		if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) {
122 122
 			throw new \InvalidArgumentException( "'$name' is not a valid subtask." );
123 123
 		}
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @return string|null d/m/Y or null if no last run registered
132 132
 	 * @fixme Is this even necessary?
133 133
 	 */
134
-	public static function getLastFullRunDate() : ?string {
134
+	public static function getLastFullRunDate () : ?string {
135 135
 		if ( file_exists( self::LOG_FILE ) ) {
136 136
 			return file_get_contents( self::LOG_FILE ) ?: null;
137 137
 		} else {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param string $class
146 146
 	 * @return Task
147 147
 	 */
148
-	private function getTaskInstance( string $class ) : Task {
148
+	private function getTaskInstance ( string $class ) : Task {
149 149
 		return new $class( $this->provider );
150 150
 	}
151 151
 
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 	 * @param string $class
156 156
 	 * @return Subtask
157 157
 	 */
158
-	private function getSubtaskInstance( string $class ) : Subtask {
158
+	private function getSubtaskInstance ( string $class ) : Subtask {
159 159
 		return new $class( $this->provider );
160 160
 	}
161 161
 
162
-	public static function setLastFullRunDate() {
162
+	public static function setLastFullRunDate () {
163 163
 		file_put_contents( self::LOG_FILE, date( 'd/m/Y' ) );
164 164
 	}
165 165
 }
Please login to merge, or discard this patch.
includes/Task/Subtask/UpdatesAround.php 1 patch
Spacing   +7 added lines, -7 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
 
@@ -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
 		$pages = $this->getDataProvider()->getCreatedPages();
20 20
 
21 21
 		if ( !$pages ) {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param PageRiconferma[] $pages
39 39
 	 */
40
-	protected function addToMainPage( array $pages ) {
40
+	protected function addToMainPage ( array $pages ) {
41 41
 		$this->getLogger()->info(
42 42
 			'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) )
43 43
 		);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @param PageRiconferma[] $pages
66 66
 	 */
67
-	protected function addToVotazioni( array $pages ) {
67
+	protected function addToVotazioni ( array $pages ) {
68 68
 		$this->getLogger()->info(
69 69
 			'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) )
70 70
 		);
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
94 94
 			// Replace semicolon with full stop
95 95
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
96
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 );
96
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 );
97 97
 		}
98 98
 
99 99
 		$summary = $this->msg( 'vote-page-summary' )
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @param int $amount
114 114
 	 */
115
-	protected function addToNews( int $amount ) {
115
+	protected function addToNews ( int $amount ) {
116 116
 		$this->getLogger()->info( "Increasing the news counter by $amount" );
117 117
 		$newsPage = new Page( $this->getConfig()->get( 'news-page-title' ) );
118 118
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 			throw new TaskException( 'Param not found in news page' );
126 126
 		}
127 127
 
128
-		$newNum = (int)$matches[2] + $amount;
128
+		$newNum = (int)$matches[ 2 ] + $amount;
129 129
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
130 130
 
131 131
 		$summary = $this->msg( 'news-page-summary' )
Please login to merge, or discard this patch.
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/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 runInternal() : int {
26
+	public function runInternal () : int {
27 27
 		$pages = $this->getDataProvider()->getOpenPages();
28 28
 
29 29
 		if ( !$pages ) {
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	 * @param PageRiconferma[] $pages
38 38
 	 * @return int a STATUS_* constant
39 39
 	 */
40
-	protected function processPages( array $pages ) : int {
41
-		$actualPages = [];
40
+	protected function processPages ( array $pages ) : int {
41
+		$actualPages = [ ];
42 42
 		foreach ( $pages as $page ) {
43 43
 			if ( $page->hasOpposition() && !$page->isVote() ) {
44 44
 				$this->openVote( $page );
45
-				$actualPages[] = $page;
45
+				$actualPages[ ] = $page;
46 46
 			}
47 47
 		}
48 48
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param PageRiconferma $page
62 62
 	 */
63
-	protected function openVote( PageRiconferma $page ) {
63
+	protected function openVote ( PageRiconferma $page ) {
64 64
 		$this->getLogger()->info( "Starting vote on $page" );
65 65
 
66 66
 		$content = $page->getContent();
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 	 * @see SimpleUpdates::updateVotazioni()
100 100
 	 * @see UpdatesAround::addToVotazioni()
101 101
 	 */
102
-	protected function updateVotePage( array $pages ) {
102
+	protected function updateVotePage ( array $pages ) {
103 103
 		$votePage = new Page( $this->getConfig()->get( 'vote-page-title' ) );
104 104
 		$content = $votePage->getContent();
105 105
 
106
-		$titles = [];
106
+		$titles = [ ];
107 107
 		foreach ( $pages as $page ) {
108
-			$titles[] = preg_quote( $page->getTitle() );
108
+			$titles[ ] = preg_quote( $page->getTitle() );
109 109
 		}
110 110
 		$titleReg = implode( '|', $titles );
111 111
 		$search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!gm";
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 );
129 129
 		} else {
130 130
 			// Start section
131
-			$matches = [];
131
+			$matches = [ ];
132 132
 			if ( preg_match( $introReg, $newContent, $matches ) === 0 ) {
133 133
 				throw new TaskException( 'Intro not found in vote page' );
134 134
 			}
135 135
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
136 136
 			// Replace semicolon with full stop
137 137
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
138
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 );
138
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 );
139 139
 		}
140 140
 
141 141
 		$summary = $this->msg( 'vote-start-vote-page-summary' )
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @see UpdatesAround::addToNews()
158 158
 	 * @see SimpleUpdates::updateNews()
159 159
 	 */
160
-	protected function updateNews( int $amount ) {
160
+	protected function updateNews ( int $amount ) {
161 161
 		$this->getLogger()->info( "Turning $amount pages into votes" );
162 162
 		$newsPage = new Page( $this->getConfig()->get( 'news-page-title' ) );
163 163
 
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 			throw new TaskException( 'Param "voto" not found in news page' );
173 173
 		}
174 174
 
175
-		$newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: '';
176
-		$newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: '';
175
+		$newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: '';
176
+		$newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: '';
177 177
 
178 178
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
179 179
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/Task/TaskBase.php 1 patch
Spacing   +10 added lines, -10 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,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 abstract class TaskBase extends ContextSource {
13 13
 	/** @var string[] */
14
-	protected $errors = [];
14
+	protected $errors = [ ];
15 15
 	/** @var TaskDataProvider */
16 16
 	protected $dataProvider;
17 17
 
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param TaskDataProvider $dataProvider
22 22
 	 */
23
-	final public function __construct( TaskDataProvider $dataProvider ) {
23
+	final public function __construct ( TaskDataProvider $dataProvider ) {
24 24
 		set_exception_handler( [ $this, 'handleException' ] );
25 25
 		set_error_handler( [ $this, 'handleError' ] );
26 26
 		parent::__construct();
27 27
 		$this->dataProvider = $dataProvider;
28 28
 	}
29 29
 
30
-	public function __destruct() {
30
+	public function __destruct () {
31 31
 		restore_error_handler();
32 32
 		restore_exception_handler();
33 33
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return TaskResult
39 39
 	 */
40
-	final public function run() : TaskResult {
40
+	final public function run () : TaskResult {
41 41
 		$class = ( new \ReflectionClass( $this ) )->getShortName();
42 42
 		$opName = $this->getOperationName();
43 43
 		$this->getLogger()->info( "Starting $opName $class" );
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @return int One of the STATUS_* constants
70 70
 	 */
71
-	abstract protected function runInternal() : int;
71
+	abstract protected function runInternal () : int;
72 72
 
73 73
 	/**
74 74
 	 * How this operation should be called in logs
75 75
 	 *
76 76
 	 * @return string
77 77
 	 */
78
-	abstract public function getOperationName() : string;
78
+	abstract public function getOperationName () : string;
79 79
 
80 80
 	/**
81 81
 	 * Exception handler.
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param \Throwable $ex
84 84
 	 * @protected
85 85
 	 */
86
-	public function handleException( \Throwable $ex ) {
86
+	public function handleException ( \Throwable $ex ) {
87 87
 		$this->getLogger()->error(
88 88
 			get_class( $ex ) . ': ' .
89 89
 			$ex->getMessage() . "\nTrace:\n" .
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 * @param int $errline
101 101
 	 * @protected
102 102
 	 */
103
-	public function handleError( $errno, $errstr, $errfile, $errline ) {
103
+	public function handleError ( $errno, $errstr, $errfile, $errline ) {
104 104
 		throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
105 105
 	}
106 106
 
107 107
 	/**
108 108
 	 * @return TaskDataProvider
109 109
 	 */
110
-	protected function getDataProvider() : TaskDataProvider {
110
+	protected function getDataProvider () : TaskDataProvider {
111 111
 		return $this->dataProvider;
112 112
 	}
113 113
 }
Please login to merge, or discard this patch.
includes/Task/Task.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\Task;
4 4
 
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 	 *
15 15
 	 * @return string[]
16 16
 	 */
17
-	abstract protected function getSubtasksMap() : array;
17
+	abstract protected function getSubtasksMap () : array;
18 18
 
19 19
 	/**
20 20
 	 * @param string $subtask Defined in self::SUBTASKS_MAP
21 21
 	 * @return TaskResult
22 22
 	 */
23
-	protected function runSubtask( string $subtask ) : TaskResult {
23
+	protected function runSubtask ( string $subtask ) : TaskResult {
24 24
 		$map = $this->getSubtasksMap();
25 25
 		if ( !isset( $map[ $subtask ] ) ) {
26 26
 			throw new \InvalidArgumentException( "'$subtask' is not a valid task." );
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @inheritDoc
35 35
 	 */
36
-	final public function getOperationName(): string {
36
+	final public function getOperationName (): string {
37 37
 		return 'task';
38 38
 	}
39 39
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param string $class
44 44
 	 * @return Subtask
45 45
 	 */
46
-	private function getSubtaskInstance( string $class ) : Subtask {
46
+	private function getSubtaskInstance ( string $class ) : Subtask {
47 47
 		return new $class( $this->getDataProvider() );
48 48
 	}
49 49
 }
Please login to merge, or discard this patch.