Hacking, Coding and Gaming | @[email protected]

I just found this gem, in some of our billing code:

$ci = $this->paymentMethod;

$cc['CC_CardType'] = $ci['CC_CardType'];
$cc['CC_Number'] = $ci['CC_Number'];
$cc['CC_ExpMonth'] = $ci['CC_ExpMonth'];
$cc['CC_ExpYear'] = $ci['CC_ExpYear'];
$cc['CC_Name'] = $ci['CC_Name'];
$cc['CC_Street'] = $ci['CC_Street'];
$cc['CC_City'] = $ci['CC_City'];
$cc['CC_State'] = $ci['CC_State'];
$cc['CC_Country'] = $ci['CC_Country'];
$cc['CC_Zip'] = $ci['CC_Zip'];

$p->loadCreditCardPayment($cc, $total, 0);

First it copies A ($this->paymentMethod) to B ($ci), then copies each value of B in to C ($cc), and then passes C to the function. That's right, 3 copies of the same data, and 14 lines of code. One could also have just passed A to the function, as so:

$p->loadCreditCardPayment($this->paymentMethod, $total, 0);

It's kinda like pouring a drink that's already in glass in to another glass, then using a spoon to move the liquid in to a different glass, then drinking from that last glass... why not just drink from the glass it was originally in? o_O