@@ -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; |
| 4 | 4 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - public function log( $level, $message, array $context = [] ) { |
|
| 15 | - error_log( "$level - $message" ); |
|
| 14 | + public function log ( $level, $message, array $context = [ ] ) { |
|
| 15 | + error_log ( "$level - $message" ); |
|
| 16 | 16 | } |
| 17 | 17 | } |
@@ -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 | |
@@ -10,26 +10,26 @@ discard block |
||
| 10 | 10 | private $users; |
| 11 | 11 | |
| 12 | 12 | /** @var string[] */ |
| 13 | - private $createdPages = []; |
|
| 13 | + private $createdPages = [ ]; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Get a list of users to execute tasks on. |
| 17 | 17 | * |
| 18 | 18 | * @return array[] |
| 19 | 19 | */ |
| 20 | - public function getUsersToProcess() : array { |
|
| 20 | + public function getUsersToProcess () : array { |
|
| 21 | 21 | if ( $this->users === null ) { |
| 22 | - $this->getLogger()->debug( 'Retrieving users list' ); |
|
| 23 | - $content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) ); |
|
| 24 | - $listUsers = json_decode( $content, true ); |
|
| 22 | + $this->getLogger ()->debug ( 'Retrieving users list' ); |
|
| 23 | + $content = $this->getController ()->getPageContent ( $this->getConfig ()->get ( 'list-title' ) ); |
|
| 24 | + $listUsers = json_decode ( $content, true ); |
|
| 25 | 25 | |
| 26 | - $this->users = []; |
|
| 26 | + $this->users = [ ]; |
|
| 27 | 27 | foreach ( $listUsers as $user => $groups ) { |
| 28 | - $timestamp = $this->getValidTimestamp( $groups ); |
|
| 28 | + $timestamp = $this->getValidTimestamp ( $groups ); |
|
| 29 | 29 | |
| 30 | - if ( date( 'd/m', $timestamp ) === date( 'd/m' ) && |
|
| 30 | + if ( date ( 'd/m', $timestamp ) === date ( 'd/m' ) && |
|
| 31 | 31 | // Don't trigger if the date is actually today |
| 32 | - date( 'd/m/Y', $timestamp ) !== date( 'd/m/Y' ) |
|
| 32 | + date ( 'd/m/Y', $timestamp ) !== date ( 'd/m/Y' ) |
|
| 33 | 33 | ) { |
| 34 | 34 | $this->users[ $user ] = $groups; |
| 35 | 35 | } |
@@ -45,17 +45,15 @@ discard block |
||
| 45 | 45 | * @param array $groups |
| 46 | 46 | * @return int |
| 47 | 47 | */ |
| 48 | - private function getValidTimestamp( array $groups ) : int { |
|
| 48 | + private function getValidTimestamp ( array $groups ) : int { |
|
| 49 | 49 | $checkuser = isset( $groups[ 'checkuser' ] ) ? |
| 50 | - \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : |
|
| 51 | - 0; |
|
| 50 | + \DateTime::createFromFormat ( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp () : 0; |
|
| 52 | 51 | $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
| 53 | - \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : |
|
| 54 | - 0; |
|
| 52 | + \DateTime::createFromFormat ( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp () : 0; |
|
| 55 | 53 | |
| 56 | - $timestamp = max( $bureaucrat, $checkuser ); |
|
| 54 | + $timestamp = max ( $bureaucrat, $checkuser ); |
|
| 57 | 55 | if ( $timestamp === 0 ) { |
| 58 | - $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp(); |
|
| 56 | + $timestamp = \DateTime::createFromFormat ( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp (); |
|
| 59 | 57 | } |
| 60 | 58 | return $timestamp; |
| 61 | 59 | } |
@@ -65,21 +63,21 @@ discard block |
||
| 65 | 63 | * |
| 66 | 64 | * @param string $name |
| 67 | 65 | */ |
| 68 | - public function removeUser( string $name ) { |
|
| 66 | + public function removeUser ( string $name ) { |
|
| 69 | 67 | unset( $this->users[ $name ] ); |
| 70 | 68 | } |
| 71 | 69 | |
| 72 | 70 | /** |
| 73 | 71 | * @return string[] |
| 74 | 72 | */ |
| 75 | - public function getCreatedPages() : array { |
|
| 73 | + public function getCreatedPages () : array { |
|
| 76 | 74 | return $this->createdPages; |
| 77 | 75 | } |
| 78 | 76 | |
| 79 | 77 | /** |
| 80 | 78 | * @param string $title |
| 81 | 79 | */ |
| 82 | - public function addCreatedPages( string $title ) { |
|
| 83 | - $this->createdPages[] = $title; |
|
| 80 | + public function addCreatedPages ( string $title ) { |
|
| 81 | + $this->createdPages[ ] = $title; |
|
| 84 | 82 | } |
| 85 | 83 | } |
@@ -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,7 +29,7 @@ discard block |
||
| 29 | 29 | /** @var string */ |
| 30 | 30 | protected $method; |
| 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 |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param array $params |
| 38 | 38 | * @param bool $isPOST |
| 39 | 39 | */ |
| 40 | - protected function __construct( array $params, bool $isPOST = false ) { |
|
| 40 | + protected function __construct ( array $params, bool $isPOST = false ) { |
|
| 41 | 41 | $this->params = [ 'format' => 'json' ] + $params; |
| 42 | 42 | $this->method = $isPOST ? 'POST' : 'GET'; |
| 43 | 43 | } |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | * @param bool $isPOST |
| 50 | 50 | * @return self |
| 51 | 51 | */ |
| 52 | - public static function newFromParams( array $params, bool $isPOST = false ) : self { |
|
| 53 | - if ( extension_loaded( 'curl' ) ) { |
|
| 54 | - $ret = new CurlRequest( $params, $isPOST ); |
|
| 52 | + public static function newFromParams ( array $params, bool $isPOST = false ) : self { |
|
| 53 | + if ( extension_loaded ( 'curl' ) ) { |
|
| 54 | + $ret = new CurlRequest ( $params, $isPOST ); |
|
| 55 | 55 | } else { |
| 56 | - $ret = new NativeRequest( $params, $isPOST ); |
|
| 56 | + $ret = new NativeRequest ( $params, $isPOST ); |
|
| 57 | 57 | } |
| 58 | 58 | return $ret; |
| 59 | 59 | } |
@@ -63,23 +63,23 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return array |
| 65 | 65 | */ |
| 66 | - public function execute() : array { |
|
| 66 | + public function execute () : array { |
|
| 67 | 67 | $curParams = $this->params; |
| 68 | - $sets = []; |
|
| 68 | + $sets = [ ]; |
|
| 69 | 69 | do { |
| 70 | - $res = $this->makeRequestInternal( $curParams ); |
|
| 70 | + $res = $this->makeRequestInternal ( $curParams ); |
|
| 71 | 71 | |
| 72 | - $this->handleErrorAndWarnings( $res ); |
|
| 73 | - $sets[] = $res; |
|
| 72 | + $this->handleErrorAndWarnings ( $res ); |
|
| 73 | + $sets[ ] = $res; |
|
| 74 | 74 | |
| 75 | 75 | $finished = true; |
| 76 | 76 | if ( isset( $res->continue ) ) { |
| 77 | - $curParams = array_merge( $curParams, get_object_vars( $res->continue ) ); |
|
| 77 | + $curParams = array_merge ( $curParams, get_object_vars ( $res->continue ) ); |
|
| 78 | 78 | $finished = false; |
| 79 | 79 | } |
| 80 | 80 | } while ( !$finished ); |
| 81 | 81 | |
| 82 | - return $this->mergeSets( $sets ); |
|
| 82 | + return $this->mergeSets ( $sets ); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -88,16 +88,16 @@ discard block |
||
| 88 | 88 | * @param array $params |
| 89 | 89 | * @return \stdClass |
| 90 | 90 | */ |
| 91 | - private function makeRequestInternal( array $params ) : \stdClass { |
|
| 91 | + private function makeRequestInternal ( array $params ) : \stdClass { |
|
| 92 | 92 | if ( $this->method === 'POST' ) { |
| 93 | - $params['maxlag'] = self::MAXLAG; |
|
| 93 | + $params[ 'maxlag' ] = self::MAXLAG; |
|
| 94 | 94 | } |
| 95 | - $params = http_build_query( $params ); |
|
| 95 | + $params = http_build_query ( $params ); |
|
| 96 | 96 | |
| 97 | - $body = $this->reallyMakeRequest( $params ); |
|
| 97 | + $body = $this->reallyMakeRequest ( $params ); |
|
| 98 | 98 | |
| 99 | - $this->setCookies( $this->newCookies ); |
|
| 100 | - return json_decode( $body ); |
|
| 99 | + $this->setCookies ( $this->newCookies ); |
|
| 100 | + return json_decode ( $body ); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -106,17 +106,17 @@ discard block |
||
| 106 | 106 | * @param string $params |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | - abstract protected function reallyMakeRequest( string $params ) : string; |
|
| 109 | + abstract protected function reallyMakeRequest ( string $params ) : string; |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * After a request, set cookies for the next ones |
| 113 | 113 | * |
| 114 | 114 | * @param array $cookies |
| 115 | 115 | */ |
| 116 | - protected function setCookies( array $cookies ) { |
|
| 116 | + protected function setCookies ( array $cookies ) { |
|
| 117 | 117 | foreach ( $cookies as $cookie ) { |
| 118 | - $bits = explode( ';', $cookie ); |
|
| 119 | - list( $name, $value ) = explode( '=', $bits[0] ); |
|
| 118 | + $bits = explode ( ';', $cookie ); |
|
| 119 | + list( $name, $value ) = explode ( '=', $bits[ 0 ] ); |
|
| 120 | 120 | self::$cookiesToSet[ $name ] = $value; |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param \stdClass $res |
| 128 | 128 | * @throws APIRequestException |
| 129 | 129 | */ |
| 130 | - protected function handleErrorAndWarnings( $res ) { |
|
| 130 | + protected function handleErrorAndWarnings ( $res ) { |
|
| 131 | 131 | if ( isset( $res->error ) ) { |
| 132 | 132 | switch ( $res->error->code ) { |
| 133 | 133 | case 'missingtitle': |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | $ex = new ProtectedPageException; |
| 138 | 138 | break; |
| 139 | 139 | default: |
| 140 | - $ex = new APIRequestException( $res->error->code . ' - ' . $res->error->info ); |
|
| 140 | + $ex = new APIRequestException ( $res->error->code . ' - ' . $res->error->info ); |
|
| 141 | 141 | } |
| 142 | 142 | throw $ex; |
| 143 | 143 | } elseif ( isset( $res->warnings ) ) { |
| 144 | 144 | $act = $this->params[ 'action' ]; |
| 145 | 145 | $warning = $res->warnings->$act; |
| 146 | - throw new APIRequestException( reset( $warning ) ); |
|
| 146 | + throw new APIRequestException ( reset ( $warning ) ); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | * @param \stdClass[] $sets |
| 154 | 154 | * @return array |
| 155 | 155 | */ |
| 156 | - private function mergeSets( array $sets ) : array { |
|
| 157 | - $sets = $this->objectToArray( $sets ); |
|
| 156 | + private function mergeSets ( array $sets ) : array { |
|
| 157 | + $sets = $this->objectToArray ( $sets ); |
|
| 158 | 158 | // Use the first set as template |
| 159 | - $ret = array_shift( $sets ); |
|
| 160 | - $act = $this->params['action']; |
|
| 159 | + $ret = array_shift ( $sets ); |
|
| 160 | + $act = $this->params[ 'action' ]; |
|
| 161 | 161 | |
| 162 | 162 | foreach ( $sets as $set ) { |
| 163 | - $ret[$act] = array_merge_recursive( |
|
| 164 | - $this->objectToArray( $ret[$act] ), |
|
| 165 | - $this->objectToArray( $set[$act] ) |
|
| 163 | + $ret[ $act ] = array_merge_recursive ( |
|
| 164 | + $this->objectToArray ( $ret[ $act ] ), |
|
| 165 | + $this->objectToArray ( $set[ $act ] ) |
|
| 166 | 166 | ); |
| 167 | 167 | } |
| 168 | 168 | return $ret; |
@@ -175,16 +175,16 @@ discard block |
||
| 175 | 175 | * @param \stdClass|array $objOrArray |
| 176 | 176 | * @return array |
| 177 | 177 | */ |
| 178 | - private function objectToArray( $objOrArray ) : array { |
|
| 179 | - $array = []; |
|
| 180 | - if ( is_object( $objOrArray ) ) { |
|
| 181 | - $objOrArray = get_object_vars( $objOrArray ); |
|
| 178 | + private function objectToArray ( $objOrArray ) : array { |
|
| 179 | + $array = [ ]; |
|
| 180 | + if ( is_object ( $objOrArray ) ) { |
|
| 181 | + $objOrArray = get_object_vars ( $objOrArray ); |
|
| 182 | 182 | } |
| 183 | 183 | foreach ( $objOrArray as $key => $value ) { |
| 184 | - if ( is_object( $value ) || is_array( $value ) ) { |
|
| 185 | - $value = $this->objectToArray( $value ); |
|
| 184 | + if ( is_object ( $value ) || is_array ( $value ) ) { |
|
| 185 | + $value = $this->objectToArray ( $value ); |
|
| 186 | 186 | } |
| 187 | - $array[$key] = $value; |
|
| 187 | + $array[ $key ] = $value; |
|
| 188 | 188 | } |
| 189 | 189 | return $array; |
| 190 | 190 | } |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @return array |
| 196 | 196 | */ |
| 197 | - protected function getHeaders() :array { |
|
| 197 | + protected function getHeaders () :array { |
|
| 198 | 198 | $ret = self::HEADERS; |
| 199 | 199 | if ( self::$cookiesToSet ) { |
| 200 | - $cookies = []; |
|
| 200 | + $cookies = [ ]; |
|
| 201 | 201 | foreach ( self::$cookiesToSet as $cname => $cval ) { |
| 202 | - $cookies[] = trim( "$cname=$cval" ); |
|
| 202 | + $cookies[ ] = trim ( "$cname=$cval" ); |
|
| 203 | 203 | } |
| 204 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 204 | + $ret[ ] = 'Cookie: ' . implode ( '; ', $cookies ); |
|
| 205 | 205 | } |
| 206 | 206 | return $ret; |
| 207 | 207 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * @param array $headers |
| 213 | 213 | * @return string |
| 214 | 214 | */ |
| 215 | - protected function buildHeadersString( array $headers ) : string { |
|
| 215 | + protected function buildHeadersString ( array $headers ) : string { |
|
| 216 | 216 | $ret = ''; |
| 217 | 217 | foreach ( $headers as $header ) { |
| 218 | 218 | $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,26 +9,26 @@ 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, |
| 16 | - 'header' => $this->buildHeadersString( $this->getHeaders() ) |
|
| 16 | + 'header' => $this->buildHeadersString ( $this->getHeaders () ) |
|
| 17 | 17 | ] |
| 18 | 18 | ]; |
| 19 | 19 | $url = self::$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 | } |
| 25 | - $context = stream_context_create( $context ); |
|
| 26 | - $body = file_get_contents( $url, false, $context ); |
|
| 25 | + $context = stream_context_create ( $context ); |
|
| 26 | + $body = file_get_contents ( $url, false, $context ); |
|
| 27 | 27 | |
| 28 | 28 | foreach ( $http_response_header as $header ) { |
| 29 | - $bits = explode( ':', $header, 2 ); |
|
| 30 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 31 | - $this->newCookies[] = $bits[1]; |
|
| 29 | + $bits = explode ( ':', $header, 2 ); |
|
| 30 | + if ( trim ( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
| 31 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
@@ -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 | |
@@ -11,36 +11,36 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - protected function reallyMakeRequest( string $params ) : string { |
|
| 15 | - $curl = curl_init(); |
|
| 14 | + protected function reallyMakeRequest ( string $params ) : string { |
|
| 15 | + $curl = curl_init (); |
|
| 16 | 16 | if ( $curl === false ) { |
| 17 | - throw new APIRequestException( 'Cannot open cURL handler.' ); |
|
| 17 | + throw new APIRequestException ( 'Cannot open cURL handler.' ); |
|
| 18 | 18 | } |
| 19 | - curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); |
|
| 20 | - curl_setopt( $curl, CURLOPT_HEADER, true ); |
|
| 21 | - curl_setopt( $curl, CURLOPT_HEADERFUNCTION, [ $this, 'headersHandler' ] ); |
|
| 22 | - curl_setopt( $curl, CURLOPT_HTTPHEADER, $this->getHeaders() ); |
|
| 19 | + curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true ); |
|
| 20 | + curl_setopt ( $curl, CURLOPT_HEADER, true ); |
|
| 21 | + curl_setopt ( $curl, CURLOPT_HEADERFUNCTION, [ $this, 'headersHandler' ] ); |
|
| 22 | + curl_setopt ( $curl, CURLOPT_HTTPHEADER, $this->getHeaders () ); |
|
| 23 | 23 | |
| 24 | 24 | $url = self::$url; |
| 25 | 25 | if ( $this->method === 'POST' ) { |
| 26 | - curl_setopt( $curl, CURLOPT_URL, $url ); |
|
| 27 | - curl_setopt( $curl, CURLOPT_POST, true ); |
|
| 28 | - curl_setopt( $curl, CURLOPT_POSTFIELDS, $params ); |
|
| 26 | + curl_setopt ( $curl, CURLOPT_URL, $url ); |
|
| 27 | + curl_setopt ( $curl, CURLOPT_POST, true ); |
|
| 28 | + curl_setopt ( $curl, CURLOPT_POSTFIELDS, $params ); |
|
| 29 | 29 | } else { |
| 30 | - curl_setopt( $curl, CURLOPT_URL, "$url?$params" ); |
|
| 30 | + curl_setopt ( $curl, CURLOPT_URL, "$url?$params" ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - $result = curl_exec( $curl ); |
|
| 33 | + $result = curl_exec ( $curl ); |
|
| 34 | 34 | |
| 35 | 35 | if ( $result === false ) { |
| 36 | - throw new APIRequestException( curl_error( $curl ) ); |
|
| 36 | + throw new APIRequestException ( curl_error ( $curl ) ); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Extract response body |
| 40 | - $headerSize = curl_getinfo( $curl, CURLINFO_HEADER_SIZE ); |
|
| 40 | + $headerSize = curl_getinfo ( $curl, CURLINFO_HEADER_SIZE ); |
|
| 41 | 41 | /** @var string $result Because RETURNTRANSFER is set */ |
| 42 | - $body = substr( $result, $headerSize ); |
|
| 43 | - curl_close( $curl ); |
|
| 42 | + $body = substr ( $result, $headerSize ); |
|
| 43 | + curl_close ( $curl ); |
|
| 44 | 44 | |
| 45 | 45 | return $body; |
| 46 | 46 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | * @return int |
| 54 | 54 | * @internal Only used as CB for cURL |
| 55 | 55 | */ |
| 56 | - public function headersHandler( $ch, string $header ) : int { |
|
| 57 | - $bits = explode( ':', $header, 2 ); |
|
| 58 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 59 | - $this->newCookies[] = $bits[1]; |
|
| 56 | + public function headersHandler ( $ch, string $header ) : int { |
|
| 57 | + $bits = explode ( ':', $header, 2 ); |
|
| 58 | + if ( trim ( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
| 59 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
| 60 | 60 | } |
| 61 | 61 | // @phan-suppress-next-line PhanTypeMismatchReturn WTF? Why does phan thinks this is a string? |
| 62 | - return strlen( $header ); |
|
| 62 | + return strlen ( $header ); |
|
| 63 | 63 | } |
| 64 | 64 | } |