/** * Check recursively if there are duplicate $attr defined in children of $e * set global var hasDuplicateAttribute to true if there is, otherwise, set it to false */ public static function hasDuplicateAttribute($e, $attr, &$id_array) { global $has_duplicate_attribute; //if ($has_duplicate_attribute) return; foreach ($e->children() as $child) { $id_val = strtolower(trim($child->attr[$attr])); // A hack to swap out the element line number for the duplicate ID line number if ($id_val != "" && in_array($id_val, $id_array)) { $has_duplicate_attribute[] = $child->linenumber; $has_duplicate_attribute[] = $child->id; return $has_duplicate_attribute; } else { if ($id_val != "") { array_push($id_array, $id_val); } BasicChecks::hasDuplicateAttribute($child, $attr, $id_array); } } }
/** * Check recursively if there are duplicate $attr defined in children of $global_e * set global var hasDuplicateAttribute to true if there is, otherwise, set it to false */ public static function hasDuplicateAttribute($attr) { global $has_duplicate_attribute, $global_e; $has_duplicate_attribute = false; $id_array = array(); BasicChecks::hasDuplicateAttribute($global_e, $attr, $id_array); return $has_duplicate_attribute; }