@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | /** |
| 10 | 10 | * @param string|null $title If available |
| 11 | 11 | */ |
| 12 | - public function __construct( string $title = null ) { |
|
| 12 | + public function __construct ( string $title = null ) { |
|
| 13 | 13 | if ( $title ) { |
| 14 | 14 | parent::__construct( "The specified page is protected: $title" ); |
| 15 | 15 | } else { |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | /** |
| 10 | 10 | * @param string|null $title If available |
| 11 | 11 | */ |
| 12 | - public function __construct( string $title = null ) { |
|
| 12 | + public function __construct ( string $title = null ) { |
|
| 13 | 13 | if ( $title ) { |
| 14 | 14 | parent::__construct( "The specified page doesn't exist: $title" ); |
| 15 | 15 | } else { |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -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 | |
@@ -29,14 +29,14 @@ discard block |
||
| 29 | 29 | /** @var string */ |
| 30 | 30 | protected $method = 'GET'; |
| 31 | 31 | /** @var string[] */ |
| 32 | - protected $newCookies = []; |
|
| 32 | + protected $newCookies = [ ]; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Use self::newFromParams, which will provide the right class to use |
| 36 | 36 | * |
| 37 | 37 | * @param array $params |
| 38 | 38 | */ |
| 39 | - protected function __construct( array $params ) { |
|
| 39 | + protected function __construct ( array $params ) { |
|
| 40 | 40 | $this->params = [ 'format' => 'json' ] + $params; |
| 41 | 41 | $this->url = DEFAULT_URL; |
| 42 | 42 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param array $params |
| 48 | 48 | * @return self |
| 49 | 49 | */ |
| 50 | - public static function newFromParams( array $params ) : self { |
|
| 50 | + public static function newFromParams ( array $params ) : self { |
|
| 51 | 51 | if ( extension_loaded( 'curl' ) ) { |
| 52 | 52 | $ret = new CurlRequest( $params ); |
| 53 | 53 | } else { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return self For chaining |
| 63 | 63 | */ |
| 64 | - public function setPost() : self { |
|
| 64 | + public function setPost () : self { |
|
| 65 | 65 | $this->method = 'POST'; |
| 66 | 66 | return $this; |
| 67 | 67 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param string $url |
| 73 | 73 | * @return self for chaining |
| 74 | 74 | */ |
| 75 | - public function setUrl( string $url ) : self { |
|
| 75 | + public function setUrl ( string $url ) : self { |
|
| 76 | 76 | $this->url = $url; |
| 77 | 77 | return $this; |
| 78 | 78 | } |
@@ -82,14 +82,14 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return \stdClass |
| 84 | 84 | */ |
| 85 | - public function execute() : \stdClass { |
|
| 85 | + public function execute () : \stdClass { |
|
| 86 | 86 | $curParams = $this->params; |
| 87 | - $sets = []; |
|
| 87 | + $sets = [ ]; |
|
| 88 | 88 | do { |
| 89 | 89 | $res = $this->makeRequestInternal( $curParams ); |
| 90 | 90 | |
| 91 | 91 | $this->handleErrorAndWarnings( $res ); |
| 92 | - $sets[] = $res; |
|
| 92 | + $sets[ ] = $res; |
|
| 93 | 93 | |
| 94 | 94 | $finished = true; |
| 95 | 95 | if ( isset( $res->continue ) ) { |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | * @param array $params |
| 108 | 108 | * @return \stdClass |
| 109 | 109 | */ |
| 110 | - private function makeRequestInternal( array $params ) : \stdClass { |
|
| 110 | + private function makeRequestInternal ( array $params ) : \stdClass { |
|
| 111 | 111 | if ( $this->method === 'POST' ) { |
| 112 | - $params['maxlag'] = self::MAXLAG; |
|
| 112 | + $params[ 'maxlag' ] = self::MAXLAG; |
|
| 113 | 113 | } |
| 114 | 114 | $params = http_build_query( $params ); |
| 115 | 115 | |
@@ -125,17 +125,17 @@ discard block |
||
| 125 | 125 | * @param string $params |
| 126 | 126 | * @return string |
| 127 | 127 | */ |
| 128 | - abstract protected function reallyMakeRequest( string $params ) : string; |
|
| 128 | + abstract protected function reallyMakeRequest ( string $params ) : string; |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * After a request, set cookies for the next ones |
| 132 | 132 | * |
| 133 | 133 | * @param array $cookies |
| 134 | 134 | */ |
| 135 | - protected function setCookies( array $cookies ) { |
|
| 135 | + protected function setCookies ( array $cookies ) { |
|
| 136 | 136 | foreach ( $cookies as $cookie ) { |
| 137 | 137 | $bits = explode( ';', $cookie ); |
| 138 | - list( $name, $value ) = explode( '=', $bits[0] ); |
|
| 138 | + list( $name, $value ) = explode( '=', $bits[ 0 ] ); |
|
| 139 | 139 | self::$cookiesToSet[ $name ] = $value; |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param \stdClass $res |
| 147 | 147 | * @throws APIRequestException |
| 148 | 148 | */ |
| 149 | - protected function handleErrorAndWarnings( $res ) { |
|
| 149 | + protected function handleErrorAndWarnings ( $res ) { |
|
| 150 | 150 | if ( isset( $res->error ) ) { |
| 151 | 151 | switch ( $res->error->code ) { |
| 152 | 152 | case 'missingtitle': |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param \stdClass[] $sets |
| 173 | 173 | * @return \stdClass |
| 174 | 174 | */ |
| 175 | - private function mergeSets( array $sets ) : \stdClass { |
|
| 175 | + private function mergeSets ( array $sets ) : \stdClass { |
|
| 176 | 176 | // Use the first set as template |
| 177 | 177 | $ret = array_shift( $sets ); |
| 178 | 178 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param array|\stdClass $second |
| 190 | 190 | * @return array|\stdClass array |
| 191 | 191 | */ |
| 192 | - private function recursiveMerge( $first, $second ) { |
|
| 192 | + private function recursiveMerge ( $first, $second ) { |
|
| 193 | 193 | $ret = $first; |
| 194 | 194 | if ( is_array( $second ) ) { |
| 195 | 195 | $ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second; |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return array |
| 209 | 209 | */ |
| 210 | - protected function getHeaders() :array { |
|
| 210 | + protected function getHeaders () :array { |
|
| 211 | 211 | $ret = self::HEADERS; |
| 212 | 212 | if ( self::$cookiesToSet ) { |
| 213 | - $cookies = []; |
|
| 213 | + $cookies = [ ]; |
|
| 214 | 214 | foreach ( self::$cookiesToSet as $cname => $cval ) { |
| 215 | - $cookies[] = trim( "$cname=$cval" ); |
|
| 215 | + $cookies[ ] = trim( "$cname=$cval" ); |
|
| 216 | 216 | } |
| 217 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 217 | + $ret[ ] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 218 | 218 | } |
| 219 | 219 | return $ret; |
| 220 | 220 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param array $headers |
| 226 | 226 | * @return string |
| 227 | 227 | */ |
| 228 | - protected function buildHeadersString( array $headers ) : string { |
|
| 228 | + protected function buildHeadersString ( array $headers ) : string { |
|
| 229 | 229 | $ret = ''; |
| 230 | 230 | foreach ( $headers as $header ) { |
| 231 | 231 | $ret .= "$header\r\n"; |
@@ -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 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | /** |
| 10 | 10 | * @inheritDoc |
| 11 | 11 | */ |
| 12 | - protected function reallyMakeRequest( string $params ) : string { |
|
| 12 | + protected function reallyMakeRequest ( string $params ) : string { |
|
| 13 | 13 | $context = [ |
| 14 | 14 | 'http' => [ |
| 15 | 15 | 'method' => $this->method, |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | ]; |
| 19 | 19 | $url = $this->url; |
| 20 | 20 | if ( $this->method === 'POST' ) { |
| 21 | - $context['http']['content'] = $params; |
|
| 21 | + $context[ 'http' ][ 'content' ] = $params; |
|
| 22 | 22 | } else { |
| 23 | 23 | $url = "$url?$params"; |
| 24 | 24 | } |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | foreach ( $http_response_header as $header ) { |
| 29 | 29 | $bits = explode( ':', $header, 2 ); |
| 30 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 31 | - $this->newCookies[] = $bits[1]; |
|
| 30 | + if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
| 31 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |