Skip to content

Commit

Permalink
$message can be null in stream_context_set_params() `notification…
Browse files Browse the repository at this point in the history
…` callback (#222)

I had it right in `MichalSpacekCz\Http\HttpStreamContext::create()`, which probably should be used instead, but followed the example in PHP docs that says only `string $message`.

PHP docs PR php/doc-en#2767

Introduced in bd8c089 in #220
  • Loading branch information
spaze authored Sep 13, 2023
2 parents 8a5f398 + fd3db5c commit 0536ea9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions site/app/CompanyInfo/CompanyRegisterAres.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ private function fetch(string $companyId): string
{
$context = stream_context_create();
$setResult = stream_context_set_params($context, [
'notification' => function (int $notificationCode, int $severity, string $message, int $messageCode) {
'notification' => function (int $notificationCode, int $severity, ?string $message, int $messageCode) {
if ($severity === STREAM_NOTIFY_SEVERITY_ERR) {
throw new CompanyInfoException(trim($message) . " ({$notificationCode})", $messageCode);
throw new CompanyInfoException($notificationCode . ($message ? trim(' ' . $message) : ''), $messageCode);
}
},
'options' => [
Expand Down
4 changes: 2 additions & 2 deletions site/app/UpcKeys/Technicolor.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ private function callApi(string $url): string
{
$context = stream_context_create();
$setResult = stream_context_set_params($context, [
'notification' => function (int $notificationCode, int $severity, string $message, int $messageCode) {
'notification' => function (int $notificationCode, int $severity, ?string $message, int $messageCode) {
if ($notificationCode == STREAM_NOTIFY_FAILURE && $messageCode >= 500) {
throw new RuntimeException(trim($message), $messageCode);
throw new RuntimeException($message ? trim($message) : '', $messageCode);
}
},
'options' => [
Expand Down

0 comments on commit 0536ea9

Please sign in to comment.