Browse Source

Fix errors reported by static analysers

ADmad 3 years ago
parent
commit
5c1d43233f
2 changed files with 2 additions and 1 deletions
  1. 1 0
      src/Http/StreamFactory.php
  2. 1 1
      src/Http/UploadedFileFactory.php

+ 1 - 0
src/Http/StreamFactory.php

@@ -35,6 +35,7 @@ class StreamFactory implements StreamFactoryInterface
     public function createStream(string $content = ''): StreamInterface
     {
         $resource = fopen('php://temp', 'r+');
+        assert($resource !== false, 'Unable to create resource');
         fwrite($resource, $content);
         rewind($resource);
 

+ 1 - 1
src/Http/UploadedFileFactory.php

@@ -50,7 +50,7 @@ class UploadedFileFactory implements UploadedFileFactoryInterface
         ?string $clientMediaType = null
     ): UploadedFileInterface {
         if ($size === null) {
-            $size = $stream->getSize();
+            $size = $stream->getSize() ?? 0;
         }
 
         return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);