Skip to content

Make PDO decorator extends PDO#70

Open
Grafikart wants to merge 1 commit into
fabfuel:developfrom
Grafikart:patch-1
Open

Make PDO decorator extends PDO#70
Grafikart wants to merge 1 commit into
fabfuel:developfrom
Grafikart:patch-1

Conversation

@Grafikart

Copy link
Copy Markdown

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
Copy Markdown

@fabfuel Could you please take a look

@fabfuel

fabfuel commented Sep 15, 2017

Copy link
Copy Markdown
Owner

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

mschop commented Feb 9, 2018

Copy link
Copy Markdown

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