-
Notifications
You must be signed in to change notification settings - Fork 53
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
Exception array_merge(): Argument #1 must be of type array in NonBlockingClient.php:183 #137
Comments
This is a bug with Write requests. Basically Composer Requests should extract values as array. Like ReadRegisterRequest does it here
but WriteRegisterRequest
I will fix it. |
I have released version 3.2.0 that contains fix for this problem. |
Excellent, the fix works fine with PHP 8, many thanks for the quick response. But have in addition an environment still running PHP 7.4.28 which cannot be upgraded to PHP 8. Therefore I need to use version 2.4.0 of modbus-tcp-client. Any chance to get the fix also downported to 2.4.0? |
@niniob I think you could create custom patch for PHP 7 and let composer to apply it. See |
Thanks, custom patch might be an option, but I found another workaround: Create NonBlockingClient with option 'flatRequestResponse' => false. This avoids
|
aa yeah, this is also an option as write requests do not need responses. |
Using WriteRegistersBuilder to write registers leads to following exception:
Fatal error: Uncaught TypeError: array_merge(): Argument #1 must be of type array, ModbusTcpClient\Packet\ModbusFunction\WriteMultipleRegistersResponse given in /php/modbus-test-01/vendor/aldas/modbus-tcp-client/src/Network/NonBlockingClient.php:183
Issue seems to be line 183 in NonBlockingClient.php:
$data = array_merge(...$data);
I'm not sure why array_merge and the spread operator are used together. I assume it should be just
$data = array_merge($data);
At least this fixes the issue for me.
Example to reproduce the issue:
Environment:
The text was updated successfully, but these errors were encountered: