diff --git a/Neos.Flow/Classes/Http/ContentStream.php b/Neos.Flow/Classes/Http/ContentStream.php index b502c8da61..2f3b333d20 100644 --- a/Neos.Flow/Classes/Http/ContentStream.php +++ b/Neos.Flow/Classes/Http/ContentStream.php @@ -69,7 +69,7 @@ public static function fromContents(string $contents): self * * @return void */ - public function close() + public function close(): void { if (!$this->resource) { return; @@ -119,7 +119,7 @@ public function replace($stream, $mode = 'r') * * @return int|null Returns the size in bytes if known, or null if unknown. */ - public function getSize() + public function getSize(): ?int { if (!$this->isValidResource($this->resource)) { return null; @@ -136,7 +136,7 @@ public function getSize() * @return int Position of the file pointer * @throws \RuntimeException on error. */ - public function tell() + public function tell(): int { $this->ensureResourceOpen(); @@ -153,7 +153,7 @@ public function tell() * * @return bool */ - public function eof() + public function eof(): bool { if (!$this->isValidResource($this->resource)) { return true; @@ -167,7 +167,7 @@ public function eof() * * @return bool */ - public function isSeekable() + public function isSeekable(): bool { if (!$this->isValidResource($this->resource)) { return false; @@ -188,10 +188,9 @@ public function isSeekable() * PHP $whence values for `fseek()`. SEEK_SET: Set position equal to * offset bytes SEEK_CUR: Set position to current location plus offset * SEEK_END: Set position to end-of-stream plus offset. - * @return bool * @throws \RuntimeException on failure. */ - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { $this->ensureResourceOpen(); @@ -205,7 +204,7 @@ public function seek($offset, $whence = SEEK_SET) throw new \RuntimeException('Error seeking within stream', 1453892231); } - return true; + return; } /** @@ -218,9 +217,9 @@ public function seek($offset, $whence = SEEK_SET) * @link http://www.php.net/manual/en/function.fseek.php * @throws \RuntimeException on failure. */ - public function rewind() + public function rewind(): void { - return $this->seek(0); + $this->seek(0); } /** @@ -228,7 +227,7 @@ public function rewind() * * @return bool */ - public function isWritable() + public function isWritable(): bool { if (!$this->isValidResource($this->resource)) { return false; @@ -253,7 +252,7 @@ public function isWritable() * @return int Returns the number of bytes written to the stream. * @throws \RuntimeException on failure. */ - public function write($string) + public function write($string): int { if (!$this->isWritable()) { throw new \RuntimeException('Stream is not writable', 1453892241); @@ -273,7 +272,7 @@ public function write($string) * * @return bool */ - public function isReadable() + public function isReadable(): bool { if (!$this->isValidResource($this->resource)) { return false; @@ -295,7 +294,7 @@ public function isReadable() * if no bytes are available. * @throws \RuntimeException if an error occurs. */ - public function read($length) + public function read($length): string { $this->ensureResourceReadable(); @@ -315,7 +314,7 @@ public function read($length) * @throws \RuntimeException if unable to read or an error occurs while * reading. */ - public function getContents() + public function getContents(): string { $this->ensureResourceReadable(); @@ -334,12 +333,12 @@ public function getContents() * stream_get_meta_data() function. * * @link http://php.net/manual/en/function.stream-get-meta-data.php - * @param string $key Specific metadata to retrieve. + * @param string|null $key Specific metadata to retrieve. * @return array|mixed|null Returns an associative array if no key is * provided. Returns a specific key value if a key is provided and the * value is found, or null if the key is not found. */ - public function getMetadata($key = null) + public function getMetadata(?string $key = null) { if ($key === null) { return stream_get_meta_data($this->resource); @@ -395,7 +394,7 @@ protected function isValidResource($resource) * @see http://php.net/manual/en/language.oop5.magic.php#object.tostring * @return string */ - public function __toString() + public function __toString(): string { if (!$this->isReadable()) { return ''; diff --git a/Neos.Flow/Classes/Http/UploadedFile.php b/Neos.Flow/Classes/Http/UploadedFile.php index 90d9139dff..e97b9fa6ca 100644 --- a/Neos.Flow/Classes/Http/UploadedFile.php +++ b/Neos.Flow/Classes/Http/UploadedFile.php @@ -127,7 +127,7 @@ public function isMoved() * @throws RuntimeException if the upload was not successful. * @api PSR-7 */ - public function getStream() + public function getStream(): StreamInterface { $this->throwExceptionIfNotAccessible(); @@ -172,7 +172,7 @@ public function getStream() * the second or subsequent call to the method. * @api PSR-7 */ - public function moveTo($targetPath) + public function moveTo($targetPath): void { $this->throwExceptionIfNotAccessible(); @@ -203,7 +203,7 @@ public function moveTo($targetPath) * @return int|null The file size in bytes or null if unknown. * @api PSR-7 */ - public function getSize() + public function getSize(): ?int { return $this->size; } @@ -223,7 +223,7 @@ public function getSize() * @return int One of PHP's UPLOAD_ERR_XXX constants. * @api PSR-7 */ - public function getError() + public function getError(): int { return $this->error; } @@ -242,7 +242,7 @@ public function getError() * was provided. * @api PSR-7 */ - public function getClientFilename() + public function getClientFilename(): ?string { return $this->clientFilename; } @@ -259,7 +259,7 @@ public function getClientFilename() * * @api PSR-7 */ - public function getClientMediaType() + public function getClientMediaType(): ?string { return $this->clientMediaType; } diff --git a/Neos.Flow/Classes/ObjectManagement/ObjectManager.php b/Neos.Flow/Classes/ObjectManagement/ObjectManager.php index 6a03f2c458..2c6d8dc859 100644 --- a/Neos.Flow/Classes/ObjectManagement/ObjectManager.php +++ b/Neos.Flow/Classes/ObjectManagement/ObjectManager.php @@ -164,7 +164,7 @@ public function isRegistered($objectName): bool * @param string $objectName * @return bool */ - public function has($objectName): bool + public function has(string $objectName): bool { return $this->isRegistered($objectName); } @@ -200,7 +200,7 @@ public function registerShutdownObject($object, $shutdownLifecycleMethodName): v * @throws InvalidConfigurationTypeException * @api */ - public function get($objectName, ...$constructorArguments): object + public function get(string $objectName, ...$constructorArguments): object { if (!empty($constructorArguments) && isset($this->objects[$objectName]) && $this->objects[$objectName][self::KEY_SCOPE] !== ObjectConfiguration::SCOPE_PROTOTYPE) { throw new \InvalidArgumentException('You cannot provide constructor arguments for singleton objects via get(). If you need to pass arguments to the constructor, define them in the Objects.yaml configuration.', 1298049934); diff --git a/Neos.Flow/Classes/ObjectManagement/ObjectManagerInterface.php b/Neos.Flow/Classes/ObjectManagement/ObjectManagerInterface.php index c3ce693c72..a5d4695486 100644 --- a/Neos.Flow/Classes/ObjectManagement/ObjectManagerInterface.php +++ b/Neos.Flow/Classes/ObjectManagement/ObjectManagerInterface.php @@ -50,7 +50,7 @@ public function getContext(); * @return T The object instance * @api */ - public function get($objectName, ...$constructorArguments); + public function get(string $objectName, ...$constructorArguments); /** * This is the PSR-11 ContainerInterface equivalent to `isRegistered`. @@ -59,7 +59,7 @@ public function get($objectName, ...$constructorArguments); * @return bool * @see isRegistered */ - public function has($objectName); + public function has(string $objectName): bool; /** * Returns true if an object with the given name has already diff --git a/Neos.Flow/Tests/Unit/Validation/Validator/FileSizeValidatorTest.php b/Neos.Flow/Tests/Unit/Validation/Validator/FileSizeValidatorTest.php index 63022859ea..5798d64351 100644 --- a/Neos.Flow/Tests/Unit/Validation/Validator/FileSizeValidatorTest.php +++ b/Neos.Flow/Tests/Unit/Validation/Validator/FileSizeValidatorTest.php @@ -38,7 +38,7 @@ protected function createResourceMetaDataInterfaceMock(int $filesize): ResourceM return $mock; } - protected function createUploadedFileInterfaceMock(string $filesize): UploadedFileInterface + protected function createUploadedFileInterfaceMock(int $filesize): UploadedFileInterface { $mock = $this->createMock(UploadedFileInterface::class); $mock->expects($this->once())->method('getSize')->willReturn($filesize); diff --git a/Neos.Flow/composer.json b/Neos.Flow/composer.json index 1f3ada347a..55462e8017 100644 --- a/Neos.Flow/composer.json +++ b/Neos.Flow/composer.json @@ -31,9 +31,9 @@ "neos/composer-plugin": "^2.0", - "psr/http-message": "^1.0", + "psr/http-message": "^2.0", "psr/http-factory": "^1.0", - "psr/container": "^1.0", + "psr/container": "^2.0", "psr/log": "^2.0 || ^3.0", "psr/http-server-middleware": "^1.0", "psr/http-server-handler": "^1.0", diff --git a/Neos.Http.Factories/composer.json b/Neos.Http.Factories/composer.json index 0b700ddd6a..8504929892 100644 --- a/Neos.Http.Factories/composer.json +++ b/Neos.Http.Factories/composer.json @@ -8,7 +8,7 @@ ], "require": { "php": "^8.2", - "psr/http-factory": "^1.0", + "psr/http-factory": "^2.0", "guzzlehttp/psr7": "^1.8.4 || ^2.1.1" }, "autoload": { diff --git a/composer.json b/composer.json index 9bf75ac0c7..20b1011a6a 100644 --- a/composer.json +++ b/composer.json @@ -28,9 +28,9 @@ "ext-xml": "*", "ext-xmlreader": "*", "neos/composer-plugin": "^2.0", - "psr/http-message": "^1.0", + "psr/http-message": "^2.0", "psr/http-factory": "^1.0", - "psr/container": "^1.0", + "psr/container": "^2.0", "psr/http-server-middleware": "^1.0", "psr/http-server-handler": "^1.0", "psr/http-client": "^1.0",