Passed
Push — master ( 5a8341...4cf7bd )
by Daimona
01:31
created
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/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.
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/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.