@@ -1,4 +1,4 @@ discard block |
||
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 |
||
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 | |
20 | 20 | if ( !$pages ) { |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | * @param PageRiconferma[] $pages |
34 | 34 | * @see UpdatesAround::addToMainPage() |
35 | 35 | */ |
36 | - protected function removeFromMainPage( array $pages ) { |
|
36 | + protected function removeFromMainPage ( array $pages ) { |
|
37 | 37 | $this->getLogger()->info( |
38 | 38 | 'Removing from main: ' . implode( ', ', $pages ) |
39 | 39 | ); |
40 | 40 | |
41 | 41 | $mainPage = new Page( $this->getConfig()->get( 'main-page-title' ) ); |
42 | - $remove = []; |
|
42 | + $remove = [ ]; |
|
43 | 43 | foreach ( $pages as $page ) { |
44 | - $remove[] = '{{' . $page->getTitle() . '}}'; |
|
44 | + $remove[ ] = '{{' . $page->getTitle() . '}}'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $newContent = str_replace( $remove, '', $mainPage->getContent() ); |
@@ -70,17 +70,17 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @param PageRiconferma[] $pages |
72 | 72 | */ |
73 | - protected function addToArchive( array $pages ) { |
|
73 | + protected function addToArchive ( array $pages ) { |
|
74 | 74 | $this->getLogger()->info( |
75 | 75 | 'Adding to archive: ' . implode( ', ', $pages ) |
76 | 76 | ); |
77 | 77 | |
78 | - $simple = $votes = []; |
|
78 | + $simple = $votes = [ ]; |
|
79 | 79 | foreach ( $pages as $page ) { |
80 | 80 | if ( $page->isVote() ) { |
81 | - $votes[] = $page; |
|
81 | + $votes[ ] = $page; |
|
82 | 82 | } else { |
83 | - $simple[] = $page; |
|
83 | + $simple[ ] = $page; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | * @param string $archiveTitle |
102 | 102 | * @param array $pages |
103 | 103 | */ |
104 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) { |
|
104 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) { |
|
105 | 105 | $archivePage = new Page( "$archiveTitle/" . date( 'Y' ) ); |
106 | 106 | $exists = $archivePage->exists(); |
107 | 107 | |
108 | 108 | $append = "\n"; |
109 | - $archivedList = []; |
|
109 | + $archivedList = [ ]; |
|
110 | 110 | foreach ( $pages as $page ) { |
111 | 111 | $append .= '{{' . $page->getTitle() . "}}\n"; |
112 | - $archivedList[] = $page->getUserNum(); |
|
112 | + $archivedList[ ] = $page->getUserNum(); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $summary = $this->msg( 'close-archive-summary' ) |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @param string $archiveTitle |
132 | 132 | */ |
133 | - private function addArchiveYear( string $archiveTitle ) { |
|
133 | + private function addArchiveYear ( string $archiveTitle ) { |
|
134 | 134 | $page = new Page( $archiveTitle ); |
135 | 135 | $year = date( 'Y' ); |
136 | 136 |
@@ -1,4 +1,4 @@ discard block |
||
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 |
||
22 | 22 | * @param string $title |
23 | 23 | * @param string $domain The site where the page lives, if different from default |
24 | 24 | */ |
25 | - public function __construct( string $title, string $domain = DEFAULT_URL ) { |
|
25 | + public function __construct ( string $title, string $domain = DEFAULT_URL ) { |
|
26 | 26 | $this->title = $title; |
27 | 27 | $this->controller = new Controller( $domain ); |
28 | 28 | } |
@@ -30,7 +30,7 @@ discard block |
||
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 |
||
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->controller->getPageContent( $this->title, $section ); |
46 | 46 | } |
@@ -52,16 +52,16 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param array $params |
54 | 54 | */ |
55 | - public function edit( array $params ) { |
|
55 | + public function edit ( array $params ) { |
|
56 | 56 | $params = [ |
57 | 57 | 'title' => $this->getTitle() |
58 | 58 | ] + $params; |
59 | 59 | |
60 | 60 | $this->controller->editPage( $params ); |
61 | - if ( isset( $params['text'] ) ) { |
|
62 | - $this->content = $params['text']; |
|
63 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
64 | - $this->content .= $params['appendtext']; |
|
61 | + if ( isset( $params[ 'text' ] ) ) { |
|
62 | + $this->content = $params[ 'text' ]; |
|
63 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
64 | + $this->content .= $params[ 'appendtext' ]; |
|
65 | 65 | } else { |
66 | 66 | // Clear the cache anyway |
67 | 67 | ( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) ); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | - public function exists() : bool { |
|
77 | + public function exists () : bool { |
|
78 | 78 | $res = RequestBase::newFromParams( [ |
79 | 79 | 'action' => 'query', |
80 | 80 | 'titles' => $this->getTitle() |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @param string $regex |
90 | 90 | * @return bool |
91 | 91 | */ |
92 | - public function matches( string $regex ) : bool { |
|
92 | + public function matches ( string $regex ) : bool { |
|
93 | 93 | return (bool)preg_match( $regex, $this->getContent() ); |
94 | 94 | } |
95 | 95 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * @return string[] |
102 | 102 | * @throws \Exception |
103 | 103 | */ |
104 | - public function getMatch( string $regex ) : array { |
|
105 | - $ret = []; |
|
104 | + public function getMatch ( string $regex ) : array { |
|
105 | + $ret = [ ]; |
|
106 | 106 | if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) { |
107 | 107 | throw new \Exception( 'The content does not match the given regex' ); |
108 | 108 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @inheritDoc |
116 | 116 | */ |
117 | - public function getRegex() : string { |
|
117 | + public function getRegex () : string { |
|
118 | 118 | return str_replace( ' ', '[ _]', preg_quote( $this->title ) ); |
119 | 119 | } |
120 | 120 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return string |
125 | 125 | */ |
126 | - public function __toString() { |
|
126 | + public function __toString () { |
|
127 | 127 | return $this->getTitle(); |
128 | 128 | } |
129 | 129 | } |