Passed
Push — master ( 470b4b...fe0189 )
by Daimona
02:30
created
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/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/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/TaskManager.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;
4 4
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK
53 53
 	 * @return TaskResult
54 54
 	 */
55
-	public function run( string $mode, string $name = null ) : TaskResult {
55
+	public function run ( string $mode, string $name = null ) : TaskResult {
56 56
 		$this->provider = new TaskDataProvider;
57 57
 
58 58
 		if ( $mode === self::MODE_COMPLETE ) {
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return TaskResult
71 71
 	 */
72
-	protected function runAllTasks() : TaskResult {
72
+	protected function runAllTasks () : TaskResult {
73 73
 		$orderedList = [
74 74
 			'update-list',
75 75
 			'start-new',
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param string $name
92 92
 	 * @return TaskResult
93 93
 	 */
94
-	protected function runTask( string $name ) : TaskResult {
94
+	protected function runTask ( string $name ) : TaskResult {
95 95
 		if ( !isset( self::TASKS_MAP[ $name ] ) ) {
96 96
 			throw new \InvalidArgumentException( "'$name' is not a valid task." );
97 97
 		}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param string $name
107 107
 	 * @return TaskResult
108 108
 	 */
109
-	protected function runSubtask( string $name ) : TaskResult {
109
+	protected function runSubtask ( string $name ) : TaskResult {
110 110
 		if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) {
111 111
 			throw new \InvalidArgumentException( "'$name' is not a valid subtask." );
112 112
 		}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @param string $class
122 122
 	 * @return Task
123 123
 	 */
124
-	private function getTaskInstance( string $class ) : Task {
124
+	private function getTaskInstance ( string $class ) : Task {
125 125
 		return new $class( $this->provider );
126 126
 	}
127 127
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @param string $class
132 132
 	 * @return Subtask
133 133
 	 */
134
-	private function getSubtaskInstance( string $class ) : Subtask {
134
+	private function getSubtaskInstance ( string $class ) : Subtask {
135 135
 		return new $class( $this->provider );
136 136
 	}
137 137
 }
Please login to merge, or discard this patch.
includes/Wiki/Element.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\Wiki;
4 4
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	 *
12 12
 	 * @return string
13 13
 	 */
14
-	abstract public function getRegex() : string;
14
+	abstract public function getRegex () : string;
15 15
 
16 16
 	/**
17 17
 	 * Get a regex matching any element in the given array
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
 	 * @return string
21 21
 	 * @todo Is this the right place?
22 22
 	 */
23
-	public static function regexFromArray( array $elements ) : string {
24
-		$bits = [];
23
+	public static function regexFromArray ( array $elements ) : string {
24
+		$bits = [ ];
25 25
 		foreach ( $elements as $el ) {
26
-			$bits[] = $el->getRegex();
26
+			$bits[ ] = $el->getRegex();
27 27
 		}
28 28
 		return '(?:' . implode( '|', $bits ) . ')';
29 29
 	}
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
 			( new \ReflectionClass( $ex ) )->getShortName() . ': ' .
89 89
 			$ex->getMessage() . "\nin " . $ex->getFile() . ' line ' .
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 	 * @throws \ErrorException
102 102
 	 * @protected
103 103
 	 */
104
-	public function handleError( $errno, $errstr, $errfile, $errline ) {
104
+	public function handleError ( $errno, $errstr, $errfile, $errline ) {
105 105
 		throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
106 106
 	}
107 107
 
108 108
 	/**
109 109
 	 * @return TaskDataProvider
110 110
 	 */
111
-	protected function getDataProvider() : TaskDataProvider {
111
+	protected function getDataProvider () : TaskDataProvider {
112 112
 		return $this->dataProvider;
113 113
 	}
114 114
 }
Please login to merge, or discard this patch.
includes/Request/CurlRequest.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
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 * @inheritDoc
13 13
 	 * @throws APIRequestException
14 14
 	 */
15
-	protected function reallyMakeRequest( string $params ) : string {
15
+	protected function reallyMakeRequest ( string $params ) : string {
16 16
 		$curl = curl_init();
17 17
 		if ( $curl === false ) {
18 18
 			throw new APIRequestException( 'Cannot open cURL handler.' );
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
 	 * @return int
55 55
 	 * @internal Only used as CB for cURL
56 56
 	 */
57
-	public function headersHandler( $ch, string $header ) : int {
57
+	public function headersHandler ( $ch, string $header ) : int {
58 58
 		$bits = explode( ':', $header, 2 );
59
-		if ( trim( $bits[0] ) === 'Set-Cookie' ) {
60
-			$this->newCookies[] = $bits[1];
59
+		if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) {
60
+			$this->newCookies[ ] = $bits[ 1 ];
61 61
 		}
62 62
 		// @phan-suppress-next-line PhanTypeMismatchReturn WTF? Why does phan thinks this is a string?
63 63
 		return strlen( $header );
Please login to merge, or discard this patch.