Skip to content

Instantly share code, notes, and snippets.

@timkelty
Created August 2, 2022 20:34
Show Gist options
  • Save timkelty/487a748f13d6737139323efdad6ea589 to your computer and use it in GitHub Desktop.
Save timkelty/487a748f13d6737139323efdad6ea589 to your computer and use it in GitHub Desktop.
<?php
class UserBehavior exends \yii\base\Behavior
{
public bool $myDynamicallyAddedProp = false;
}
$user = new \yii\web\User();
$user->attachBehavior('myUser', UserBehavior::class);
// I want to have $user be aware of myDynamicallyAddedProp, without having to "@var User|UserBehavior".
// We can't simply use @mixin on the \yii\web\User class, as that is a library class we don't control.
$user->myDynamicallyAddedProp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment