Skip to content

Commit 6dee5c6

Browse files
author
Florian Krämer
committed
Minor improvements and corrections
1 parent a2f470f commit 6dee5c6

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/File.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class File implements FileInterface
5858
protected ?string $extension = null;
5959

6060
/**
61-
* @var string
61+
* @var string|null
6262
*/
6363
protected ?string $path = null;
6464

@@ -245,7 +245,7 @@ public function withResource($resource): FileInterface
245245
public function belongsToModel(string $model, $modelId): FileInterface
246246
{
247247
$this->model = $model;
248-
$this->modelId = $modelId;
248+
$this->modelId = (string)$modelId;
249249

250250
return $this;
251251
}

src/Utility/StreamWrapper.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
use InvalidArgumentException;
1919
use Psr\Http\Message\StreamInterface;
20-
use RuntimeException;
20+
21+
use function \Phauthentic\Infrastructure\Storage\fopen;
2122

2223
/**
2324
* Converts Guzzle streams into PHP stream resources.
@@ -55,14 +56,7 @@ public static function getResource(StreamInterface $stream)
5556
);
5657
}
5758

58-
$result = \fopen('guzzle://stream', $mode, false, self::createStreamContext($stream));
59-
60-
if ($result === false) {
61-
throw new RuntimeException(\sprintf(
62-
'Failed to open guzzle://stream with mode %s',
63-
$mode
64-
));
65-
}
59+
$result = fopen('guzzle://stream', $mode, false, self::createStreamContext($stream));
6660

6761
return $result;
6862
}

src/functions.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
/**
2222
* The original php function has mixed return values, either a resource or
2323
* boolean false. But we want an exception.
24+
*
25+
* @param string $filename
26+
* @param string $mode
27+
* @param bool $useIncludePath
28+
* @param mixed $context
29+
* @return resource
2430
*/
2531
function fopen(string $filename, string $mode, bool $useIncludePath = true, $context = null)
2632
{
@@ -32,7 +38,7 @@ function fopen(string $filename, string $mode, bool $useIncludePath = true, $con
3238

3339
if ($result === false) {
3440
throw new RuntimeException(sprintf(
35-
'Failed to open file `%s` with fopen()',
41+
'Failed to open resource `%s`',
3642
$filename
3743
));
3844
}

0 commit comments

Comments
 (0)