Skip to content

Commit df23f92

Browse files
committed
Update dependencies
1 parent 0bcb907 commit df23f92

File tree

4 files changed

+97
-75
lines changed

4 files changed

+97
-75
lines changed

api.include.php

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,13 +1515,18 @@ public function createStream(string $content = ''): StreamInterface
15151515

15161516
public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface
15171517
{
1518-
$resource = @\fopen($filename, $mode);
1518+
try {
1519+
$resource = @\fopen($filename, $mode);
1520+
} catch (\Throwable $e) {
1521+
throw new \RuntimeException(\sprintf('The file "%s" cannot be opened.', $filename));
1522+
}
1523+
15191524
if (false === $resource) {
1520-
if ('' === $mode || false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'])) {
1521-
throw new \InvalidArgumentException('The mode ' . $mode . ' is invalid.');
1525+
if ('' === $mode || false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], true)) {
1526+
throw new \InvalidArgumentException(\sprintf('The mode "%s" is invalid.', $mode));
15221527
}
15231528

1524-
throw new \RuntimeException('The file ' . $filename . ' cannot be opened.');
1529+
throw new \RuntimeException(\sprintf('The file "%s" cannot be opened.', $filename));
15251530
}
15261531

15271532
return Stream::create($resource);
@@ -1687,7 +1692,7 @@ public function withBody(StreamInterface $body): self
16871692
return $new;
16881693
}
16891694

