ConnectionInterface docblock is wrong or implementation is wrong.. #3469

Closed
cdekok opened this Issue Jan 17, 2013 · 4 comments

Projects

None yet

3 participants

Contributor
cdekok commented Jan 17, 2013

Interface..

    /**
     * Connect
     *
     * @return ConnectionInterface
     */
    public function connect();

Pgsql connection returns nothing..

    /**
     * Connect to the database
     *
     * @return void
     * @throws Exception\RuntimeException on failure
     */
    public function connect()
Member
Maks3w commented Jan 17, 2013
Owner

While interfaces can indicate via the docblock what they expect an implementation to return, this is not binding. I would always check to see what the given implementation defines in its own docblock.

In looking through the various concrete implementations, some return the connection, some do not; in some cases, what is returned is based on what occurs within the internals of the implementation within logic branches.

Considering this would be defining a fluent interface at best, I'm not sure it's important. If you feel it is, please feel free to submit a pull request that makes the behavior consistent across the various implementations.

Owner

Re-opening after discussion with @Maks3w

What should likely happen is one of the following:

  • Change the interface to indicate a "null" return value, and ensure all concrete interfaces enforce that, or
  • Change the concrete interfaces to always do a return $this, and to have the docblock indicate the concrete class returned.
@weierophinney weierophinney reopened this Jan 18, 2013
Member
Maks3w commented Jan 18, 2013

I suggest implement the fluent interface for preserve the backward compatibility.

@Mech7 If you want send a contribution for fix this.

@weierophinney weierophinney was assigned Feb 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment