diff --git a/DataCollector/ProfilerDataCollector.php b/DataCollector/ProfilerDataCollector.php index 69fc0f9..5dc6e55 100644 --- a/DataCollector/ProfilerDataCollector.php +++ b/DataCollector/ProfilerDataCollector.php @@ -15,6 +15,7 @@ use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Stopwatch\Stopwatch; +use Throwable; /* * @author Emmanuel VAISSE @@ -53,7 +54,7 @@ public function __construct(protected bool $debug) { } - public function collect(Request $request, Response $response, \Throwable $exception = null): void + public function collect(Request $request, Response $response, ?Throwable $exception = null): void { $this->data = array( 'countRequests' => count($this->calls), @@ -332,7 +333,7 @@ public function fetchResponseInfos(Response $response): array return $data; } - public function fetchErrorInfos(\Throwable $error): array + public function fetchErrorInfos(Throwable $error): array { return [ 'class' => get_class($error), diff --git a/Http/Exception/BadGatewayHttpException.php b/Http/Exception/BadGatewayHttpException.php index 767c39a..34d72bb 100644 --- a/Http/Exception/BadGatewayHttpException.php +++ b/Http/Exception/BadGatewayHttpException.php @@ -9,6 +9,8 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class BadGatewayHttpException extends ServerErrorHttpException { @@ -16,10 +18,10 @@ class BadGatewayHttpException extends ServerErrorHttpException * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(502, $message, $previous, array(), $code); } diff --git a/Http/Exception/ExpectationFailedHttpException.php b/Http/Exception/ExpectationFailedHttpException.php index 67bea85..e4e2301 100644 --- a/Http/Exception/ExpectationFailedHttpException.php +++ b/Http/Exception/ExpectationFailedHttpException.php @@ -9,17 +9,19 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class ExpectationFailedHttpException extends ClientErrorHttpException { /** * Constructor. * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param string|null $message The internal exception message + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(417, $message, $previous, array(), $code); } diff --git a/Http/Exception/ForbiddenHttpException.php b/Http/Exception/ForbiddenHttpException.php index fbc1c7e..438dc56 100644 --- a/Http/Exception/ForbiddenHttpException.php +++ b/Http/Exception/ForbiddenHttpException.php @@ -9,16 +9,18 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class ForbiddenHttpException extends ClientErrorHttpException { /** * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(403, $message, $previous, array(), $code); } diff --git a/Http/Exception/GatewayTimeoutHttpException.php b/Http/Exception/GatewayTimeoutHttpException.php index 1ec8a90..0642c12 100644 --- a/Http/Exception/GatewayTimeoutHttpException.php +++ b/Http/Exception/GatewayTimeoutHttpException.php @@ -9,6 +9,8 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class GatewayTimeoutHttpException extends ServerErrorHttpException { @@ -16,10 +18,10 @@ class GatewayTimeoutHttpException extends ServerErrorHttpException * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(504, $message, $previous, array(), $code); } diff --git a/Http/Exception/HttpVersionNotSupportedHttpException.php b/Http/Exception/HttpVersionNotSupportedHttpException.php index 059a0f2..7b17216 100644 --- a/Http/Exception/HttpVersionNotSupportedHttpException.php +++ b/Http/Exception/HttpVersionNotSupportedHttpException.php @@ -9,16 +9,18 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class HttpVersionNotSupportedHttpException extends ServerErrorHttpException { /** * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(505, $message, $previous, array(), $code); } diff --git a/Http/Exception/InternalServerErrorHttpException.php b/Http/Exception/InternalServerErrorHttpException.php index 0afe47d..daab496 100644 --- a/Http/Exception/InternalServerErrorHttpException.php +++ b/Http/Exception/InternalServerErrorHttpException.php @@ -9,6 +9,8 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class InternalServerErrorHttpException extends ServerErrorHttpException { @@ -16,10 +18,10 @@ class InternalServerErrorHttpException extends ServerErrorHttpException * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(500, $message, $previous, array(), $code); } diff --git a/Http/Exception/NotImplementedHttpException.php b/Http/Exception/NotImplementedHttpException.php index fab8609..be63544 100644 --- a/Http/Exception/NotImplementedHttpException.php +++ b/Http/Exception/NotImplementedHttpException.php @@ -9,6 +9,8 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class NotImplementedHttpException extends ServerErrorHttpException { @@ -16,10 +18,10 @@ class NotImplementedHttpException extends ServerErrorHttpException * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(501, $message, $previous, array(), $code); } diff --git a/Http/Exception/ProxyAuthenticationRequiredHttpException.php b/Http/Exception/ProxyAuthenticationRequiredHttpException.php index 76b349c..2f7be2a 100644 --- a/Http/Exception/ProxyAuthenticationRequiredHttpException.php +++ b/Http/Exception/ProxyAuthenticationRequiredHttpException.php @@ -9,6 +9,8 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class ProxyAuthenticationRequiredHttpException extends ClientErrorHttpException { @@ -16,10 +18,10 @@ class ProxyAuthenticationRequiredHttpException extends ClientErrorHttpException * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(407, $message, $previous, array(), $code); } diff --git a/Http/Exception/RequestEntityTooLargeHttpException.php b/Http/Exception/RequestEntityTooLargeHttpException.php index dc61272..f5f97fe 100644 --- a/Http/Exception/RequestEntityTooLargeHttpException.php +++ b/Http/Exception/RequestEntityTooLargeHttpException.php @@ -9,6 +9,8 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class RequestEntityTooLargeHttpException extends ClientErrorHttpException { @@ -16,10 +18,10 @@ class RequestEntityTooLargeHttpException extends ClientErrorHttpException * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(413, $message, $previous, array(), $code); } diff --git a/Http/Exception/RequestTimeoutHttpException.php b/Http/Exception/RequestTimeoutHttpException.php index e83ec5e..748fd7a 100644 --- a/Http/Exception/RequestTimeoutHttpException.php +++ b/Http/Exception/RequestTimeoutHttpException.php @@ -9,6 +9,8 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class RequestTimeoutHttpException extends ClientErrorHttpException { @@ -16,10 +18,10 @@ class RequestTimeoutHttpException extends ClientErrorHttpException * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(408, $message, $previous, array(), $code); } diff --git a/Http/Exception/RequestUriTooLongHttpException.php b/Http/Exception/RequestUriTooLongHttpException.php index 5569ade..a8ee205 100644 --- a/Http/Exception/RequestUriTooLongHttpException.php +++ b/Http/Exception/RequestUriTooLongHttpException.php @@ -9,16 +9,18 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class RequestUriTooLongHttpException extends ClientErrorHttpException { /** * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(414, $message, $previous, array(), $code); } diff --git a/Http/Exception/RequestedRangeNotSatisfiableHttpException.php b/Http/Exception/RequestedRangeNotSatisfiableHttpException.php index b33a459..e8e2a15 100644 --- a/Http/Exception/RequestedRangeNotSatisfiableHttpException.php +++ b/Http/Exception/RequestedRangeNotSatisfiableHttpException.php @@ -9,6 +9,8 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; +use Exception; + class RequestedRangeNotSatisfiableHttpException extends ClientErrorHttpException { @@ -16,10 +18,10 @@ class RequestedRangeNotSatisfiableHttpException extends ClientErrorHttpException * Constructor. * * @param string $message The internal exception message - * @param \Exception $previous The previous exception + * @param Exception|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct($message = null, \Exception $previous = null, $code = 0) + public function __construct($message = null, ?Exception $previous = null, $code = 0) { parent::__construct(416, $message, $previous, array(), $code); } diff --git a/Http/Exception/ResponseException.php b/Http/Exception/ResponseException.php index b2942fc..e787e3f 100644 --- a/Http/Exception/ResponseException.php +++ b/Http/Exception/ResponseException.php @@ -9,6 +9,7 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; use evaisse\SimpleHttpBundle\Http\Response; +use Exception; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -30,9 +31,9 @@ class ResponseException extends HttpException * @param Response $response response attached to error * @param string $message Message describing exception * @param int $code error code - * @param \Exception $previous optionnal previous exception + * @param Exception|null $previous optionnal previous exception */ - public function __construct(Response $response, $message = "", $code = 0, \Exception $previous = null) + public function __construct(Response $response, $message = "", $code = 0, ?Exception $previous = null) { parent::__construct(580, $message, $previous, [], $code); // TODO: Change the autogenerated stub $this->setResponse($response); diff --git a/Http/Exception/TransportException.php b/Http/Exception/TransportException.php index 72b7ff8..62a48f3 100644 --- a/Http/Exception/TransportException.php +++ b/Http/Exception/TransportException.php @@ -2,7 +2,7 @@ namespace evaisse\SimpleHttpBundle\Http\Exception; -use evaisse\SimpleHttpBundle\Http\Exception; +use Exception; use Symfony\Component\HttpKernel\Exception\HttpException; abstract class TransportException extends HttpException @@ -11,9 +11,9 @@ abstract class TransportException extends HttpException /** * @param string $message * @param int $code - * @param \Exception $previous + * @param Exception|null $previous */ - public function __construct($message = null, $code = 0, \Exception $previous = null) + public function __construct($message = null, $code = 0, ?Exception $previous = null) { /* * @see https://en.wikipedia.org/wiki/List_of_HTTP_status_codes diff --git a/Http/Kernel.php b/Http/Kernel.php index b3c6551..7afd925 100644 --- a/Http/Kernel.php +++ b/Http/Kernel.php @@ -71,7 +71,7 @@ class Kernel extends RemoteHttpKernel * @param EventDispatcherInterface $eventDispatcher * @param RequestGenerator|null $generator Optionnal generator to construct curlrequest */ - public function __construct(EventDispatcherInterface $eventDispatcher, RequestGenerator $generator = null) + public function __construct(EventDispatcherInterface $eventDispatcher, ?RequestGenerator $generator = null) { $this->setEventDispatcher($eventDispatcher); parent::__construct($generator); @@ -354,13 +354,13 @@ protected function prepareRawCurlHandler(Statement $stmt): array * * @param string $filename realpath to file * @param string $mimetype mime content type - * @param string $postname base name for file + * @param string|null $postname base name for file * * @throws \InvalidArgumentException * * @return mixed|string|CURLFile if version >= 5.5, CURLFile instance will be return, otherwise a string resource */ - protected function createCurlFile(string $filename, string $mimetype, string $postname = null): mixed + protected function createCurlFile(string $filename, string $mimetype, ?string $postname = null): mixed { if (!realpath($filename) && is_file($filename)) { throw new \InvalidArgumentException('invalid given filepath : ' . $filename); diff --git a/Http/Kernel/RemoteHttpKernel.php b/Http/Kernel/RemoteHttpKernel.php index c135291..89b2ea9 100644 --- a/Http/Kernel/RemoteHttpKernel.php +++ b/Http/Kernel/RemoteHttpKernel.php @@ -37,7 +37,7 @@ class RemoteHttpKernel implements HttpKernelInterface private $lastCurlRequest; - public function __construct(RequestGenerator $generator = null) + public function __construct(?RequestGenerator $generator = null) { $this->generator = $generator; } diff --git a/Http/SessionCookieJar.php b/Http/SessionCookieJar.php index f2c9629..100f318 100644 --- a/Http/SessionCookieJar.php +++ b/Http/SessionCookieJar.php @@ -32,7 +32,7 @@ class SessionCookieJar extends CookieJar * @param SessionInterface $session Session storage to persist cookieJar * @param string $cookieJarName A key in which will be stored the cookie jar */ - function __construct(SessionInterface $session = null, $cookieJarName = "_simple_http.cookiejar") + function __construct(?SessionInterface $session = null, $cookieJarName = "_simple_http.cookiejar") { $session = $session ? $session : new Session(new MockArraySessionStorage()); $this->setSession($session); diff --git a/Http/Statement.php b/Http/Statement.php index b794a8d..ecaf69f 100644 --- a/Http/Statement.php +++ b/Http/Statement.php @@ -127,7 +127,7 @@ public function setHttpKernel(Kernel $httpKernel): void * * @param Request $request An http request object to send */ - public function __construct(Request $request, EventDispatcherInterface $eventDispatcher, Kernel $httpKernel = null) + public function __construct(Request $request, EventDispatcherInterface $eventDispatcher, ?Kernel $httpKernel = null) { $this->setRequest($request); $this->deferred = new Deferred(); @@ -327,7 +327,7 @@ public function getUid() * @throws Error * @throws Exception */ - public function execute(Kernel $httpKernel = null) + public function execute(?Kernel $httpKernel = null) { $this->sent = true; $http = $httpKernel ? $httpKernel : $this->httpKernel; diff --git a/Serializer/CustomGetSetNormalizer.php b/Serializer/CustomGetSetNormalizer.php index d74eeec..faf15e6 100644 --- a/Serializer/CustomGetSetNormalizer.php +++ b/Serializer/CustomGetSetNormalizer.php @@ -15,7 +15,7 @@ class CustomGetSetNormalizer extends GetSetMethodNormalizer /** * {@inheritdoc} */ - public function normalize(mixed $object, string $format = null, array $context = []) + public function normalize(mixed $object, ?string $format = null, array $context = []) { if ($object instanceof \Throwable) { return $this->normalizeThrowable($object); diff --git a/Serializer/RequestNormalizer.php b/Serializer/RequestNormalizer.php index 8ce0020..7dfe5dd 100644 --- a/Serializer/RequestNormalizer.php +++ b/Serializer/RequestNormalizer.php @@ -7,7 +7,7 @@ class RequestNormalizer extends GetSetMethodNormalizer { - protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []): mixed + protected function getAttributeValue(object $object, string $attribute, ?string $format = null, array $context = []): mixed { $ucfirsted = ucfirst($attribute); diff --git a/Service/Helper.php b/Service/Helper.php index 328f544..d352b59 100644 --- a/Service/Helper.php +++ b/Service/Helper.php @@ -41,10 +41,10 @@ public function getDefaultCookieJar(): SessionCookieJar|CookieJar } /** - * @param SessionInterface $session session to store the cookies + * @param SessionInterface|null $session session to store the cookies * @return SessionCookieJar */ - public function createCookieJar(SessionInterface $session = null): SessionCookieJar + public function createCookieJar(?SessionInterface $session = null): SessionCookieJar { return new SessionCookieJar($session); } @@ -58,7 +58,7 @@ public function createCookieJar(SessionInterface $session = null): SessionCookie * @param Kernel|null $client http client proxy to use * @return Helper given service list */ - public function execute(array $servicesList, SessionCookieJar $cookieJar = null, Kernel $client = null): static + public function execute(array $servicesList, ?SessionCookieJar $cookieJar = null, Kernel $client = null): static { $httpClient = $client ? $client : $this->httpKernel;