@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param string $listTitle |
21 | 21 | * @param Wiki $wiki |
22 | 22 | */ |
23 | - private function __construct( string $listTitle, Wiki $wiki ) { |
|
23 | + private function __construct ( string $listTitle, Wiki $wiki ) { |
|
24 | 24 | parent::__construct( $listTitle, $wiki ); |
25 | 25 | } |
26 | 26 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $listTitle |
32 | 32 | * @return self |
33 | 33 | */ |
34 | - public static function get( Wiki $wiki, string $listTitle ): self { |
|
34 | + public static function get ( Wiki $wiki, string $listTitle ): self { |
|
35 | 35 | static $instance = null; |
36 | 36 | if ( $instance === null ) { |
37 | 37 | $instance = new self( $listTitle, $wiki ); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param UserInfo $ui |
44 | 44 | * @return int|null |
45 | 45 | */ |
46 | - public function getOverrideTimestamp( UserInfo $ui ): ?int { |
|
46 | + public function getOverrideTimestamp ( UserInfo $ui ): ?int { |
|
47 | 47 | $info = $ui->getInfo(); |
48 | 48 | if ( !array_intersect_key( $info, [ 'override-perm' => true, 'override' => true ] ) ) { |
49 | 49 | return null; |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | |
52 | 52 | // A one-time override takes precedence |
53 | 53 | if ( array_key_exists( 'override', $info ) ) { |
54 | - $date = $info['override']; |
|
54 | + $date = $info[ 'override' ]; |
|
55 | 55 | } else { |
56 | - $date = $info['override-prem'] . '/' . date( 'Y' ); |
|
56 | + $date = $info[ 'override-prem' ] . '/' . date( 'Y' ); |
|
57 | 57 | } |
58 | 58 | return DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp(); |
59 | 59 | } |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | * @return int |
66 | 66 | * @suppress PhanPluginComparisonObjectOrdering DateTime objects can be compared (phan issue #2907) |
67 | 67 | */ |
68 | - public function getNextTimestamp( string $user ): int { |
|
68 | + public function getNextTimestamp ( string $user ): int { |
|
69 | 69 | $userInfo = $this->getUserInfo( $user )->getInfo(); |
70 | 70 | $now = new DateTime(); |
71 | - if ( isset( $userInfo['override-perm'] ) ) { |
|
71 | + if ( isset( $userInfo[ 'override-perm' ] ) ) { |
|
72 | 72 | $date = DateTime::createFromFormat( |
73 | 73 | 'd/m/Y', |
74 | - $userInfo['override-perm'] . '/' . date( 'Y' ) |
|
74 | + $userInfo[ 'override-perm' ] . '/' . date( 'Y' ) |
|
75 | 75 | ); |
76 | 76 | } else { |
77 | 77 | $date = null; |
78 | - if ( isset( $userInfo['override'] ) ) { |
|
79 | - $date = DateTime::createFromFormat( 'd/m/Y', $userInfo['override'] ); |
|
78 | + if ( isset( $userInfo[ 'override' ] ) ) { |
|
79 | + $date = DateTime::createFromFormat( 'd/m/Y', $userInfo[ 'override' ] ); |
|
80 | 80 | } |
81 | 81 | if ( !$date || $date <= $now ) { |
82 | 82 | $ts = self::getValidFlagTimestamp( $userInfo ); |
@@ -97,17 +97,15 @@ discard block |
||
97 | 97 | * @param string[] $groups |
98 | 98 | * @return int |
99 | 99 | */ |
100 | - public static function getValidFlagTimestamp( array $groups ): int { |
|
101 | - $checkuser = isset( $groups['checkuser'] ) ? |
|
102 | - DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() : |
|
103 | - 0; |
|
104 | - $bureaucrat = isset( $groups['bureaucrat'] ) ? |
|
105 | - DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() : |
|
106 | - 0; |
|
100 | + public static function getValidFlagTimestamp ( array $groups ): int { |
|
101 | + $checkuser = isset( $groups[ 'checkuser' ] ) ? |
|
102 | + DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
103 | + $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
|
104 | + DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
107 | 105 | |
108 | 106 | $timestamp = max( $bureaucrat, $checkuser ); |
109 | 107 | if ( $timestamp === 0 ) { |
110 | - $timestamp = DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp(); |
|
108 | + $timestamp = DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp(); |
|
111 | 109 | } |
112 | 110 | return $timestamp; |
113 | 111 | } |
@@ -121,14 +119,14 @@ discard block |
||
121 | 119 | * @param string[] $groups |
122 | 120 | * @return bool |
123 | 121 | */ |
124 | - public static function isOverrideExpired( array $groups ): bool { |
|
125 | - if ( !isset( $groups['override'] ) ) { |
|
122 | + public static function isOverrideExpired ( array $groups ): bool { |
|
123 | + if ( !isset( $groups[ 'override' ] ) ) { |
|
126 | 124 | return false; |
127 | 125 | } |
128 | 126 | |
129 | 127 | $flagTS = self::getValidFlagTimestamp( $groups ); |
130 | 128 | $usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) ); |
131 | - $overrideTS = DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp(); |
|
129 | + $overrideTS = DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp(); |
|
132 | 130 | $delay = 60 * 60 * 24 * 3; |
133 | 131 | |
134 | 132 | return time() > $usualTS + $delay && time() > $overrideTS + $delay; |
@@ -139,9 +137,9 @@ discard block |
||
139 | 137 | * |
140 | 138 | * @return UserInfo[] |
141 | 139 | */ |
142 | - public function getAdminsList(): array { |
|
140 | + public function getAdminsList (): array { |
|
143 | 141 | if ( $this->adminsList === null ) { |
144 | - $this->adminsList = []; |
|
142 | + $this->adminsList = [ ]; |
|
145 | 143 | foreach ( $this->getDecodedContent() as $user => $info ) { |
146 | 144 | $this->adminsList[ $user ] = new UserInfo( $user, $info ); |
147 | 145 | } |
@@ -153,8 +151,8 @@ discard block |
||
153 | 151 | * @param string $user |
154 | 152 | * @return UserInfo |
155 | 153 | */ |
156 | - public function getUserInfo( string $user ): UserInfo { |
|
157 | - return $this->getAdminsList()[$user]; |
|
154 | + public function getUserInfo ( string $user ): UserInfo { |
|
155 | + return $this->getAdminsList()[ $user ]; |
|
158 | 156 | } |
159 | 157 | |
160 | 158 | /** |
@@ -162,7 +160,7 @@ discard block |
||
162 | 160 | * |
163 | 161 | * @return string[][] |
164 | 162 | */ |
165 | - public function getDecodedContent(): array { |
|
163 | + public function getDecodedContent (): array { |
|
166 | 164 | return json_decode( $this->getContent(), true ); |
167 | 165 | } |
168 | 166 | } |
@@ -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 | |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** @var int|null */ |
17 | 17 | private $opposeSection; |
18 | 18 | /** @var int[] Counts of votes for each section */ |
19 | - private $sectionCounts = []; |
|
19 | + private $sectionCounts = [ ]; |
|
20 | 20 | |
21 | 21 | // Possible outcomes of a vote |
22 | 22 | public const OUTCOME_OK = 0; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * because they can vary depending on whether the page is a vote, which is relatively |
36 | 36 | * expensive to know since it requires parsing the content of the page. |
37 | 37 | */ |
38 | - private function defineSections(): void { |
|
38 | + private function defineSections (): void { |
|
39 | 39 | $this->supportSection = $this->isVote() ? 3 : 0; |
40 | 40 | $this->opposeSection = $this->isVote() ? 4 : 3; |
41 | 41 | } |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return string |
47 | 47 | */ |
48 | - public function getUserName(): string { |
|
49 | - return explode( '/', $this->title )[2]; |
|
48 | + public function getUserName (): string { |
|
49 | + return explode( '/', $this->title )[ 2 ]; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return int |
56 | 56 | */ |
57 | - public function getNum(): int { |
|
57 | + public function getNum (): int { |
|
58 | 58 | $bits = explode( '/', $this->getTitle() ); |
59 | 59 | return (int)end( $bits ); |
60 | 60 | } |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string |
66 | 66 | */ |
67 | - public function getUserNum(): string { |
|
68 | - return explode( '/', $this->getTitle(), 3 )[2]; |
|
67 | + public function getUserNum (): string { |
|
68 | + return explode( '/', $this->getTitle(), 3 )[ 2 ]; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return int |
75 | 75 | */ |
76 | - public function getOpposingCount(): int { |
|
76 | + public function getOpposingCount (): int { |
|
77 | 77 | $this->defineSections(); |
78 | 78 | return $this->getCountForSection( $this->opposeSection ); |
79 | 79 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @return int |
85 | 85 | * @throws BadMethodCallException |
86 | 86 | */ |
87 | - public function getSupportCount(): int { |
|
87 | + public function getSupportCount (): int { |
|
88 | 88 | if ( !$this->isVote() ) { |
89 | 89 | throw new BadMethodCallException( 'Cannot get support for a non-vote page.' ); |
90 | 90 | } |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | * @param int $secNum |
99 | 99 | * @return int |
100 | 100 | */ |
101 | - protected function getCountForSection( int $secNum ): int { |
|
101 | + protected function getCountForSection ( int $secNum ): int { |
|
102 | 102 | if ( !isset( $this->sectionCounts[ $secNum ] ) ) { |
103 | 103 | $content = $this->wiki->getPageContent( $this->title, $secNum ); |
104 | 104 | // Let's hope that this is good enough... |
105 | - $this->sectionCounts[$secNum] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content ); |
|
105 | + $this->sectionCounts[ $secNum ] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content ); |
|
106 | 106 | } |
107 | - return $this->sectionCounts[$secNum]; |
|
107 | + return $this->sectionCounts[ $secNum ]; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return int |
114 | 114 | */ |
115 | - protected function getQuorum(): int { |
|
115 | + protected function getQuorum (): int { |
|
116 | 116 | $reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!"; |
117 | - return (int)$this->getMatch( $reg )[1]; |
|
117 | + return (int)$this->getMatch( $reg )[ 1 ]; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return bool |
124 | 124 | */ |
125 | - public function hasOpposition(): bool { |
|
125 | + public function hasOpposition (): bool { |
|
126 | 126 | return $this->getOpposingCount() >= self::REQUIRED_OPPOSE; |
127 | 127 | } |
128 | 128 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return int One of the OUTCOME_* constants |
133 | 133 | */ |
134 | - public function getOutcome(): int { |
|
134 | + public function getOutcome (): int { |
|
135 | 135 | if ( !$this->isVote() ) { |
136 | 136 | return self::OUTCOME_OK; |
137 | 137 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @throws BadMethodCallException |
155 | 155 | * @throws LogicException |
156 | 156 | */ |
157 | - public function getOutcomeText(): string { |
|
157 | + public function getOutcomeText (): string { |
|
158 | 158 | if ( !$this->isVote() ) { |
159 | 159 | throw new BadMethodCallException( 'No need for an outcome text.' ); |
160 | 160 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return bool |
190 | 190 | */ |
191 | - public function isVote(): bool { |
|
191 | + public function isVote (): bool { |
|
192 | 192 | $sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/'; |
193 | 193 | return !$this->matches( $sectionReg ); |
194 | 194 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @return int |
200 | 200 | */ |
201 | - public function getCreationTimestamp(): int { |
|
201 | + public function getCreationTimestamp (): int { |
|
202 | 202 | return $this->wiki->getPageCreationTS( $this->title ); |
203 | 203 | } |
204 | 204 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return int |
209 | 209 | */ |
210 | - public function getEndTimestamp(): int { |
|
210 | + public function getEndTimestamp (): int { |
|
211 | 211 | if ( $this->isVote() ) { |
212 | 212 | $reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!"; |
213 | 213 | [ , $hours, $day ] = $this->getMatch( $reg ); |
@@ -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 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 |
||
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->wiki->getPageContent( $this->title, $section ); |
46 | 46 | } |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | * @phan-param array<int|string|bool> $params |
55 | 55 | * @throws LogicException |
56 | 56 | */ |
57 | - public function edit( array $params ): void { |
|
57 | + public function edit ( array $params ): void { |
|
58 | 58 | $params = [ |
59 | 59 | 'title' => $this->getTitle() |
60 | 60 | ] + $params; |
61 | 61 | |
62 | 62 | $this->wiki->editPage( $params ); |
63 | - if ( isset( $params['text'] ) ) { |
|
64 | - $this->content = $params['text']; |
|
65 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
66 | - $this->content .= $params['appendtext']; |
|
67 | - } elseif ( isset( $params['prependtext'] ) ) { |
|
68 | - $this->content = $params['prependtext'] . $this->content; |
|
63 | + if ( isset( $params[ 'text' ] ) ) { |
|
64 | + $this->content = $params[ 'text' ]; |
|
65 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
66 | + $this->content .= $params[ 'appendtext' ]; |
|
67 | + } elseif ( isset( $params[ 'prependtext' ] ) ) { |
|
68 | + $this->content = $params[ 'prependtext' ] . $this->content; |
|
69 | 69 | } else { |
70 | 70 | throw new LogicException( |
71 | 71 | 'Unrecognized text param for edit. Params: ' . var_export( $params, true ) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public function exists(): bool { |
|
81 | + public function exists (): bool { |
|
82 | 82 | $pages = $this->wiki->getRequestFactory()->newFromParams( [ |
83 | 83 | 'action' => 'query', |
84 | 84 | 'titles' => $this->getTitle() |
@@ -92,7 +92,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
126 | 126 | * |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - public function __toString(): string { |
|
129 | + public function __toString (): string { |
|
130 | 130 | return $this->getTitle(); |
131 | 131 | } |
132 | 132 | } |
@@ -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; |
4 | 4 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param array $info |
22 | 22 | * @phan-param array<string,string|string[]> $info |
23 | 23 | */ |
24 | - public function __construct( string $name, array $info ) { |
|
24 | + public function __construct ( string $name, array $info ) { |
|
25 | 25 | $this->name = $name; |
26 | 26 | $this->info = $info; |
27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @return string |
31 | 31 | */ |
32 | - public function getName(): string { |
|
32 | + public function getName (): string { |
|
33 | 33 | return $this->name; |
34 | 34 | } |
35 | 35 | |
@@ -37,28 +37,28 @@ discard block |
||
37 | 37 | * @return array |
38 | 38 | * @phan-return array<string,string|string[]> |
39 | 39 | */ |
40 | - public function getInfo(): array { |
|
40 | + public function getInfo (): array { |
|
41 | 41 | return $this->info; |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @return string[] |
46 | 46 | */ |
47 | - public function extractGroups(): array { |
|
47 | + public function extractGroups (): array { |
|
48 | 48 | return array_keys( $this->extractGroupsWithDates() ); |
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @return string[] |
53 | 53 | */ |
54 | - public function extractGroupsWithDates(): array { |
|
54 | + public function extractGroupsWithDates (): array { |
|
55 | 55 | return array_intersect_key( $this->getInfo(), array_fill_keys( self::GROUP_KEYS, 1 ) ); |
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @return string[] |
60 | 60 | */ |
61 | - public function getAliases(): array { |
|
62 | - return $this->getInfo()['aliases'] ?? []; |
|
61 | + public function getAliases (): array { |
|
62 | + return $this->getInfo()[ 'aliases' ] ?? [ ]; |
|
63 | 63 | } |
64 | 64 | } |
@@ -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; |
4 | 4 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param LoggerInterface $logger |
37 | 37 | * @param RequestFactory $requestFactory |
38 | 38 | */ |
39 | - public function __construct( |
|
39 | + public function __construct ( |
|
40 | 40 | LoginInfo $li, |
41 | 41 | LoggerInterface $logger, |
42 | 42 | RequestFactory $requestFactory |
@@ -49,35 +49,35 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @return LoginInfo |
51 | 51 | */ |
52 | - public function getLoginInfo(): LoginInfo { |
|
52 | + public function getLoginInfo (): LoginInfo { |
|
53 | 53 | return $this->loginInfo; |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @return RequestFactory |
58 | 58 | */ |
59 | - public function getRequestFactory(): RequestFactory { |
|
59 | + public function getRequestFactory (): RequestFactory { |
|
60 | 60 | return $this->requestFactory; |
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param string $prefix |
65 | 65 | */ |
66 | - public function setPagePrefix( string $prefix ): void { |
|
66 | + public function setPagePrefix ( string $prefix ): void { |
|
67 | 67 | $this->pagePrefix = $prefix; |
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @param string $ident |
72 | 72 | */ |
73 | - public function setLocalUserIdentifier( string $ident ): void { |
|
73 | + public function setLocalUserIdentifier ( string $ident ): void { |
|
74 | 74 | $this->localUserIdentifier = $ident; |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - public function getLocalUserIdentifier(): string { |
|
80 | + public function getLocalUserIdentifier (): string { |
|
81 | 81 | return $this->localUserIdentifier; |
82 | 82 | } |
83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param string $title |
86 | 86 | * @param int|null $section |
87 | 87 | */ |
88 | - private function logRead( string $title, int $section = null ): void { |
|
88 | + private function logRead ( string $title, int $section = null ): void { |
|
89 | 89 | $fullTitle = $this->pagePrefix . $title; |
90 | 90 | $msg = "Retrieving content of $fullTitle" . ( $section !== null ? ", section $section" : '' ); |
91 | 91 | $this->logger->info( $msg ); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @throws MissingPageException |
101 | 101 | * @throws MissingSectionException |
102 | 102 | */ |
103 | - public function getPageContent( string $title, int $section = null ): string { |
|
103 | + public function getPageContent ( string $title, int $section = null ): string { |
|
104 | 104 | $this->logRead( $title, $section ); |
105 | 105 | $params = [ |
106 | 106 | 'action' => 'query', |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | ]; |
112 | 112 | |
113 | 113 | if ( $section !== null ) { |
114 | - $params['rvsection'] = $section; |
|
114 | + $params[ 'rvsection' ] = $section; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $req = $this->buildRequest( $params ); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | throw new MissingPageException( $title ); |
121 | 121 | } |
122 | 122 | |
123 | - $mainSlot = $page->revisions[0]->slots->main; |
|
123 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
124 | 124 | |
125 | 125 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
126 | 126 | throw new MissingSectionException( $title, $section ); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @phan-param array<int|string|bool> $params |
136 | 136 | * @throws EditException |
137 | 137 | */ |
138 | - public function editPage( array $params ): void { |
|
138 | + public function editPage ( array $params ): void { |
|
139 | 139 | $this->login(); |
140 | 140 | |
141 | 141 | $params = [ |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | ] + $params; |
145 | 145 | |
146 | 146 | if ( BOT_EDITS === true ) { |
147 | - $params['bot'] = 1; |
|
147 | + $params[ 'bot' ] = 1; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | $res = $this->buildRequest( $params )->setPost()->executeSingle(); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
163 | 163 | * @throws LoginException |
164 | 164 | */ |
165 | - public function login(): void { |
|
165 | + public function login (): void { |
|
166 | 166 | if ( $this->loginInfo === null ) { |
167 | 167 | throw new CannotLoginException( 'Missing login data' ); |
168 | 168 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | $this->loggedIn = true; |
194 | 194 | // Clear tokens cache |
195 | - $this->tokens = []; |
|
195 | + $this->tokens = [ ]; |
|
196 | 196 | $this->logger->info( 'Login succeeded' ); |
197 | 197 | } |
198 | 198 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param string $type |
203 | 203 | * @return string |
204 | 204 | */ |
205 | - public function getToken( string $type ): string { |
|
205 | + public function getToken ( string $type ): string { |
|
206 | 206 | if ( !isset( $this->tokens[ $type ] ) ) { |
207 | 207 | $params = [ |
208 | 208 | 'action' => 'query', |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param string $title |
223 | 223 | * @return int |
224 | 224 | */ |
225 | - public function getPageCreationTS( string $title ): int { |
|
225 | + public function getPageCreationTS ( string $title ): int { |
|
226 | 226 | $params = [ |
227 | 227 | 'action' => 'query', |
228 | 228 | 'prop' => 'revisions', |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | ]; |
235 | 235 | |
236 | 236 | $page = $this->buildRequest( $params )->executeAsQuery()->current(); |
237 | - return strtotime( $page->revisions[0]->timestamp ); |
|
237 | + return strtotime( $page->revisions[ 0 ]->timestamp ); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @param string $title |
244 | 244 | * @param string $reason |
245 | 245 | */ |
246 | - public function protectPage( string $title, string $reason ): void { |
|
246 | + public function protectPage ( string $title, string $reason ): void { |
|
247 | 247 | $fullTitle = $this->pagePrefix . $title; |
248 | 248 | $this->logger->info( "Protecting page $fullTitle" ); |
249 | 249 | $this->login(); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @param string $username |
267 | 267 | * @param string $reason |
268 | 268 | */ |
269 | - public function blockUser( string $username, string $reason ): void { |
|
269 | + public function blockUser ( string $username, string $reason ): void { |
|
270 | 270 | $this->logger->info( "Blocking user $username" ); |
271 | 271 | $this->login(); |
272 | 272 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @phan-param array<int|string|bool> $params |
294 | 294 | * @return RequestBase |
295 | 295 | */ |
296 | - private function buildRequest( array $params ): RequestBase { |
|
296 | + private function buildRequest ( array $params ): RequestBase { |
|
297 | 297 | return $this->requestFactory->newFromParams( $params ); |
298 | 298 | } |
299 | 299 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme; |
4 | 4 | |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * @return bool |
68 | 68 | */ |
69 | - public static function isCLI(): bool { |
|
69 | + public static function isCLI (): bool { |
|
70 | 70 | return PHP_SAPI === 'cli'; |
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | 74 | * Populate options and check for required ones |
75 | 75 | */ |
76 | - public function __construct() { |
|
76 | + public function __construct () { |
|
77 | 77 | /** @var string[] $opts */ |
78 | 78 | $opts = getopt( self::SHORT_OPTS, self::LONG_OPTS ); |
79 | 79 | $this->checkRequiredOpts( $opts ); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * @param string[] $opts |
87 | 87 | */ |
88 | - private function checkRequiredOpts( array $opts ): void { |
|
88 | + private function checkRequiredOpts ( array $opts ): void { |
|
89 | 89 | $missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) ); |
90 | 90 | if ( $missingOpts ) { |
91 | 91 | $this->fatal( 'Required options missing: ' . implode( ', ', $missingOpts ) ); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | /** |
108 | 108 | * @param string[] $opts |
109 | 109 | */ |
110 | - private function checkConflictingOpts( array $opts ): void { |
|
110 | + private function checkConflictingOpts ( array $opts ): void { |
|
111 | 111 | $this->checkNotBothSet( $opts, 'password', 'use-password-file' ); |
112 | 112 | if ( array_key_exists( 'use-password-file', $opts ) && !file_exists( self::PASSWORD_FILE ) ) { |
113 | 113 | $this->fatal( 'Please create the password file (' . self::PASSWORD_FILE . ')' ); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string $first |
129 | 129 | * @param string $second |
130 | 130 | */ |
131 | - private function checkNotBothSet( array $opts, string $first, string $second ): void { |
|
131 | + private function checkNotBothSet ( array $opts, string $first, string $second ): void { |
|
132 | 132 | if ( array_key_exists( $first, $opts ) && array_key_exists( $second, $opts ) ) { |
133 | 133 | $this->fatal( "Can only use one of '$first' and '$second'" ); |
134 | 134 | } |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * @param string[] &$opts |
139 | 139 | */ |
140 | - private function canonicalize( array &$opts ): void { |
|
140 | + private function canonicalize ( array &$opts ): void { |
|
141 | 141 | if ( array_key_exists( 'use-password-file', $opts ) ) { |
142 | 142 | $pw = trim( file_get_contents( self::PASSWORD_FILE ) ); |
143 | - $opts['password'] = $pw; |
|
144 | - unset( $opts['use-password-file'] ); |
|
143 | + $opts[ 'password' ] = $pw; |
|
144 | + unset( $opts[ 'use-password-file' ] ); |
|
145 | 145 | } |
146 | 146 | if ( array_key_exists( 'use-private-password-file', $opts ) ) { |
147 | 147 | $pw = trim( file_get_contents( self::PRIVATE_PASSWORD_FILE ) ); |
148 | - $opts['private-password'] = $pw; |
|
149 | - unset( $opts['use-private-password-file'] ); |
|
148 | + $opts[ 'private-password' ] = $pw; |
|
149 | + unset( $opts[ 'use-private-password-file' ] ); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | 154 | * @param string $msg |
155 | 155 | */ |
156 | - private function fatal( string $msg ): void { |
|
156 | + private function fatal ( string $msg ): void { |
|
157 | 157 | exit( $msg . "\n" ); |
158 | 158 | } |
159 | 159 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | * @param string $opt |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - public function getSetOpt( string $opt ): string { |
|
166 | - return $this->opts[$opt]; |
|
165 | + public function getSetOpt ( string $opt ): string { |
|
166 | + return $this->opts[ $opt ]; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * @param string|null $default |
172 | 172 | * @return string|null |
173 | 173 | */ |
174 | - public function getOpt( string $opt, string $default = null ): ?string { |
|
175 | - return $this->opts[$opt] ?? $default; |
|
174 | + public function getOpt ( string $opt, string $default = null ): ?string { |
|
175 | + return $this->opts[ $opt ] ?? $default; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
179 | 179 | * @return string[] Either [ 'tasks' => name1,... ] or [ 'subtasks' => name1,... ] |
180 | 180 | */ |
181 | - public function getTaskOpt(): array { |
|
181 | + public function getTaskOpt (): array { |
|
182 | 182 | return array_intersect_key( |
183 | 183 | $this->opts, |
184 | 184 | [ 'tasks' => true, 'subtasks' => true ] |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @return string|null |
190 | 190 | */ |
191 | - public function getURL(): ?string { |
|
191 | + public function getURL (): ?string { |
|
192 | 192 | return $this->getOpt( 'force-url' ); |
193 | 193 | } |
194 | 194 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme; |
4 | 4 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @param CLI $cli |
36 | 36 | */ |
37 | - public function __construct( CLI $cli ) { |
|
37 | + public function __construct ( CLI $cli ) { |
|
38 | 38 | $this->cli = $cli; |
39 | 39 | $this->initialize(); |
40 | 40 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * Initialize all members. |
44 | 44 | */ |
45 | - private function initialize(): void { |
|
45 | + private function initialize (): void { |
|
46 | 46 | $simpleLogger = new SimpleLogger(); |
47 | 47 | $this->createWikiGroup( $simpleLogger ); |
48 | 48 | $this->messageProvider = new MessageProvider( |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * Main entry point |
58 | 58 | */ |
59 | - public function run(): void { |
|
59 | + public function run (): void { |
|
60 | 60 | $taskOpt = $this->cli->getTaskOpt(); |
61 | 61 | $type = current( array_keys( $taskOpt ) ); |
62 | 62 | try { |
63 | 63 | if ( $type === 'tasks' ) { |
64 | - $this->runInternal( TaskManager::MODE_TASK, explode( ',', $taskOpt['tasks'] ) ); |
|
64 | + $this->runInternal( TaskManager::MODE_TASK, explode( ',', $taskOpt[ 'tasks' ] ) ); |
|
65 | 65 | } elseif ( $type === 'subtasks' ) { |
66 | - $this->runInternal( TaskManager::MODE_SUBTASK, explode( ',', $taskOpt['subtasks'] ) ); |
|
66 | + $this->runInternal( TaskManager::MODE_SUBTASK, explode( ',', $taskOpt[ 'subtasks' ] ) ); |
|
67 | 67 | } else { |
68 | 68 | $this->runInternal(); |
69 | 69 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * @param LoggerInterface $baseLogger |
79 | 79 | */ |
80 | - private function createWikiGroup( LoggerInterface $baseLogger ): void { |
|
80 | + private function createWikiGroup ( LoggerInterface $baseLogger ): void { |
|
81 | 81 | // FIXME Hardcoded |
82 | 82 | $url = $this->cli->getURL() ?? 'https://it.wikipedia.org/w/api.php'; |
83 | 83 | $localUserIdentifier = '@itwiki'; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @param IFlushingAwareLogger $baseLogger |
117 | 117 | */ |
118 | - private function createMainLogger( IFlushingAwareLogger $baseLogger ): void { |
|
118 | + private function createMainLogger ( IFlushingAwareLogger $baseLogger ): void { |
|
119 | 119 | $mainWiki = $this->wikiGroup->getMainWiki(); |
120 | 120 | $mp = $this->messageProvider; |
121 | 121 | $errTitle = $this->cli->getOpt( 'error-title' ); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * Create the Config |
144 | 144 | */ |
145 | - private function initConfig(): void { |
|
145 | + private function initConfig (): void { |
|
146 | 146 | $wiki = $this->wikiGroup->getMainWiki(); |
147 | 147 | try { |
148 | 148 | $confValues = json_decode( $wiki->getPageContent( $this->cli->getSetOpt( 'config-title' ) ), true ); |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | * @param string $mode |
160 | 160 | * @param string[] $taskNames |
161 | 161 | */ |
162 | - private function runInternal( |
|
162 | + private function runInternal ( |
|
163 | 163 | string $mode = TaskManager::MODE_COMPLETE, |
164 | - array $taskNames = [] |
|
164 | + array $taskNames = [ ] |
|
165 | 165 | ): void { |
166 | 166 | $activity = $mode === TaskManager::MODE_COMPLETE |
167 | 167 | ? 'full process' |
@@ -181,8 +181,7 @@ discard block |
||
181 | 181 | $base = "Execution of $activity"; |
182 | 182 | if ( $res->isOK() ) { |
183 | 183 | $msg = $res->getStatus() === TaskResult::STATUS_NOTHING ? |
184 | - ': nothing to do' : |
|
185 | - ' completed successfully'; |
|
184 | + ': nothing to do' : ' completed successfully'; |
|
186 | 185 | $this->mainLogger->info( $base . $msg ); |
187 | 186 | } else { |
188 | 187 | $this->mainLogger->error( "$base failed.\n$res" ); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Request; |
4 | 4 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** @var string */ |
42 | 42 | protected $method = self::METHOD_GET; |
43 | 43 | /** @var string[] */ |
44 | - protected $newCookies = []; |
|
44 | + protected $newCookies = [ ]; |
|
45 | 45 | |
46 | 46 | /** @var LoggerInterface */ |
47 | 47 | protected $logger; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @phan-param array<int|string|bool> $params |
55 | 55 | * @param string $domain |
56 | 56 | */ |
57 | - public function __construct( LoggerInterface $logger, array $params, string $domain ) { |
|
57 | + public function __construct ( LoggerInterface $logger, array $params, string $domain ) { |
|
58 | 58 | $this->logger = $logger; |
59 | 59 | $this->params = [ 'format' => 'json' ] + $params; |
60 | 60 | $this->url = $domain; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return self For chaining |
67 | 67 | */ |
68 | - public function setPost(): self { |
|
68 | + public function setPost (): self { |
|
69 | 69 | $this->method = self::METHOD_POST; |
70 | 70 | return $this; |
71 | 71 | } |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | * Execute a query request |
75 | 75 | * @return Generator |
76 | 76 | */ |
77 | - public function executeAsQuery(): Generator { |
|
78 | - if ( ( $this->params['action'] ?? false ) !== 'query' ) { |
|
77 | + public function executeAsQuery (): Generator { |
|
78 | + if ( ( $this->params[ 'action' ] ?? false ) !== 'query' ) { |
|
79 | 79 | throw new BadMethodCallException( 'Not an ApiQuery!' ); |
80 | 80 | } |
81 | 81 | // TODO Is this always correct? |
82 | - $key = $this->params['list'] ?? 'pages'; |
|
82 | + $key = $this->params[ 'list' ] ?? 'pages'; |
|
83 | 83 | $curParams = $this->params; |
84 | 84 | $lim = $this->parseLimit(); |
85 | 85 | do { |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * Execute a request that doesn't need any continuation. |
109 | 109 | * @return stdClass |
110 | 110 | */ |
111 | - public function executeSingle(): stdClass { |
|
111 | + public function executeSingle (): stdClass { |
|
112 | 112 | $curParams = $this->params; |
113 | 113 | $res = $this->makeRequestInternal( $curParams ); |
114 | 114 | $this->handleErrorAndWarnings( $res ); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | /** |
119 | 119 | * @return int |
120 | 120 | */ |
121 | - private function parseLimit(): int { |
|
121 | + private function parseLimit (): int { |
|
122 | 122 | foreach ( $this->params as $name => $val ) { |
123 | 123 | if ( substr( $name, -strlen( 'limit' ) ) === 'limit' ) { |
124 | 124 | return $val === 'max' ? -1 : (int)$val; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param string $resKey |
136 | 136 | * @return int|null |
137 | 137 | */ |
138 | - private function countQueryResults( stdClass $res, string $resKey ): ?int { |
|
138 | + private function countQueryResults ( stdClass $res, string $resKey ): ?int { |
|
139 | 139 | if ( !isset( $res->query->$resKey ) ) { |
140 | 140 | return null; |
141 | 141 | } |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | * @phan-param array<int|string|bool> $params |
164 | 164 | * @return stdClass |
165 | 165 | */ |
166 | - private function makeRequestInternal( array $params ): stdClass { |
|
166 | + private function makeRequestInternal ( array $params ): stdClass { |
|
167 | 167 | if ( $this->method === self::METHOD_POST ) { |
168 | - $params['maxlag'] = self::MAXLAG; |
|
168 | + $params[ 'maxlag' ] = self::MAXLAG; |
|
169 | 169 | } |
170 | - if ( !isset( $params['assert'] ) ) { |
|
171 | - $params['assert'] = 'user'; |
|
170 | + if ( !isset( $params[ 'assert' ] ) ) { |
|
171 | + $params[ 'assert' ] = 'user'; |
|
172 | 172 | } |
173 | 173 | $query = http_build_query( $params ); |
174 | 174 | |
@@ -189,18 +189,18 @@ discard block |
||
189 | 189 | * @param string $params |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - abstract protected function reallyMakeRequest( string $params ): string; |
|
192 | + abstract protected function reallyMakeRequest ( string $params ): string; |
|
193 | 193 | |
194 | 194 | /** |
195 | 195 | * After a request, set cookies for the next ones |
196 | 196 | * |
197 | 197 | * @param string[] $cookies |
198 | 198 | */ |
199 | - protected function setCookies( array $cookies ): void { |
|
199 | + protected function setCookies ( array $cookies ): void { |
|
200 | 200 | foreach ( $cookies as $cookie ) { |
201 | 201 | /** @var string[] $bits */ |
202 | 202 | $bits = explode( ';', $cookie ); |
203 | - [ $name, $value ] = explode( '=', $bits[0] ); |
|
203 | + [ $name, $value ] = explode( '=', $bits[ 0 ] ); |
|
204 | 204 | self::$cookiesToSet[ $name ] = $value; |
205 | 205 | } |
206 | 206 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @param stdClass $res |
212 | 212 | * @return APIRequestException |
213 | 213 | */ |
214 | - private function getException( stdClass $res ): APIRequestException { |
|
214 | + private function getException ( stdClass $res ): APIRequestException { |
|
215 | 215 | switch ( $res->error->code ) { |
216 | 216 | case 'missingtitle': |
217 | 217 | $ex = new MissingPageException; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param stdClass $res |
238 | 238 | * @throws APIRequestException |
239 | 239 | */ |
240 | - protected function handleErrorAndWarnings( stdClass $res ): void { |
|
240 | + protected function handleErrorAndWarnings ( stdClass $res ): void { |
|
241 | 241 | if ( isset( $res->error ) ) { |
242 | 242 | throw $this->getException( $res ); |
243 | 243 | } |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string[] |
255 | 255 | */ |
256 | - protected function getHeaders(): array { |
|
256 | + protected function getHeaders (): array { |
|
257 | 257 | $ret = self::HEADERS; |
258 | 258 | if ( self::$cookiesToSet ) { |
259 | - $cookies = []; |
|
259 | + $cookies = [ ]; |
|
260 | 260 | foreach ( self::$cookiesToSet as $cname => $cval ) { |
261 | - $cookies[] = trim( "$cname=$cval" ); |
|
261 | + $cookies[ ] = trim( "$cname=$cval" ); |
|
262 | 262 | } |
263 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
263 | + $ret[ ] = 'Cookie: ' . implode( '; ', $cookies ); |
|
264 | 264 | } |
265 | 265 | return $ret; |
266 | 266 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param string[] $headers |
272 | 272 | * @return string |
273 | 273 | */ |
274 | - protected function buildHeadersString( array $headers ): string { |
|
274 | + protected function buildHeadersString ( array $headers ): string { |
|
275 | 275 | $ret = ''; |
276 | 276 | foreach ( $headers as $header ) { |
277 | 277 | $ret .= "$header\r\n"; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param string $actualParams |
284 | 284 | * @return string |
285 | 285 | */ |
286 | - protected function getDebugURL( string $actualParams ): string { |
|
286 | + protected function getDebugURL ( string $actualParams ): string { |
|
287 | 287 | return strpos( $this->url, 'login' ) !== false |
288 | 288 | ? '[Login request]' |
289 | 289 | : "{$this->url}?$actualParams"; |