> The extra params aren't really _that_ bad.

Okay, I'd like to reset the conversation a bit here. It's clear that the
current API does not fit the problem domain very well. Tacking on more
parameters only creates a bigger mess. Six parameters to a stateless
function call is a completely incoherent API. It's unusable without
consulting the manual. I think we need a completely different approach. Let
me propose something else that won't break BC in any release and results in
an API that's actually sane:

class CryptoContext {
    private $mode;
    private $password;
    function __construct($mode, $password) {
        $this->mode = $mode;
        $this->password = $password;
    }
    function encrypt($data) {
        // ...
        return $encryptedData;
    }
    function decrypt($data) {
        // ...
        return $decryptedData;
    }
    function setOption($option, $value) {
        // ...
    }
    // more methods here to do anything you need
}

Thoughts on a stateful object API here? Personally I find this much more
coherent than anything that's been proposed so far and it could be
implemented without affecting existing functionality.

Reply via email to