Skip to content

Commit b832f1b

Browse files
committed
🚿
1 parent b98bbf5 commit b832f1b

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/CurlUtils/CurlHandle.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public function init():CurlHandle{
293293
}
294294

295295
// overwrite the default values with $curl_options
296-
foreach($this->options->curl_options as $k => $v){
296+
foreach($this->options->curl_options ?? [] as $k => $v){
297297
// skip some options that are only set automatically
298298
if(in_array($k, [CURLOPT_HTTPHEADER, CURLOPT_CUSTOMREQUEST, CURLOPT_NOBODY], true)){
299299
continue;
@@ -317,6 +317,7 @@ public function init():CurlHandle{
317317
* @param int $length
318318
*
319319
* @return string
320+
* @noinspection PhpUnusedParameterInspection
320321
*/
321322
public function readfunction($curl, $stream, int $length):string{
322323
return $this->request->getBody()->read($length);
@@ -329,6 +330,7 @@ public function readfunction($curl, $stream, int $length):string{
329330
* @param string $data
330331
*
331332
* @return int
333+
* @noinspection PhpUnusedParameterInspection
332334
*/
333335
public function writefunction($curl, string $data):int{
334336
return $this->response->getBody()->write($data);
@@ -341,6 +343,7 @@ public function writefunction($curl, string $data):int{
341343
* @param string $line
342344
*
343345
* @return int
346+
* @noinspection PhpUnusedParameterInspection
344347
*/
345348
public function headerfunction($curl, string $line):int{
346349
$str = trim($line);

src/Psr17/RequestFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Fig\Http\Message\RequestMethodInterface;
1515
use Psr\Http\Message\{RequestFactoryInterface, RequestInterface};
1616

17-
class RequestFactory implements RequestFactoryInterface, RequestMethodInterface{
17+
final class RequestFactory implements RequestFactoryInterface, RequestMethodInterface{
1818

1919
/**
2020
* @inheritDoc

src/Psr17/StreamFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Psr\Http\Message\{StreamFactoryInterface, StreamInterface};
1515
use InvalidArgumentException, RuntimeException;
1616

17-
use function fopen, in_array, is_file;
17+
use function fopen, in_array, is_file, is_readable;
1818

1919
final class StreamFactory implements StreamFactoryInterface{
2020

@@ -36,7 +36,7 @@ public function createStream(string $content = ''):StreamInterface{
3636
*/
3737
public function createStreamFromFile(string $filename, string $mode = 'r'):StreamInterface{
3838

39-
if(empty($filename) || !is_file($filename)){
39+
if(empty($filename) || !is_file($filename) || !is_readable($filename)){
4040
throw new RuntimeException('invalid file');
4141
}
4242

src/Psr7/Stream.php

+7-10
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,17 @@ public function __toString(){
6363
return '';
6464
}
6565

66-
try{
66+
if($this->isSeekable()){
67+
$this->seek(0);
68+
}
6769

68-
if($this->isSeekable()){
69-
$this->seek(0);
70-
}
70+
$contents = stream_get_contents($this->stream);
7171

72-
return (string)stream_get_contents($this->stream);
73-
}
74-
// @codeCoverageIgnoreStart
75-
catch(Exception $e){
76-
throw new RuntimeException('Stream::__toString exception: '.$e->getMessage());
72+
if($contents !== false){
73+
return $contents;
7774
}
78-
// @codeCoverageIgnoreEnd
7975

76+
throw new RuntimeException('stream_get_contents() error'); // @codeCoverageIgnore
8077
}
8178

8279
/**

0 commit comments

Comments
 (0)