Passed
Push — master ( 4b4859...1d252d )
by Daimona
02:04
created
includes/Wiki/Page/Page.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @param string $title
23 23
 	 * @param Wiki $wiki For the site where the page lives
24 24
 	 */
25
-	public function __construct( string $title, Wiki $wiki ) {
25
+	public function __construct ( string $title, Wiki $wiki ) {
26 26
 		$this->wiki = $wiki;
27 27
 		$this->title = $title;
28 28
 	}
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * @return string
32 32
 	 */
33
-	public function getTitle() : string {
33
+	public function getTitle () : string {
34 34
 		return $this->title;
35 35
 	}
36 36
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @param int|null $section A section number to retrieve the content of that section
41 41
 	 * @return string
42 42
 	 */
43
-	public function getContent( int $section = null ) : string {
43
+	public function getContent ( int $section = null ) : string {
44 44
 		if ( $this->content === null ) {
45 45
 			$this->content = $this->wiki->getPageContent( $this->title, $section );
46 46
 		}
@@ -53,18 +53,18 @@  discard block
 block discarded – undo
53 53
 	 * @param array $params
54 54
 	 * @throws \LogicException
55 55
 	 */
56
-	public function edit( array $params ) : void {
56
+	public function edit ( array $params ) : void {
57 57
 		$params = [
58 58
 			'title' => $this->getTitle()
59 59
 		] + $params;
60 60
 
61 61
 		$this->wiki->editPage( $params );
62
-		if ( isset( $params['text'] ) ) {
63
-			$this->content = $params['text'];
64
-		} elseif ( isset( $params['appendtext'] ) ) {
65
-			$this->content .= $params['appendtext'];
66
-		} elseif ( isset( $params['prependtext'] ) ) {
67
-			$this->content = $params['prependtext'] . $this->content;
62
+		if ( isset( $params[ 'text' ] ) ) {
63
+			$this->content = $params[ 'text' ];
64
+		} elseif ( isset( $params[ 'appendtext' ] ) ) {
65
+			$this->content .= $params[ 'appendtext' ];
66
+		} elseif ( isset( $params[ 'prependtext' ] ) ) {
67
+			$this->content = $params[ 'prependtext' ] . $this->content;
68 68
 		} else {
69 69
 			throw new \LogicException(
70 70
 				'Unrecognized text param for edit. Params: ' . var_export( $params, true )
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return bool
79 79
 	 */
80
-	public function exists() : bool {
80
+	public function exists () : bool {
81 81
 		$res = RequestBase::newFromParams( [
82 82
 			'action' => 'query',
83 83
 			'titles' => $this->getTitle()
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 * @param string $regex
93 93
 	 * @return bool
94 94
 	 */
95
-	public function matches( string $regex ) : bool {
95
+	public function matches ( string $regex ) : bool {
96 96
 		return (bool)preg_match( $regex, $this->getContent() );
97 97
 	}
98 98
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @return string[]
105 105
 	 * @throws MissingMatchException
106 106
 	 */
107
-	public function getMatch( string $regex ) : array {
108
-		$ret = [];
107
+	public function getMatch ( string $regex ) : array {
108
+		$ret = [ ];
109 109
 		if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) {
110 110
 			throw new MissingMatchException( "The content of $this does not match the given regex $regex" );
111 111
 		}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @inheritDoc
119 119
 	 */
120
-	public function getRegex( string $delimiter = '/' ) : string {
120
+	public function getRegex ( string $delimiter = '/' ) : string {
121 121
 		return str_replace( ' ', '[ _]', preg_quote( $this->title, $delimiter ) );
122 122
 	}
123 123
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return string
128 128
 	 */
129
-	public function __toString() {
129
+	public function __toString () {
130 130
 		return $this->getTitle();
131 131
 	}
132 132
 }
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
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 * @param string $delimiter
13 13
 	 * @return string
14 14
 	 */
15
-	abstract public function getRegex( string $delimiter = '/' ) : string;
15
+	abstract public function getRegex ( string $delimiter = '/' ) : string;
16 16
 
17 17
 	/**
18 18
 	 * Get a regex matching any element in the given array
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 	 * @return string
23 23
 	 * @todo Is this the right place?
24 24
 	 */
25
-	public static function regexFromArray( array $elements, string $delimiter = '/' ) : string {
26
-		$bits = [];
25
+	public static function regexFromArray ( array $elements, string $delimiter = '/' ) : string {
26
+		$bits = [ ];
27 27
 		foreach ( $elements as $el ) {
28
-			$bits[] = $el->getRegex( $delimiter );
28
+			$bits[ ] = $el->getRegex( $delimiter );
29 29
 		}
30 30
 		return '(?:' . implode( '|', $bits ) . ')';
31 31
 	}
Please login to merge, or discard this patch.
includes/Wiki/User.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\Wiki;
4 4
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @param string $name
23 23
 	 * @param Wiki $wiki
24 24
 	 */
25
-	public function __construct( string $name, Wiki $wiki ) {
25
+	public function __construct ( string $name, Wiki $wiki ) {
26 26
 		$this->wiki = $wiki;
27 27
 		$this->name = $name;
28 28
 	}
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * @return string
32 32
 	 */
33
-	public function getName() : string {
33
+	public function getName () : string {
34 34
 		return $this->name;
35 35
 	}
36 36
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @return string[]
41 41
 	 */
42
-	public function getGroups() : array {
42
+	public function getGroups () : array {
43 43
 		return array_diff( array_keys( $this->getUserInfo() ), PageBotList::NON_GROUP_KEYS );
44 44
 	}
45 45
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @return string[] [ group => date ]
50 50
 	 */
51
-	public function getGroupsWithDates() : array {
51
+	public function getGroupsWithDates () : array {
52 52
 		return array_intersect_key( $this->getUserInfo(), array_fill_keys( $this->getGroups(), 1 ) );
53 53
 	}
54 54
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @return string[]
59 59
 	 */
60
-	public function getUserInfo() : array {
60
+	public function getUserInfo () : array {
61 61
 		if ( $this->info === null ) {
62 62
 			$usersList = PageBotList::get( $this->wiki )->getAdminsList();
63 63
 			$this->info = $usersList[ $this->name ]->getUserInfo();
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	/**
69 69
 	 * @param array|null $info
70 70
 	 */
71
-	public function setInfo( ?array $info ) : void {
71
+	public function setInfo ( ?array $info ) : void {
72 72
 		$this->info = $info;
73 73
 	}
74 74
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param string $groupName
79 79
 	 * @return bool
80 80
 	 */
81
-	public function inGroup( string $groupName ) : bool {
81
+	public function inGroup ( string $groupName ) : bool {
82 82
 		return in_array( $groupName, $this->getGroups(), true );
83 83
 	}
84 84
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @inheritDoc
89 89
 	 */
90
-	public function getRegex( string $delimiter = '/' ) : string {
90
+	public function getRegex ( string $delimiter = '/' ) : string {
91 91
 		$bits = $this->getAliases();
92
-		$bits[] = $this->name;
92
+		$bits[ ] = $this->name;
93 93
 		$regexify = static function ( $el ) use ( $delimiter ) {
94 94
 			return str_replace( ' ', '[ _]', preg_quote( $el, $delimiter ) );
95 95
 		};
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return string[]
103 103
 	 */
104
-	public function getAliases() : array {
105
-		return $this->getUserInfo()['aliases'] ?? [];
104
+	public function getAliases () : array {
105
+		return $this->getUserInfo()[ 'aliases' ] ?? [ ];
106 106
 	}
107 107
 
108 108
 	/**
109 109
 	 * @return Page
110 110
 	 */
111
-	public function getTalkPage() : Page {
111
+	public function getTalkPage () : Page {
112 112
 		return new Page( "User talk:{$this->name}", $this->wiki );
113 113
 	}
114 114
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 * Get the default base page, e.g. WP:A/Riconferma annuale/XXX
117 117
 	 * @return Page
118 118
 	 */
119
-	public function getBasePage() : Page {
119
+	public function getBasePage () : Page {
120 120
 		$prefix = Config::getInstance()->get( 'main-page-title' );
121 121
 		return new Page( "$prefix/$this", $this->wiki );
122 122
 	}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @throws MissingPageException
129 129
 	 * @return Page
130 130
 	 */
131
-	public function getExistingBasePage() : Page {
131
+	public function getExistingBasePage () : Page {
132 132
 		$basePage = $this->getBasePage();
133 133
 		if ( !$basePage->exists() ) {
134 134
 			$basePage = null;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	/**
153 153
 	 * @return string
154 154
 	 */
155
-	public function __toString() {
155
+	public function __toString () {
156 156
 		return $this->name;
157 157
 	}
158 158
 }
Please login to merge, or discard this patch.