walkor / workerman

An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols.
http://www.workerman.net
MIT License
11.03k stars 2.25k forks source link

Type union instead of mixed #939

Closed joanhey closed 10 months ago

joanhey commented 1 year ago

Update: investigating why the /session test fail !!

Update: the Session->pull() return mixed, thinking about what will happen if return an array, the encode() will not show it corretly.

I think that need to be forced to string|Response or string|Stringable the encode(), send() and close() methods and perhaps in TcpConnection too. :thinking: Check https://3v4l.org/Og7d6 Also we need to catch the error and send a 500, now only stop and send nothing.

@walkor what do you think ?

joanhey commented 1 year ago

Added to show Workerman info and errors (if exist) in the test. Before we see blind errors, without any info.

Before: https://github.com/walkor/workerman/actions/runs/5549327537/jobs/10133294775 After: https://github.com/walkor/workerman/actions/runs/5549366572/jobs/10133376678

joanhey commented 1 year ago

It's easy to fix the test. But this time we want the error information.

walkor commented 1 year ago

I think we cannot limit it to string|Response, as numbers or null or other classes( for example Workerman\Psr7\Response) that can be converted to strings can be encoded. We cannot limit the types of TcpConnection because data has a wider range of data types.