walkor / workerman

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

Use static anonymous functions #861

Open joanhey opened 1 year ago

joanhey commented 1 year ago

Will be good to change in all the code and examples.

And explain that's better to use static.

For performance and memory benefit.

Anonymous functions when declared in the context of a class, the current class is automatically bound to it, making $this available inside of the function's scope. If this automatic binding of the current class is not wanted, then static anonymous functions may be used instead.

walkor commented 1 year ago

I don't object to this proposal, but through stress test comparison, the use of static functions has no significant performance improvement, or even difference.