Passed
Push — master ( 3a1f1a...4b4859 )
by Daimona
02:56 queued 18s
created
includes/Wiki/Page/PageBotList.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\Wiki\Page;
4 4
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @private Use self::get()
19 19
 	 * @param Wiki $wiki
20 20
 	 */
21
-	public function __construct( Wiki $wiki ) {
21
+	public function __construct ( Wiki $wiki ) {
22 22
 		// phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix
23 23
 		global $globalListTitle;
24 24
 		parent::__construct( $globalListTitle, $wiki );
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @param Wiki $wiki
31 31
 	 * @return self
32 32
 	 */
33
-	public static function get( Wiki $wiki ) : self {
33
+	public static function get ( Wiki $wiki ) : self {
34 34
 		static $instance = null;
35 35
 		if ( $instance === null ) {
36 36
 			$instance = new self( $wiki );
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
 	 * @param string[] $groups
43 43
 	 * @return int|null
44 44
 	 */
45
-	public static function getOverrideTimestamp( array $groups ) : ?int {
45
+	public static function getOverrideTimestamp ( array $groups ) : ?int {
46 46
 		if ( !array_intersect_key( $groups, [ 'override-perm' => true, 'override' => true ] ) ) {
47 47
 			return null;
48 48
 		}
49 49
 
50 50
 		// A one-time override takes precedence
51 51
 		if ( array_key_exists( 'override', $groups ) ) {
52
-			$date = $groups['override'];
52
+			$date = $groups[ 'override' ];
53 53
 		} else {
54
-			$date = $groups['override-prem'] . '/' . date( 'Y' );
54
+			$date = $groups[ 'override-prem' ] . '/' . date( 'Y' );
55 55
 		}
56 56
 		return \DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp();
57 57
 	}
@@ -62,17 +62,15 @@  discard block
 block discarded – undo
62 62
 	 * @param array $groups
63 63
 	 * @return int
64 64
 	 */
65
-	public static function getValidFlagTimestamp( array $groups ): int {
66
-		$checkuser = isset( $groups['checkuser'] ) ?
67
-			\DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() :
68
-			0;
69
-		$bureaucrat = isset( $groups['bureaucrat'] ) ?
70
-			\DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() :
71
-			0;
65
+	public static function getValidFlagTimestamp ( array $groups ): int {
66
+		$checkuser = isset( $groups[ 'checkuser' ] ) ?
67
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
68
+		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
69
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
72 70
 
73 71
 		$timestamp = max( $bureaucrat, $checkuser );
74 72
 		if ( $timestamp === 0 ) {
75
-			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp();
73
+			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp();
76 74
 		}
77 75
 		return $timestamp;
78 76
 	}
@@ -81,14 +79,14 @@  discard block
 block discarded – undo
81 79
 	 * @param array $groups
82 80
 	 * @return bool
83 81
 	 */
84
-	public static function isOverrideExpired( array $groups ) : bool {
85
-		if ( !isset( $groups['override'] ) ) {
82
+	public static function isOverrideExpired ( array $groups ) : bool {
83
+		if ( !isset( $groups[ 'override' ] ) ) {
86 84
 			return false;
87 85
 		}
88 86
 
89 87
 		$flagTS = self::getValidFlagTimestamp( $groups );
90 88
 		$usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) );
91
-		$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp();
89
+		$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp();
92 90
 		$delay = 60 * 60 * 24 * 3;
93 91
 
94 92
 		return time() > $usualTS + $delay && time() > $overrideTS + $delay;
@@ -99,9 +97,9 @@  discard block
 block discarded – undo
99 97
 	 *
100 98
 	 * @return User[]
101 99
 	 */
102
-	public function getAdminsList() : array {
100
+	public function getAdminsList () : array {
103 101
 		if ( $this->adminsList === null ) {
104
-			$this->adminsList = [];
102
+			$this->adminsList = [ ];
105 103
 			foreach ( $this->getDecodedContent() as $user => $info ) {
106 104
 				$userObj = new User( $user, $this->wiki );
107 105
 				$userObj->setInfo( $info );
@@ -116,7 +114,7 @@  discard block
 block discarded – undo
116 114
 	 *
117 115
 	 * @return array[]
118 116
 	 */
119
-	public function getDecodedContent() : array {
117
+	public function getDecodedContent () : array {
120 118
 		return json_decode( $this->getContent(), true );
121 119
 	}
122 120
 }
Please login to merge, or discard this patch.
includes/CLI.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;
4 4
 
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 	/**
58 58
 	 * @return bool
59 59
 	 */
60
-	public static function isCLI() : bool {
60
+	public static function isCLI () : bool {
61 61
 		return PHP_SAPI === 'cli';
62 62
 	}
63 63
 
64 64
 	/**
65 65
 	 * Populate options and check for required ones
66 66
 	 */
67
-	public function __construct() {
67
+	public function __construct () {
68 68
 		$opts = getopt( self::SHORT_OPTS, self::LONG_OPTS );
69 69
 		$this->checkRequiredOpts( $opts );
70 70
 		$this->checkConflictingOpts( $opts );
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * @param array $opts
77 77
 	 */
78
-	private function checkRequiredOpts( array $opts ) : void {
78
+	private function checkRequiredOpts ( array $opts ) : void {
79 79
 		$missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) );
80 80
 		if ( $missingOpts ) {
81 81
 			exit( 'Required options missing: ' . implode( ', ', $missingOpts ) );
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	/**
92 92
 	 * @param array $opts
93 93
 	 */
94
-	private function checkConflictingOpts( array $opts ) : void {
94
+	private function checkConflictingOpts ( array $opts ) : void {
95 95
 		$hasPw = array_key_exists( 'password', $opts );
96 96
 		$hasPwFile = array_key_exists( 'use-password-file', $opts );
97 97
 		if ( $hasPw && $hasPwFile ) {
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	/**
109 109
 	 * @param array &$opts
110 110
 	 */
111
-	private function canonicalize( array &$opts ) : void {
111
+	private function canonicalize ( array &$opts ) : void {
112 112
 		if ( array_key_exists( 'use-password-file', $opts ) ) {
113 113
 			$pw = trim( file_get_contents( self::PASSWORD_FILE ) );
114
-			$opts['password'] = $pw;
115
-			unset( $opts['use-password-file'] );
114
+			$opts[ 'password' ] = $pw;
115
+			unset( $opts[ 'use-password-file' ] );
116 116
 		}
117 117
 	}
118 118
 
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
 	 * @param mixed|null $default
122 122
 	 * @return mixed
123 123
 	 */
124
-	public function getOpt( string $opt, $default = null ) {
125
-		return $this->opts[$opt] ?? $default;
124
+	public function getOpt ( string $opt, $default = null ) {
125
+		return $this->opts[ $opt ] ?? $default;
126 126
 	}
127 127
 
128 128
 	/**
129 129
 	 * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ]
130 130
 	 */
131
-	public function getTaskOpt() : array {
131
+	public function getTaskOpt () : array {
132 132
 		return array_intersect_key(
133 133
 			$this->opts,
134 134
 			[ 'task' => true, 'subtask' => true ]
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	/**
139 139
 	 * @return string|null
140 140
 	 */
141
-	public function getURL() : ?string {
141
+	public function getURL () : ?string {
142 142
 		return $this->getOpt( 'force-url' );
143 143
 	}
144 144
 }
Please login to merge, or discard this patch.