9797 *
9898 * @author Qiang Xue <qiang.xue@gmail.com>
9999 * @since 2.0
100+ *
101+ * @phpstan-property-read Behavior<$this>[] $behaviors
102+ * @psalm-property-read Behavior<$this>[] $behaviors
100103 */
101104class Component extends BaseObject
102105{
@@ -111,6 +114,8 @@ class Component extends BaseObject
111114 private $ _eventWildcards = [];
112115 /**
113116 * @var Behavior[]|null the attached behaviors (behavior name => behavior). This is `null` when not initialized.
117+ *
118+ * @phpstan-var Behavior<$this>[]|null
114119 */
115120 private $ _behaviors ;
116121
@@ -661,6 +666,9 @@ public function trigger($name, ?Event $event = null)
661666 * Returns the named behavior object.
662667 * @param string $name the behavior name
663668 * @return Behavior|null the behavior object, or null if the behavior does not exist
669+ *
670+ * @phpstan-return Behavior<$this>|null
671+ * @psalm-return Behavior<$this>|null
664672 */
665673 public function getBehavior ($ name )
666674 {
@@ -671,6 +679,9 @@ public function getBehavior($name)
671679 /**
672680 * Returns all behaviors attached to this component.
673681 * @return Behavior[] list of behaviors attached to this component
682+ *
683+ * @phpstan-return Behavior<$this>[]
684+ * @psalm-return Behavior<$this>[]
674685 */
675686 public function getBehaviors ()
676687 {
@@ -692,6 +703,12 @@ public function getBehaviors()
692703 *
693704 * @return Behavior the behavior object
694705 * @see detachBehavior()
706+ *
707+ * @phpstan-param string|array|Behavior<$this> $behavior
708+ * @psalm-param string|array|Behavior<$this> $behavior
709+ *
710+ * @phpstan-return Behavior<$this>
711+ * @psalm-return Behavior<$this>
695712 */
696713 public function attachBehavior ($ name , $ behavior )
697714 {
@@ -719,6 +736,9 @@ public function attachBehaviors($behaviors)
719736 * The behavior's [[Behavior::detach()]] method will be invoked.
720737 * @param string $name the behavior's name.
721738 * @return Behavior|null the detached behavior. Null if the behavior does not exist.
739+ *
740+ * @phpstan-return Behavior<$this>|null
741+ * @psalm-return Behavior<$this>|null
722742 */
723743 public function detachBehavior ($ name )
724744 {
@@ -764,6 +784,10 @@ public function ensureBehaviors()
764784 * will be detached first.
765785 * @param string|array|Behavior $behavior the behavior to be attached
766786 * @return Behavior the attached behavior.
787+ *
788+ * @phpstan-param string|array|Behavior<$this> $behavior
789+ *
790+ * @phpstan-return Behavior<$this>
767791 */
768792 private function attachBehaviorInternal ($ name , $ behavior )
769793 {
0 commit comments