php-loep/oauth2-server — pull request #140 by bakura10 (2013-12-27 10:02:54+00:00)
Title: [WIP] Cleaning code

Hi,

First of all, thank you for your awesome library and your help understanding OAuth.

Please don't review this PR yet, I still have a lot of work to do. This PR mainly aims at fixing a lot of CS errors, better architecture and better dependency support. This is an opiniated PR, I'm really open to discussion on all the changes!

Among other things:

* Remove the GrantTrait in favor of an abstract class. This is what we want here, not a trait :).
* Better injection where possible, especially regarding hard dependency.
* Clean some interfaces (especially about the __construct in interfaces).
* Remove fluid interfaces ([here's why](http://ocramius.github.io/blog/fluent-interfaces-are-evil/)).
* Update code to use Symfony Request instead of own Request class
* Rename classes (Authorization and Resource were way too generic. What they are are really authorization and resource server). The issue with that is that I already have AuthorizationService in my code for instance, which handle the real authorization through permissions. Having more explicit name is always better !

There is also something that is wrong to me: the entities classes. You instantiate those entities class in the various grant type but this feels wrong: those entities are actually mean to be persisted somewhere (database...). Therefore, each module will likely provide its own implementation (for instance I'll likely create a ZF2 module for Doctrine, with specific entities with Doctrine mapping).

Therefore, those entities should be moved to a data folder and just provided as dist files, for quick start and having a base to work with, but the code should not rely on this. Instead, the various Storage should type hint the return to specific interfaces, and use this in the code.

I'll try to provide specific implementation for that.

ping @ocramius for reviewing when I'm done