Called at the start of an element.

@param string[] $attrs an array of key value pairs for the attributes

@return void
17900
private function gedcomStartHandler(array $attrs): void
    {
        if ($this->process_gedcoms > 0) {
            $this->process_gedcoms++;

            return;
        }

        $tag       = $attrs['id'];
        $tag       = str_replace('@fact', $this->fact, $tag);
        $tags      = explode(':', $tag);
        $newgedrec = '';
        if (count($tags) < 2) {
            $tmp       = GedcomRecord::getInstance($attrs['id'], $this->tree);
            $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($this->tree)) : '';
        }
        if (empty($newgedrec)) {
            $tgedrec   = $this->gedrec;
            $newgedrec = '';
            foreach ($tags as $tag) {
                if (preg_match('/\$(.+)/', $tag, $match)) {
                    if (isset($this->vars[$match[1]]['gedcom'])) {
                        $newgedrec = $this->vars[$match[1]]['gedcom'];
                    } else {
                        $tmp       = GedcomRecord::getInstance($match[1], $this->tree);
                        $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($this->tree)) : '';
                    }
                } else {
                    if (preg_match('/@(.+)/', $tag, $match)) {
                        $gmatch = [];
                        if (preg_match("/\d $match[1] @([^@]+)@/", $tgedrec, $gmatch)) {
                            $tmp       = GedcomRecord::getInstance($gmatch[1], $this->tree);
                            $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($this->tree)) : '';
                            $tgedrec   = $newgedrec;
                        } else {
                            $newgedrec = '';
                            break;
                        }
                    } else {
                        $temp      = explode(' ', trim($tgedrec));
                        $level     = 1 + (int) $temp[0];
                        $newgedrec = Functions::getSubRecord($level, "$level $tag", $tgedrec);
                        $tgedrec   = $newgedrec;
                    }
                }
            }
        }
        if (!empty($newgedrec)) {
            $this->gedrec_stack[] = [$this->gedrec, $this->fact, $this->desc];
            $this->gedrec         = $newgedrec;
            if (preg_match("/(\d+) (_?[A-Z0-9]+) (.*)/", $this->gedrec, $match)) {
                $this->fact = $match[2];
                $this->desc = trim($match[3]);
            }
        } else {
            $this->process_gedcoms++;
        }
    }
306086
public function setAttribute( $attr, $value ) {
        //value is the text node
        //we add this for the sake of consistency amongst other form elements
        if( strtolower( $attr ) == 'value' ) {
           $this->setText( $value );
        } else {
            parent::setAttribute( $attr, $value );
        }
    }
496898
protected function checkAttr($values, $attr)
    {
        if (!is_array($values)) $values = array($values);

        foreach ($values as $value) {
            if (!@in_array($value, $this->get_value($attr, 'all'))) {
                return false;
            }
        }
        return true;
    }
958847
public void setAttrs(String[] attrs, String[] descs) {
    for (int i = 0; i < attrs.length && i < descs.length; i++) {
      descriptions.put(attrs[i], descs[i]);
    }
    this.attrs = attrs;
  }
1237253
public function setAttributes(array $attributes)
    {
        foreach ($attributes as $attribute => $value) {
            $this->setAttribute($attribute, $value);
        }
    }
