来自表达式的PHP const

I have a class (MetricUnits) that looks like this:

class MetricUnit {
    const SIZE = [
        "value" => 0,
        "text" => Yii::t("app", "Size")
    ];
}

Yii::t is a i18n function. As you'd be probably thinking by now, this is invalid as PHP doesn't allow expressions in const.

How can I avoid that limitation so I could get the text of that cons?

Btw, Yii::t doesn't take any non-string values, not even const values, so I can't do something like:

class MetricUnit {
    const SIZE = [
        "value" => 0,
        "text" => "Size"
    ];
}

Yii::t("app", MetricUnit::SIZE["text"]);

As it was mentioned, you cannot run calculations like that -

Furthermore, since you have to do some calculation to get that attribute, then technically, it isn't really a constant value constant -

So, I would recommend you do this:

class MetricUnit {

     public static $SIZE;

     public static getSize(){
          return self::$SIZE ? : self::$SIZE = array(
             "value" => 0,
             "text" => Yii::t("app", "Size")
         );
     }

}