How does Yii handle alias

While using alias, I feel it it so amazing. Could anyone guild me a link which explains the implementation of alias?

I had read the code of BaseYii.php. But I still don’t know how it handles “@” at runtime. Does it translate the whole source code at runtime?

BTW, I had googled similar question with different sentences but no luck.

Here’s implementation:

What do you mean by "translate the whole source code at runtime"?

Thanks for the information.

And yes, you are correct. I just wondering if yii translate the whole source code at runtime. We had use "@xxxx" at our source code in many function calls. And it just works.

No, it does not. It inits an array of root aliases bound to dirs. Then when getAlias() is used it’s looking up this array and replaces first part of the alias starting with @ with what’s in the aliases array.