Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PDO decorator extends PDO #70

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Make PDO decorator extends PDO #70

wants to merge 1 commit into from

Conversation

Grafikart
Copy link

This would allow the decorator to be injected to replace the original PDO object without breaking typehinting.

public function myMethod(\PDO $pdo) {

}

@sergeyklay
Copy link

@fabfuel Could you please take a look

@fabfuel
Copy link
Owner

fabfuel commented Sep 15, 2017

With this change, it wouldn't be a decorator anymore.
I see how this would make things easier, but this class wouldn't make too much sense, if you extend PDO but still have to inject a PDO instance. Sorry, I can't merge it like this.

@mschop
Copy link

mschop commented Feb 9, 2018

The real problem is, that PHP has not provided an PDOInterface. A real decorator does implement the interface for being compatible with existing implementations. This is not possible here.

Therefore I would recomment creating an interface "PDOInterface". Then one can is able to create real decorators.

class ProfilingPDO implements PDOInterface
{
   ...
}

class MyPDO extends PDO implements PDOInterface
{
   ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants