-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some issues identified by phpstan #123
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,13 +79,13 @@ public function __construct(array $fields = null, array $hl7Globals = null) | |
* @param int $index Index of field | ||
* @param string $value | ||
*/ | ||
public function setField(int $index, $value = ''): bool | ||
public function setField(int $index, string|int|array|null $value = ''): bool | ||
{ | ||
if (($index === 1) && strlen($value) !== 1) { | ||
if (($index === 1) && (!is_string($value) || strlen($value) !== 1)) { | ||
return false; | ||
} | ||
|
||
if (($index === 2) && strlen($value) !== 4) { | ||
if (($index === 2) && (!is_string($value) || strlen($value) !== 4)) { | ||
Comment on lines
-82
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return false; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
use Aranyasen\HL7; | ||
use Aranyasen\HL7\Segments\PID; | ||
use DMS\PHPUnitExtensions\ArraySubset\Assert; | ||
use Exception; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docblock for |
||
|
||
class HL7Test extends TestCase | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,22 +67,23 @@ public function createTcpServer(int $port, int $totalClientsToConnect): void | |
} | ||
|
||
if (($ret = socket_bind($socket, "localhost", $port)) === false) { | ||
throw new RuntimeException('socket_bind() failed: reason: ' . socket_strerror($ret) . "\n"); | ||
throw new RuntimeException( | ||
'socket_bind() failed: reason: ' . socket_strerror(socket_last_error($socket)) . "\n" | ||
); | ||
} | ||
if (($ret = socket_listen($socket, 5)) === false) { | ||
throw new RuntimeException('socket_listen() failed: reason: ' . socket_strerror($ret) . "\n"); | ||
throw new RuntimeException( | ||
'socket_listen() failed: reason: ' . socket_strerror(socket_last_error($socket)) . "\n" | ||
); | ||
} | ||
|
||
$clientCount = 0; | ||
while (true) { // Loop over each client | ||
if (($clientSocket = socket_accept($socket)) === false) { | ||
echo 'socket_accept() failed: reason: ' . socket_strerror(socket_last_error()) . "\n"; | ||
socket_close($clientSocket); | ||
echo 'socket_accept() failed: reason: ' . socket_strerror(socket_last_error($socket)) . "\n"; | ||
socket_close($socket); | ||
exit(); | ||
} | ||
if ($clientSocket === false) { | ||
continue; | ||
} | ||
Comment on lines
-83
to
-85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The above block exits if |
||
|
||
$clientCount++; | ||
$clientName = 'Unknown'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exception is thrown in this class, but was not
use
d.