1173581
private function relativesStartHandler(array $attrs): void
    {
        $this->process_repeats++;
        if ($this->process_repeats > 1) {
            return;
        }

        $sortby = $attrs['sortby'] ?? 'NAME';

        $match = [];
        if (preg_match("/\\$(\w+)/", $sortby, $match)) {
            $sortby = $this->vars[$match[1]]['id'];
            $sortby = trim($sortby);
        }

        $maxgen = -1;
        if (isset($attrs['maxgen'])) {
            $maxgen = (int) $attrs['maxgen'];
        }
        if ($maxgen === '*') {
            $maxgen = -1;
        }

        $group = $attrs['group'] ?? 'child-family';

        if (preg_match("/\\$(\w+)/", $group, $match)) {
            $group = $this->vars[$match[1]]['id'];
            $group = trim($group);
        }

        $id = $attrs['id'] ?? '';

        if (preg_match("/\\$(\w+)/", $id, $match)) {
            $id = $this->vars[$match[1]]['id'];
            $id = trim($id);
        }

        $this->list = [];
        $person     = Individual::getInstance($id, $this->tree);
        if ($person instanceof Individual) {
            $this->list[$id] = $person;
            switch ($group) {
                case 'child-family':
                    foreach ($person->childFamilies() as $family) {
                        foreach ($family->spouses() as $spouse) {
                            $this->list[$spouse->xref()] = $spouse;
                        }

                        foreach ($family->children() as $child) {
                            $this->list[$child->xref()] = $child;
                        }
                    }
                    break;
                case 'spouse-family':
                    foreach ($person->spouseFamilies() as $family) {
                        foreach ($family->spouses() as $spouse) {
                            $this->list[$spouse->xref()] = $spouse;
                        }

                        foreach ($family->children() as $child) {
                            $this->list[$child->xref()] = $child;
                        }
                    }
                    break;
                case 'direct-ancestors':
                    $this->addAncestors($this->list, $id, false, $maxgen);
                    break;
                case 'ancestors':
                    $this->addAncestors($this->list, $id, true, $maxgen);
                    break;
                case 'descendants':
                    $this->list[$id]->generation = 1;
                    $this->addDescendancy($this->list, $id, false, $maxgen);
                    break;
                case 'all':
                    $this->addAncestors($this->list, $id, true, $maxgen);
                    $this->addDescendancy($this->list, $id, true, $maxgen);
                    break;
            }
        }

        switch ($sortby) {
            case 'NAME':
                uasort($this->list, GedcomRecord::nameComparator());
                break;
            case 'BIRT:DATE':
                uasort($this->list, Individual::birthDateComparator());
                break;
            case 'DEAT:DATE':
                uasort($this->list, Individual::deathDateComparator());
                break;
            case 'generation':
                $newarray = [];
                reset($this->list);
                $genCounter = 1;
                while (count($newarray) < count($this->list)) {
                    foreach ($this->list as $key => $value) {
                        $this->generation = $value->generation;
                        if ($this->generation == $genCounter) {
                            $newarray[$key]             = new stdClass();
                            $newarray[$key]->generation = $this->generation;
                        }
                    }
                    $genCounter++;
                }
                $this->list = $newarray;
                break;
            default:
                // unsorted
                break;
        }
        $this->repeats_stack[] = [$this->repeats, $this->repeat_bytes];
        $this->repeat_bytes    = xml_get_current_line_number($this->parser) + 1;
    }
1286934
void setAttributesForInit(Map<String, Object> attr) {
    this.attributes.clear();
    if (attr != null) {
      this.attributes.putAll(attr);
    }
  }
83919
private function startelement($parser, $name, $attrs) {
        $current = &$this->current;
        $level = &$this->level;
        if (!empty($name)) {
            if ($level == 0) {
                $current[$level][$name] = array();
                $current[$level][$name]["@"] = $attrs; // Attribute.
                $current[$level][$name]["#"] = array(); // Other tags.
                $current[$level + 1] = & $current[$level][$name]["#"];
                $level++;
            } else {
                if (empty($current[$level][$name])) {
                    $current[$level][$name] = array();
                }
                $siz = count($current[$level][$name]);
                if (!empty($attrs)) {
                    $current[$level][$name][$siz]["@"] = $attrs; // Attribute.
                }
                $current[$level][$name][$siz]["#"] = array(); // Other tags.
                $current[$level + 1] = & $current[$level][$name][$siz]["#"];
                $level++;
            }
        }
    }
1129147
public function tfoot(array $attributes = []): void
    {
        $this->tableArray[] = Tags::tfoot($this->trArray, $attributes);
        $this->trArray = [];
    }
