Whereas the documentation for ssh_channel_read_nonblocking() says that 0 is returned on EOF, the actual return value is -127 (aka SSH_EOF).
This appears to me to come from ssh_channel_read_nonblocking() expecting ssh_channel_poll() to only return non-negative values or SSH_ERROR. So when ssh_channel_poll() instead returns SSH_EOF (which its own contract allows), ssh_channel_read_nonblocking() returns that as-is --- which contradicts the documentation.
For the sake of compatibility, it might be easiest to update the documentation to reflect that SSH_EOF is returned on EOF, though trapping/replacing it with SSH_ERROR might also be reasonable.