Code preview: Object and Component

I'd like to share with you the most important classes in Yii 2.0: Object and Class. They provide the foundation for all other advanced features of Yii. They are close to release quality, but your suggestions and feedback are always welcome. The code should also show the new coding style that is used throughout the whole 2.0 codebase.

The new coding style with the many extra spaces looks more to how I style my code, so I enjoy that.
Just like I'm going to use the static attribute Yii::$objectConfig. A lot.

I still need to get used to the new class names: I kinda miss the initial 'C' on classnames and 'I' on interface names (got so used to them, but I'll hide my tears).

I noticed 2 ways to create a new instance:
1. the new way using Classname::newInstance()
2. the old way using Yii::createObject()
Will both of these remain? Or are they different?

Finally I think the description of the Component.__get() method is not quite the same as what the code does: the description says a behavior object may be returned, but I don't find that back in the code.

Overall I like the new style and can't wait to get used to the new and improved gadgets.
Good job!

Component L.207 wouldn't a BadMethodCallException (part of SPL) be more appropiate here?
Also all-lowercase namespace? Its just athetic, but "Yii\Bla" just looks better as "yii\bla" in my oppinion. (I know i can use the first version in my code, but yeah .

I was just playing around with your new Component class and noticed some (possibly unwanted) behavior:

The detachBehaviors() method does not only remove all behaviors but also sets Component->_b to null.

Next time you call a non-existing method on the class (the __call(...) method is then called) which may in turn call ensureBehaviors(). This will re-install the class behaviors as Component->_b is null.

My point of view:
detachBehaviors() should detach all behaviors leaving Component->_b an empty array.
a new method resetBehaviors() should detach all behaviors and set Component->_b to null.

@onman: Good catch. Fixed. Thanks! We still have Yii::createObject() which allows you specify a class using path alias. That's the main difference.
@Mike: Fixed. Thanks!
@Suralc: Yes, we plan to introduce an exception hierarchy.

when attaching a behavior through the __set() method it always seems to expect a value that is passed to Yii::createObject(). But this value can already be a behavior object and should then be used as is.

If I want to interrupt the event for some reason, like if there is no permission or something, I would set $event->handled to true or to be easier just return false and it would return false in trigger method, allowing the caller to know whether the event was successful.