Skip to content

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