Passed
Push — master ( 1a35de...b3e686 )
by Daimona
01:36
created
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/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.
run.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
  * Entry point for the bot, called by CLI
4 4
  */
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 /* URL (for debugging purpose) */
39 39
 $urlParam = getopt( '', [ 'force-url:' ] );
40
-$url = $urlParam['force-url'] ?? 'https://it.wikipedia.org/w/api.php';
40
+$url = $urlParam[ 'force-url' ] ?? 'https://it.wikipedia.org/w/api.php';
41 41
 
42 42
 define( 'DEFAULT_URL', $url );
43 43
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 
88 88
 if ( count( $taskOpts ) === 2 ) {
89 89
 	throw new InvalidArgumentException( 'Cannot specify both task and subtask.' );
90
-} elseif ( isset( $taskOpts['task'] ) ) {
90
+} elseif ( isset( $taskOpts[ 'task' ] ) ) {
91 91
 	$bot->runTask( $taskOpts[ 'task' ] );
92
-} elseif ( isset( $taskOpts['subtask'] ) ) {
92
+} elseif ( isset( $taskOpts[ 'subtask' ] ) ) {
93 93
 	$bot->runSubtask( $taskOpts[ 'subtask' ] );
94 94
 } else {
95 95
 	$bot->runAll();
Please login to merge, or discard this patch.
includes/ContextSource.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
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	/** @var Controller */
20 20
 	private $controller;
21 21
 
22
-	public function __construct() {
22
+	public function __construct () {
23 23
 		$this->setLogger( new Logger );
24 24
 		$this->setConfig( Config::getInstance() );
25 25
 		$this->setController( new Controller );
@@ -28,42 +28,42 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @return LoggerInterface
30 30
 	 */
31
-	protected function getLogger() : LoggerInterface {
31
+	protected function getLogger () : LoggerInterface {
32 32
 		return $this->logger;
33 33
 	}
34 34
 
35 35
 	/**
36 36
 	 * @inheritDoc
37 37
 	 */
38
-	public function setLogger( LoggerInterface $logger ) {
38
+	public function setLogger ( LoggerInterface $logger ) {
39 39
 		$this->logger = $logger;
40 40
 	}
41 41
 
42 42
 	/**
43 43
 	 * @return Config
44 44
 	 */
45
-	protected function getConfig() : Config {
45
+	protected function getConfig () : Config {
46 46
 		return $this->config;
47 47
 	}
48 48
 
49 49
 	/**
50 50
 	 * @param Config $cfg
51 51
 	 */
52
-	protected function setConfig( Config $cfg ) {
52
+	protected function setConfig ( Config $cfg ) {
53 53
 		$this->config = $cfg;
54 54
 	}
55 55
 
56 56
 	/**
57 57
 	 * @return Controller
58 58
 	 */
59
-	protected function getController() : Controller {
59
+	protected function getController () : Controller {
60 60
 		return $this->controller;
61 61
 	}
62 62
 
63 63
 	/**
64 64
 	 * @param Controller $controller
65 65
 	 */
66
-	protected function setController( Controller $controller ) {
66
+	protected function setController ( Controller $controller ) {
67 67
 		$this->controller = $controller;
68 68
 	}
69 69
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param string $key
74 74
 	 * @return Message
75 75
 	 */
76
-	protected function msg( string $key ) : Message {
76
+	protected function msg ( string $key ) : Message {
77 77
 		return new Message( $key );
78 78
 	}
79 79
 }
Please login to merge, or discard this patch.
includes/Wiki/Page/Page.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\Wiki\Page;
4 4
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param string $title
21 21
 	 * @param string $domain The site where the page lives, if different from default
22 22
 	 */
23
-	public function __construct( string $title, string $domain = DEFAULT_URL ) {
23
+	public function __construct ( string $title, string $domain = DEFAULT_URL ) {
24 24
 		$this->title = $title;
25 25
 		$this->controller = new Controller( $domain );
26 26
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @return string
30 30
 	 */
31
-	public function getTitle() : string {
31
+	public function getTitle () : string {
32 32
 		return $this->title;
33 33
 	}
34 34
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param int|null $section A section number to retrieve the content of that section
39 39
 	 * @return string
40 40
 	 */
41
-	public function getContent( int $section = null ) : string {
41
+	public function getContent ( int $section = null ) : string {
42 42
 		if ( $this->content === null ) {
43 43
 			$this->content = $this->controller->getPageContent( $this->title, $section );
44 44
 		}
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param array $params
52 52
 	 */
53
-	public function edit( array $params ) {
53
+	public function edit ( array $params ) {
54 54
 		$params = [
55 55
 			'title' => $this->getTitle()
56 56
 		] + $params;
57 57
 
58 58
 		$this->controller->editPage( $params );
59
-		if ( isset( $params['text'] ) ) {
60
-			$this->content = $params['text'];
61
-		} elseif ( isset( $params['appendtext'] ) ) {
62
-			$this->content .= $params['appendtext'];
59
+		if ( isset( $params[ 'text' ] ) ) {
60
+			$this->content = $params[ 'text' ];
61
+		} elseif ( isset( $params[ 'appendtext' ] ) ) {
62
+			$this->content .= $params[ 'appendtext' ];
63 63
 		} else {
64 64
 			// Clear the cache anyway
65 65
 			( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) );
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param string $regex
74 74
 	 * @return bool
75 75
 	 */
76
-	public function matches( string $regex ) : bool {
76
+	public function matches ( string $regex ) : bool {
77 77
 		return (bool)preg_match( $regex, $this->getContent() );
78 78
 	}
79 79
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 * @return string[]
86 86
 	 * @throws \Exception
87 87
 	 */
88
-	public function getMatch( string $regex ) : array {
89
-		$ret = [];
88
+	public function getMatch ( string $regex ) : array {
89
+		$ret = [ ];
90 90
 		if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) {
91 91
 			throw new \Exception( 'The content does not match the given regex' );
92 92
 		}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return string
100 100
 	 */
101
-	public function __toString() {
101
+	public function __toString () {
102 102
 		return $this->getTitle();
103 103
 	}
104 104
 }
Please login to merge, or discard this patch.
includes/Wiki/Page/PageBotList.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\Wiki\Page;
4 4
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @private Use self::get()
13 13
 	 */
14
-	public function __construct() {
14
+	public function __construct () {
15 15
 		parent::__construct( Config::getInstance()->get( 'list-title' ) );
16 16
 	}
17 17
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return self
22 22
 	 */
23
-	public static function get() : self {
23
+	public static function get () : self {
24 24
 		static $instance = null;
25 25
 		if ( $instance === null ) {
26 26
 			$instance = new self;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @return array[]
35 35
 	 */
36
-	public function getAdminsList() : array {
36
+	public function getAdminsList () : array {
37 37
 		return json_decode( $this->getContent(), true );
38 38
 	}
39 39
 }
Please login to merge, or discard this patch.
includes/Wiki/User.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\Wiki;
4 4
 
@@ -16,21 +16,21 @@  discard block
 block discarded – undo
16 16
 	/**
17 17
 	 * @param string $name
18 18
 	 */
19
-	public function __construct( string $name ) {
19
+	public function __construct ( string $name ) {
20 20
 		$this->name = $name;
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @return string
25 25
 	 */
26
-	public function getName() : string {
26
+	public function getName () : string {
27 27
 		return $this->name;
28 28
 	}
29 29
 
30 30
 	/**
31 31
 	 * @return string[]
32 32
 	 */
33
-	public function getGroups() : array {
33
+	public function getGroups () : array {
34 34
 		if ( $this->groups === null ) {
35 35
 			$usersList = PageBotList::get()->getAdminsList();
36 36
 			$this->groups = array_keys( $usersList[ $this->name ] );
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
 	 * @param string $groupName
45 45
 	 * @return bool
46 46
 	 */
47
-	public function inGroup( string $groupName ) : bool {
47
+	public function inGroup ( string $groupName ) : bool {
48 48
 		return in_array( $groupName, $this->getGroups() );
49 49
 	}
50 50
 
51 51
 	/**
52 52
 	 * @return string
53 53
 	 */
54
-	public function __toString() {
54
+	public function __toString () {
55 55
 		return $this->name;
56 56
 	}
57 57
 }
Please login to merge, or discard this patch.