Solved the problem by explicitly specifying the data type

$resize = 'VDI.resize'; $xcpapi->$resize($vdi, ''.(int)$hdd2.'');

Doesn't work without brackets

''.(int)$hdd2.''