Why this is so?
The difference is sometimes more sometimes less, but the first option is always faster…
$ar = new \yii\db\ActiveRecord();
$ar->id = 123456789;
$numberOfIteration = 10000000; //10 millions
$tmp = null;
for ($i=0;$i<$numberOfIteration;$i++){
$tmp = $ar->id; // faster: 25.631805896759 s
}
$tmp = null;
for ($i=0;$i<$numberOfIteration;$i++){
$tmp = $ar['id']; // slower: 38.955304861069 ms
}