(array) will return an object as an array
Assuming $item->classes->attribute_a = 1 and $item->classes->attribute_b = 2 ,
$object_to_array = (array)$item->classes;
creates a linked array equivalent to array('attribute_a' => 1, 'attribute_b' => 2) .
Typecasting is intended not only for arrays, but also for different types. For example, an integer can be represented as a string;
$i = 123; $string_i = (string)$i;
Significantly more on typginging here
Passkit
source share