Passed
Push — master ( 5e186e...dbb2e0 )
by Anton
02:56
created

src/Http/Diactoros/UploadedFileFactory.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
declare(strict_types=1);
9
10
namespace Spiral\Http\Diactoros;
11
12
use Psr\Http\Message\StreamInterface;
13
use Psr\Http\Message\UploadedFileFactoryInterface;
14
use Psr\Http\Message\UploadedFileInterface;
15
use Zend\Diactoros\UploadedFile;
16
17
final class UploadedFileFactory implements UploadedFileFactoryInterface
18
{
19
    /**
20
     * @inheritdoc
21
     */
22
    public function createUploadedFile(
23
        StreamInterface $stream,
24
        int $size = null,
25
        int $error = \UPLOAD_ERR_OK,
26
        string $clientFilename = null,
27
        string $clientMediaType = null
28
    ): UploadedFileInterface {
29
        if ($size === null) {
30
            $size = $stream->getSize();
31
        }
32
33
        return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);
0 ignored issues
show
It seems like $size can also be of type null; however, parameter $size of Zend\Diactoros\UploadedFile::__construct() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

33
        return new UploadedFile($stream, /** @scrutinizer ignore-type */ $size, $error, $clientFilename, $clientMediaType);
Loading history...
34
    }
35
}