getIs* & getHas*

Why have Yii devs chosen to name boolean getter methods with a starting getIs/getHas? Examples:




    public function getIsActive()

...

    public function getHasSessionId()



And in numerous other places.

Wouldn’t isActive() & hasSessionId() be enough?

Nevermind, I think I found the reason, you can still use:


if ($session->isActive) ...

and rely on the fact that failing to find such a method, class Component’s magical __get() method rewrites it to getIsActive and calls the proper method.

Still such design looks a bit weird. Why not simply name the method isActive in the first place?

It is a common practice in Yii to use properties instead of methods for getters and setters. getIsActive() creates a read only property when there is no setter.

Thanks, then it makes some sense. $session->isActive is two keystrokes shorter than $session->isActive() :)