Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.6.2

Bug #20526 CIF Calculation retrieves wrong array index
Submitted: 2015-03-25 16:29 UTC
From: romeurosa Assigned:
Status: Open Package: Validate_ES (version Unknown)
PHP Version: Irrelevant OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2015-03-25 16:29 UTC] romeurosa (Romeu Rosa)
Description: ------------ Taking into consideration the following valid Spanish CIF () This will return 0 from the cif($cif) method found in ES.php. On closer inspection I verified that when you do the final verification: if ((int)$controlCode != $d && $letters2[$d] != $controlCode) { $letters2[$d] for that cif will return F. This is because the array starts at index 0 and not index 1. If you change that for $letters2[$d-1], or shift all the indexes by 1 it will work. Test script: --------------- class ES { function testCIF() { echo 'Result: ' . (int) $this->cif('Q5355149E'); } function cif($cif) { // Same one as in ES.php } } Expected result: ---------------- Result: 1 Actual result: -------------- Result: 0

Comments