Skip to content

Commit b3cb1d6

Browse files
committed
fix check return value
1 parent d97898d commit b3cb1d6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/Service/ServiceInformationsTrait.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@ protected function getServiceInformations(ServiceIdentificator $service): Servic
5959
}
6060

6161
/**
62-
*
6362
* @throws ServiceAccessDeniedException
6463
* @throws ServiceNotFoundException
6564
*/
66-
protected function checkResponseAndConvertInExceptionIfNeed(mixed $value, ServiceIdentificator $service): void
65+
protected function checkResponseAndConvertInExceptionIfNeed(?int $value, ServiceIdentificator $service): void
6766
{
6867
if ($value === WIN32_ERROR_SERVICE_DOES_NOT_EXIST) {
6968
throw new ServiceNotFoundException('Service '.$service->serviceId().' is not found');
@@ -76,7 +75,7 @@ protected function checkResponseAndConvertInExceptionIfNeed(mixed $value, Servic
7675
/**
7776
* @throws Win32ServiceException
7877
*/
79-
protected function throwExceptionIfError(mixed $value, string $exceptionClass, string $message): void
78+
protected function throwExceptionIfError(?int $value, string $exceptionClass, string $message): void
8079
{
8180
if (class_exists($exceptionClass) === false || is_a(
8281
$exceptionClass,
@@ -86,7 +85,7 @@ protected function throwExceptionIfError(mixed $value, string $exceptionClass, s
8685
throw new Win32ServiceException(sprintf('Cannot throw object as it does not extend Exception or implement Throwable. Class provided "%s"', $exceptionClass));
8786
}
8887

89-
if ($value !== WIN32_NO_ERROR) {
88+
if ($value !== null && $value !== WIN32_NO_ERROR) {
9089
throw new $exceptionClass($message, $value);
9190
}
9291
}

0 commit comments

Comments
 (0)