phergie / phergie-irc-client-react

IRC client library built on React
BSD 3-Clause "New" or "Revised" License
56 stars 26 forks source link

Write stream in connect.after.each/all callback is always null #57

Closed asm89 closed 7 years ago

asm89 commented 7 years ago

According to the documentation (and code) the connect.after.each callback should return the connection and the write stream belonging to it. The write stream seems to always be null. I'm pretty certain that it is a bug in the library. On this line getOption() gets called on the connection: https://github.com/phergie/phergie-irc-client-react/blob/e76dcfa1a6f85d324f6ecf509cffc1be311e3b39/src/Client.php#L634. I think it should be getData('write'). It gets set here: https://github.com/phergie/phergie-irc-client-react/blob/e76dcfa1a6f85d324f6ecf509cffc1be311e3b39/src/Client.php#L650.

Calling $connection->getData('write') in my callback seems to yield the write stream like expected. :)

elazar commented 7 years ago

I agree. I believe ConnectionInterface originally had one of getOption() or getData() and the other was added later, and this issue is an artifact from before that change was made.

@asm89 Would you mind submitting a PR with this change, ideally also updating tests if needed (which I would think would be)?

asm89 commented 7 years ago

@elazar I would, but it might take a while as I have to get permission from my employer to contribute code. If anyone else is up for it in the meantime please take it. 👍