fabfuel / prophiler

PHP Profiler & Developer Toolbar (built for Phalcon)
http://prophiler.fabfuel.de
Other
443 stars 54 forks source link

Make PDO decorator extends PDO #70

Open Grafikart opened 7 years ago

Grafikart commented 7 years ago

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

public function myMethod(\PDO $pdo) {

}
sergeyklay commented 7 years ago

@fabfuel Could you please take a look

fabfuel commented 7 years ago

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 commented 6 years ago

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
{
   ...
}