1690-
private function setHeaders(array $headers): void
1695+
private function setHeaders(array $headers) /*:void*/
16911696
{
16921697
foreach ($headers as $header => $value) {
16931698
if (\is_int($header)) {
@@ -1894,7 +1899,7 @@ public function withUri(UriInterface $uri, $preserveHost = false): self
18941899
return $new;
18951900
}
18961901

1897-
private function updateHostFromUri(): void
1902+
private function updateHostFromUri() /*:void*/
18981903
{
18991904
if ('' === $host = $this->uri->getHost()) {
19001905
return;
@@ -1934,7 +1939,7 @@ class Response implements ResponseInterface
19341939
use MessageTrait;
19351940

19361941
/** @var array Map of standard HTTP status code/reason phrases */
1937-
private const PHRASES = [
1942+
/*private*/ const PHRASES = [
19381943
100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing',
19391944
200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-status', 208 => 'Already Reported',
19401945
300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect',
@@ -2204,7 +2209,7 @@ class Stream implements StreamInterface
22042209
private $size;
22052210

22062211
/** @var array Hash of readable and writable stream types */
2207-
private const READ_WRITE_HASH = [
2212+
/*private*/ const READ_WRITE_HASH = [
22082213
'read' => [
22092214
'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true,
22102215
'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true,
@@ -2293,7 +2298,7 @@ public function __toString()
22932298
}
22942299
}
22952300

2296-
public function close(): void
2301+
public function close() /*:void*/
22972302
{
22982303
if (isset($this->stream)) {
22992304
if (\is_resource($this->stream)) {
@@ -2326,7 +2331,7 @@ private function getUri()
23262331
return $this->uri;
23272332
}
23282333

2329-
public function getSize(): ?int
2334+
public function getSize() /*:?int*/
23302335
{
23312336
if (null !== $this->size) {
23322337
return $this->size;
@@ -2370,18 +2375,18 @@ public function isSeekable(): bool
23702375
return $this->seekable;
23712376
}
23722377

2373-
public function seek($offset, $whence = \SEEK_SET): void
2378+
public function seek($offset, $whence = \SEEK_SET) /*:void*/
23742379
{
23752380
if (!$this->seekable) {
23762381
throw new \RuntimeException('Stream is not seekable');
23772382
}
23782383

23792384
if (-1 === \fseek($this->stream, $offset, $whence)) {
2380-
throw new \RuntimeException('Unable to seek to stream position ' . $offset . ' with whence ' . \var_export($whence, true));
2385+
throw new \RuntimeException('Unable to seek to stream position "' . $offset . '" with whence ' . \var_export($whence, true));
23812386
}
23822387
}
23832388

2384-
public function rewind(): void
2389+
public function rewind() /*:void*/
23852390
{
23862391
$this->seek(0);
23872392
}
@@ -2470,7 +2475,7 @@ public function getMetadata($key = null)
24702475
class UploadedFile implements UploadedFileInterface
24712476
{
24722477
/** @var array */
2473-
private const ERRORS = [
2478+
/*private*/ const ERRORS = [
24742479
\UPLOAD_ERR_OK => 1,
24752480
\UPLOAD_ERR_INI_SIZE => 1,
24762481
\UPLOAD_ERR_FORM_SIZE => 1,
@@ -2549,7 +2554,7 @@ public function __construct($streamOrFile, $size, $errorStatus, $clientFilename
25492554
/**
25502555
* @throws \RuntimeException if is moved or not ok
25512556
*/
2552-
private function validateActive(): void
2557+
private function validateActive() /*:void*/
25532558
{
25542559
if (\UPLOAD_ERR_OK !== $this->error) {
25552560
throw new \RuntimeException('Cannot retrieve stream due to upload error');
@@ -2568,12 +2573,14 @@ public function getStream(): StreamInterface
25682573
return $this->stream;
25692574
}
25702575

2571-
$resource = \fopen($this->file, 'r');
2572-
2573-
return Stream::create($resource);
2576+
try {
2577+
return Stream::create(\fopen($this->file, 'r'));
2578+
} catch (\Throwable $e) {
2579+
throw new \RuntimeException(\sprintf('The file "%s" cannot be opened.', $this->file));
2580+
}
25742581
}
25752582

2576-
public function moveTo($targetPath): void
2583+
public function moveTo($targetPath) /*:void*/
25772584
{
25782585
$this->validateActive();
25792586

@@ -2589,8 +2596,13 @@ public function moveTo($targetPath): void
25892596
$stream->rewind();
25902597
}
25912598

2592-
// Copy the contents of a stream into another stream until end-of-file.
2593-
$dest = Stream::create(\fopen($targetPath, 'w'));
2599+
try {
2600+
// Copy the contents of a stream into another stream until end-of-file.
2601+
$dest = Stream::create(\fopen($targetPath, 'w'));
2602+
} catch (\Throwable $e) {
2603+
throw new \RuntimeException(\sprintf('The file "%s" cannot be opened.', $targetPath));
2604+
}
2605+
25942606
while (!$stream->eof()) {
25952607
if (!$dest->write($stream->read(1048576))) {
25962608
break;
@@ -2601,7 +2613,7 @@ public function moveTo($targetPath): void
26012613
}
26022614

26032615
if (false === $this->moved) {
2604-
throw new \RuntimeException(\sprintf('Uploaded file could not be moved to %s', $targetPath));
2616+
throw new \RuntimeException(\sprintf('Uploaded file could not be moved to "%s"', $targetPath));
26052617
}
26062618
}
26072619

@@ -2615,12 +2627,12 @@ public function getError(): int
26152627
return $this->error;
26162628
}
26172629

2618-
public function getClientFilename(): ?string
2630+
public function getClientFilename() /*:?string*/
26192631
{
26202632
return $this->clientFilename;
26212633
}
26222634

2623-
public function getClientMediaType(): ?string
2635+
public function getClientMediaType() /*:?string*/
26242636
{
26252637
return $this->clientMediaType;
26262638
}
@@ -2645,11 +2657,11 @@ public function getClientMediaType(): ?string
26452657
*/
26462658
class Uri implements UriInterface
26472659
{
2648-
private const SCHEMES = ['http' => 80, 'https' => 443];
2660+
/*private*/ const SCHEMES = ['http' => 80, 'https' => 443];
26492661

2650-
private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
2662+
/*private*/ const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
26512663

2652-
private const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;=';
2664+
/*private*/ const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;=';
26532665

26542666
/** @var string Uri scheme. */
26552667
private $scheme = '';
@@ -2676,7 +2688,7 @@ public function __construct(string $uri = '')
26762688
{
26772689
if ('' !== $uri) {
26782690
if (false === $parts = \parse_url($uri)) {
2679-
throw new \InvalidArgumentException("Unable to parse URI: $uri");
2691+
throw new \InvalidArgumentException(\sprintf('Unable to parse URI: "%s"', $uri));
26802692
}
26812693

26822694
// Apply parse_url parts to a URI.
@@ -2731,7 +2743,7 @@ public function getHost(): string
27312743
return $this->host;
27322744
}
27332745

2734-
public function getPort(): ?int
2746+
public function getPort() /*:?int*/
27352747
{
27362748
return $this->port;
27372749
}
@@ -2899,7 +2911,7 @@ private static function isNonStandardPort(string $scheme, int $port): bool
28992911
return !isset(self::SCHEMES[$scheme]) || $port !== self::SCHEMES[$scheme];
29002912
}
29012913

2902-
private function filterPort($port): ?int
2914+
private function filterPort($port) /*:?int*/
29032915
{
29042916
if (null === $port) {
29052917
return null;
@@ -3011,7 +3023,7 @@ public function fromGlobals(): ServerRequestInterface
30113023
/**
30123024
* {@inheritdoc}
30133025
*/
3014-
public function fromArrays(array $server, array $headers = [], array $cookie = [], array $get = [], ?array $post = null, array $files = [], $body = null): ServerRequestInterface
3026+
public function fromArrays(array $server, array $headers = [], array $cookie = [], array $get = [], /*?array*/ $post = null, array $files = [], $body = null): ServerRequestInterface
30153027
{
30163028
$method = $this->getMethodFromEnv($server);
30173029
$uri = $this->getUriFromEnvWithHTTP($server);
@@ -3280,8 +3292,7 @@ public function fromArrays(
32803292
array $server,
32813293
array $headers = [],
32823294
array $cookie = [],
3283-
array $get = [],
3284-
?array $post = null,
3295+
array $get = [], /*?array*/ $post = null,
32853296
array $files = [],
32863297
$body = null
32873298
): ServerRequestInterface;

0 commit comments

Comments
 (0)