make SSH2::exec behave as expected#1843
Conversation
SSH2::exec used to behave differently when false was given as callback, this has been changed in the method signature to be nullable but not reflected in the code
|
I'm curious... did you port your v2 code to v3 before or after this change? If the latter, then remember that as a major release, v3 isn't aiming to be BC with v2 at all. For that there's phpseclib/phpseclib_compat. If the former then https://xkcd.com/1172/ seems relevant. |
|
Regarding the code. If you leave the typehint |
Easy solution to that is to change That said, it's unclear what your use case is where it's beneficial for it to be false. There are some definite benefits to it being type hinted as a function doSomething() {}
$ssh->exec('ping 127.0.0.1', 'doSmething');That's a typo and the callable type hit can alert you to that fact. Well, it may not tell you that it's a typo but it'll tell you that there's an issue on that line. So there are definitely advantages to having something type hinted as a callable. The advantages of not doing so are as yet unclear to me. |
My first attempt was to do exactly that changing to null, null checks and the type hint. That broke the logic that
Passing Either way, I love using the library and |
|
In reviewing the code.... I think the most appropriate code change to address the if condition that can't ever be true ( If you want to achieve the same effect without using The feature in 1.0 / 2.0 mainly exists to facilitate SCP, which the 3.0 branch dropped. |
That change has been made: |
|
Sorry for being so quiet, I’ll check out your change! :-) |
SSH2::exec used to behave differently when
falsewas given as callback, this has been changed in the method signature to be nullable but not reflected in the code.We got a huge chunk of PHP code using phpseclib v2 and while we ported our code to phpseclib v3 we came across a few issues which one of them needs to be fixed upstream :-)
I hope that makes sense for you, I’d appreciate to have this merged and released quite soon.