CComponent->attachBahaviors might be wrong?

I am not sure that this is a bug or I mistake my understand.

when I attach my behavior to a component I use as following

in Line 2, I need $a as return variable by attachBehavior();

But if I use $a->attachBehaviors( array(‘test’ => array(‘class’ => ‘application.components.ChangeBehavior’))); . This function will return nothing.

My Class


class ChangeBehavior extends CBehavior{

    // Test Override Component Method

    public function test(){

        echo "ChangeBehavior::test();<br />";

    }

    public function test2(){

        echo "ChangeBehavior::test2();<br />";

        

    }

}

class TestComponent extends CComponent {

    //put your code here

    public function test(){

        echo "TestComponent::Test called <br />\n";      

    }


}

My Snippet Code to test

I expected that it should show [color="#0000FF"]ChangeBehavior::test();[/color] , isn’t it?

see API

attachBehavior return IBehavior

not CComponent

$a = $a->attachBehavior(‘test’, array(‘class’ => ‘application.components.ChangeBehavior’));

then $a is IBehavior

$a = $a->attachBehaviors( array(‘test’ => array(‘class’ => ‘application.components.ChangeBehavior’)));

means IBehavior->attchBehaviors

it’s wrong!