323449
private void init(AttributeSet attrs) {
        inflate(getContext(), R.layout.intl_phone_input, this);

        /**+
         * Country spinner
         */
        mCountrySpinner = (Spinner) findViewById(R.id.intl_phone_edit__country);
        mCountrySpinnerAdapter = new CountrySpinnerAdapter(getContext());
        mCountrySpinner.setAdapter(mCountrySpinnerAdapter);

        mCountries = CountriesFetcher.getCountries(getContext());
        mCountrySpinnerAdapter.addAll(mCountries);
        mCountrySpinner.setOnItemSelectedListener(mCountrySpinnerListener);

        setFlagDefaults(attrs);

        /**
         * Phone text field
         */
        mPhoneEdit = (EditText) findViewById(R.id.intl_phone_edit__phone);
        mPhoneEdit.addTextChangedListener(mPhoneNumberWatcher);

        setDefault();
        setEditTextDefaults(attrs);
    }
1361059
public static function newRow(array $attrs = array()) {
        if (!empty(self::$row_data))
            self::$rows[count(self::$rows) - 1][] = self::$row_data;
        self::$row_data = array();
        self::$rows[][] = $attrs;
        return count(self::$rows);
    }
203618
protected function setDataAttributes(Attributes $attributes)
    {
        // add data attributes
        $this->bootstrap_dataAttributes = deserialize($this->bootstrap_dataAttributes, true);

        if (empty($this->bootstrap_dataAttributes)) {
            return;
        }

        foreach ($this->bootstrap_dataAttributes as $attribute) {
            if (trim($attribute['value']) != '' && $attribute['name'] != '') {
                $attributes->setAttribute('data-' . $attribute['name'], $attribute['value']);
            }
        }
    }
925644
public static function init(array $attributes = array()) {
        self::$table_attributes = array();
        self::$rows = array();
        self::$row_data = array();
        self::$headers = array();
        self::$footers = array();

        self::setAttributes($attributes);
    }
693493
protected function add_autovalues(&$attrs)
    {
        if (empty($this->prop['autovalues'])) {
            return;
        }

        $attrvals = array();
        foreach ($attrs as $k => $v) {
            $attrvals['{'.$k.'}'] = is_array($v) ? $v[0] : $v;
        }

        foreach ((array)$this->prop['autovalues'] as $lf => $templ) {
            if (empty($attrs[$lf])) {
                if (strpos($templ, '(') !== false) {
                    // replace {attr} placeholders with (escaped!) attribute values to be safely eval'd
                    $code = preg_replace('/\{\w+\}/', '', strtr($templ, array_map('addslashes', $attrvals)));
                    $res  = false;

                    try {
                        $res = eval("return ($code);");
                    }
                    catch (ParseError $e) {
                        // ignore
                    }

                    if ($res === false) {
                        rcube::raise_error(array(
                            'code' => 505, 'file' => __FILE__, 'line' => __LINE__,
                            'message' => "Expression parse error on: ($code)"), true, false);
                        continue;
                    }

                    $attrs[$lf] = $res;
                }
                else {
                    // replace {attr} placeholders with concrete attribute values
                    $attrs[$lf] = preg_replace('/\{\w+\}/', '', strtr($templ, $attrvals));
                }
            }
        }
    }
961417
protected function initAttrs()
    {
        $attrs = self::getAttrs();
        foreach ($attrs as $key => $attr) {
            if (! isset($attr['default'])) continue;
            if (! isset($this->cleanData[$key])) {
                $this->$key = $attr['default'];
            }
        }
    }
667460
public function addAttributes(array $attrs)
	{
		$this->getElementPrototype('td')->addAttributes($attrs);
		$this->getElementPrototype('th')->addAttributes($attrs);

		return $this;
	}
185975
public function setAttributes($attributes) {
        $this->setVariable(self::ATTRIBUTES, "");
        foreach($attributes as $name => $value) {
            $this->addAttribute($name, $value);
        }
    }