diff --git a/Factory/PsrHttpFactory.php b/Factory/PsrHttpFactory.php index fcb80d6..d19baa1 100644 --- a/Factory/PsrHttpFactory.php +++ b/Factory/PsrHttpFactory.php @@ -89,7 +89,7 @@ private function getFiles(array $uploadedFiles) foreach ($uploadedFiles as $key => $value) { if (null === $value) { - $files[$key] = $this->uploadedFileFactory->createUploadedFile($this->streamFactory->createStream(), 0, UPLOAD_ERR_NO_FILE); + $files[$key] = $this->uploadedFileFactory->createUploadedFile($this->streamFactory->createStream(), 0, \UPLOAD_ERR_NO_FILE); continue; } if ($value instanceof UploadedFile) { diff --git a/Factory/UploadedFile.php b/Factory/UploadedFile.php index 804f747..53aa37a 100644 --- a/Factory/UploadedFile.php +++ b/Factory/UploadedFile.php @@ -29,7 +29,7 @@ public function __construct(UploadedFileInterface $psrUploadedFile, callable $ge $error = $psrUploadedFile->getError(); $path = ''; - if (UPLOAD_ERR_NO_FILE !== $error) { + if (\UPLOAD_ERR_NO_FILE !== $error) { $path = $psrUploadedFile->getStream()->getMetadata('uri') ?? ''; if ($this->test = !\is_string($path) || !is_uploaded_file($path)) { diff --git a/Tests/Factory/AbstractHttpMessageFactoryTest.php b/Tests/Factory/AbstractHttpMessageFactoryTest.php index 2176ae8..82d3fc7 100644 --- a/Tests/Factory/AbstractHttpMessageFactoryTest.php +++ b/Tests/Factory/AbstractHttpMessageFactoryTest.php @@ -31,7 +31,7 @@ abstract class AbstractHttpMessageFactoryTest extends TestCase abstract protected function buildHttpMessageFactory(): HttpMessageFactoryInterface; - public function setUp(): void + protected function setUp(): void { $this->factory = $this->buildHttpMessageFactory(); $this->tmpDir = sys_get_temp_dir(); @@ -61,8 +61,8 @@ public function testCreateRequest() 'c2' => ['c3' => 'bar'], ], [ - 'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', UPLOAD_ERR_OK), - 'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', UPLOAD_ERR_OK)], + 'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', \UPLOAD_ERR_OK), + 'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', \UPLOAD_ERR_OK)], ], [ 'REQUEST_METHOD' => 'POST', @@ -102,12 +102,12 @@ public function testCreateRequest() $this->assertEquals('F1', $uploadedFiles['f1']->getStream()->__toString()); $this->assertEquals('f1.txt', $uploadedFiles['f1']->getClientFilename()); $this->assertEquals('text/plain', $uploadedFiles['f1']->getClientMediaType()); - $this->assertEquals(UPLOAD_ERR_OK, $uploadedFiles['f1']->getError()); + $this->assertEquals(\UPLOAD_ERR_OK, $uploadedFiles['f1']->getError()); $this->assertEquals('F2', $uploadedFiles['foo']['f2']->getStream()->__toString()); $this->assertEquals('f2.txt', $uploadedFiles['foo']['f2']->getClientFilename()); $this->assertEquals('text/plain', $uploadedFiles['foo']['f2']->getClientMediaType()); - $this->assertEquals(UPLOAD_ERR_OK, $uploadedFiles['foo']['f2']->getError()); + $this->assertEquals(\UPLOAD_ERR_OK, $uploadedFiles['foo']['f2']->getError()); $serverParams = $psrRequest->getServerParams(); $this->assertEquals('POST', $serverParams['REQUEST_METHOD']); @@ -201,10 +201,10 @@ public function testCreateResponseFromBinaryFileWithRange() public function testUploadErrNoFile() { - $file = new UploadedFile('', '', null, UPLOAD_ERR_NO_FILE, true); + $file = new UploadedFile('', '', null, \UPLOAD_ERR_NO_FILE, true); $this->assertEquals(0, $file->getSize()); - $this->assertEquals(UPLOAD_ERR_NO_FILE, $file->getError()); + $this->assertEquals(\UPLOAD_ERR_NO_FILE, $file->getError()); $this->assertFalse($file->getSize(), 'SplFile::getSize() returns false on error'); $request = new Request( @@ -214,7 +214,7 @@ public function testUploadErrNoFile() [], [ 'f1' => $file, - 'f2' => ['name' => null, 'type' => null, 'tmp_name' => null, 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0], + 'f2' => ['name' => null, 'type' => null, 'tmp_name' => null, 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0], ], [ 'REQUEST_METHOD' => 'POST', @@ -228,7 +228,7 @@ public function testUploadErrNoFile() $uploadedFiles = $psrRequest->getUploadedFiles(); - $this->assertEquals(UPLOAD_ERR_NO_FILE, $uploadedFiles['f1']->getError()); - $this->assertEquals(UPLOAD_ERR_NO_FILE, $uploadedFiles['f2']->getError()); + $this->assertEquals(\UPLOAD_ERR_NO_FILE, $uploadedFiles['f1']->getError()); + $this->assertEquals(\UPLOAD_ERR_NO_FILE, $uploadedFiles['f2']->getError()); } } diff --git a/Tests/Factory/HttpFoundationFactoryTest.php b/Tests/Factory/HttpFoundationFactoryTest.php index e35a789..3a00e2f 100644 --- a/Tests/Factory/HttpFoundationFactoryTest.php +++ b/Tests/Factory/HttpFoundationFactoryTest.php @@ -34,7 +34,7 @@ class HttpFoundationFactoryTest extends TestCase /** @var string */ private $tmpDir; - public function setUp(): void + protected function setUp(): void { $this->factory = new HttpFoundationFactory(); $this->tmpDir = sys_get_temp_dir(); @@ -57,11 +57,11 @@ public function testCreateRequest() ['city' => 'Lille'], ['url' => 'http://les-tilleuls.coop'], [ - 'doc1' => $this->createUploadedFile('Doc 1', UPLOAD_ERR_OK, 'doc1.txt', 'text/plain'), + 'doc1' => $this->createUploadedFile('Doc 1', \UPLOAD_ERR_OK, 'doc1.txt', 'text/plain'), 'nested' => [ 'docs' => [ - $this->createUploadedFile('Doc 2', UPLOAD_ERR_OK, 'doc2.txt', 'text/plain'), - $this->createUploadedFile('Doc 3', UPLOAD_ERR_OK, 'doc3.txt', 'text/plain'), + $this->createUploadedFile('Doc 2', \UPLOAD_ERR_OK, 'doc2.txt', 'text/plain'), + $this->createUploadedFile('Doc 3', \UPLOAD_ERR_OK, 'doc3.txt', 'text/plain'), ], ], ], @@ -168,7 +168,7 @@ public function testCreateRequestWithUri() public function testCreateUploadedFile() { - $uploadedFile = $this->createUploadedFile('An uploaded file.', UPLOAD_ERR_OK, 'myfile.txt', 'text/plain'); + $uploadedFile = $this->createUploadedFile('An uploaded file.', \UPLOAD_ERR_OK, 'myfile.txt', 'text/plain'); $symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile); $size = $symfonyUploadedFile->getSize(); @@ -176,7 +176,7 @@ public function testCreateUploadedFile() $symfonyUploadedFile->move($this->tmpDir, $uniqid); $this->assertEquals($uploadedFile->getSize(), $size); - $this->assertEquals(UPLOAD_ERR_OK, $symfonyUploadedFile->getError()); + $this->assertEquals(\UPLOAD_ERR_OK, $symfonyUploadedFile->getError()); $this->assertEquals('myfile.txt', $symfonyUploadedFile->getClientOriginalName()); $this->assertEquals('txt', $symfonyUploadedFile->getClientOriginalExtension()); $this->assertEquals('text/plain', $symfonyUploadedFile->getClientMimeType()); @@ -188,10 +188,10 @@ public function testCreateUploadedFileWithError() $this->expectException(FileException::class); $this->expectExceptionMessage('The file "e" could not be written on disk.'); - $uploadedFile = $this->createUploadedFile('Error.', UPLOAD_ERR_CANT_WRITE, 'e', 'text/plain'); + $uploadedFile = $this->createUploadedFile('Error.', \UPLOAD_ERR_CANT_WRITE, 'e', 'text/plain'); $symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile); - $this->assertEquals(UPLOAD_ERR_CANT_WRITE, $symfonyUploadedFile->getError()); + $this->assertEquals(\UPLOAD_ERR_CANT_WRITE, $symfonyUploadedFile->getError()); $symfonyUploadedFile->move($this->tmpDir, 'shouldFail.txt'); } diff --git a/Tests/Fixtures/Stream.php b/Tests/Fixtures/Stream.php index 06fff28..2cb4ab2 100644 --- a/Tests/Fixtures/Stream.php +++ b/Tests/Fixtures/Stream.php @@ -59,7 +59,7 @@ public function isSeekable() return true; } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = \SEEK_SET) { } diff --git a/Tests/Fixtures/UploadedFile.php b/Tests/Fixtures/UploadedFile.php index f58a4bd..93b3214 100644 --- a/Tests/Fixtures/UploadedFile.php +++ b/Tests/Fixtures/UploadedFile.php @@ -24,7 +24,7 @@ class UploadedFile implements UploadedFileInterface private $clientFileName; private $clientMediaType; - public function __construct($filePath, $size = null, $error = UPLOAD_ERR_OK, $clientFileName = null, $clientMediaType = null) + public function __construct($filePath, $size = null, $error = \UPLOAD_ERR_OK, $clientFileName = null, $clientMediaType = null) { $this->filePath = $filePath; $this->size = $size; diff --git a/Tests/Functional/CovertTest.php b/Tests/Functional/CovertTest.php index 4fc6890..f460b0e 100644 --- a/Tests/Functional/CovertTest.php +++ b/Tests/Functional/CovertTest.php @@ -36,9 +36,9 @@ class CovertTest extends TestCase { private $tmpDir; - public function setUp(): void + protected function setUp(): void { - if (!class_exists('Nyholm\Psr7\ServerRequest')) { + if (!class_exists(Psr7Request::class)) { $this->markTestSkipped('nyholm/psr7 is not installed.'); } @@ -124,8 +124,8 @@ public function requestProvider() 'c2' => ['c3' => 'bar'], ], [ - 'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', UPLOAD_ERR_OK), - 'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', UPLOAD_ERR_OK)], + 'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', \UPLOAD_ERR_OK), + 'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', \UPLOAD_ERR_OK)], ], [ 'REQUEST_METHOD' => 'POST',