XML_RPC_Message::closing_tag PHP Method

closing_tag() public method

End Element Handler
public closing_tag ( $the_parser, $name ) : void
return void
    public function closing_tag($the_parser, $name)
    {
        $the_parser = (string) $the_parser;
        if ($this->xh[$the_parser]['isf'] > 1) {
            return;
        }
        // Remove current element from stack and set variable
        // NOTE: If the XML validates, then we do not have to worry about
        // the opening and closing of elements. Nesting is checked on the opening
        // tag so we be safe there as well.
        $curr_elem = array_shift($this->xh[$the_parser]['stack']);
        switch ($name) {
            case 'STRUCT':
            case 'ARRAY':
                $cur_val = array_shift($this->xh[$the_parser]['valuestack']);
                $this->xh[$the_parser]['value'] = isset($cur_val['values']) ? $cur_val['values'] : array();
                $this->xh[$the_parser]['vt'] = strtolower($name);
                break;
            case 'NAME':
                $this->xh[$the_parser]['valuestack'][0]['name'] = $this->xh[$the_parser]['ac'];
                break;
            case 'BOOLEAN':
            case 'I4':
            case 'INT':
            case 'STRING':
            case 'DOUBLE':
            case 'DATETIME.ISO8601':
            case 'BASE64':
                $this->xh[$the_parser]['vt'] = strtolower($name);
                if ($name === 'STRING') {
                    $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
                } elseif ($name === 'DATETIME.ISO8601') {
                    $this->xh[$the_parser]['vt'] = $this->xmlrpcDateTime;
                    $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
                } elseif ($name === 'BASE64') {
                    $this->xh[$the_parser]['value'] = base64_decode($this->xh[$the_parser]['ac']);
                } elseif ($name === 'BOOLEAN') {
                    // Translated BOOLEAN values to TRUE AND FALSE
                    $this->xh[$the_parser]['value'] = (bool) $this->xh[$the_parser]['ac'];
                } elseif ($name == 'DOUBLE') {
                    // we have a DOUBLE
                    // we must check that only 0123456789-.<space> are characters here
                    $this->xh[$the_parser]['value'] = preg_match('/^[+-]?[eE0-9\\t \\.]+$/', $this->xh[$the_parser]['ac']) ? (double) $this->xh[$the_parser]['ac'] : 'ERROR_NON_NUMERIC_FOUND';
                } else {
                    // we have an I4/INT
                    // we must check that only 0123456789-<space> are characters here
                    $this->xh[$the_parser]['value'] = preg_match('/^[+-]?[0-9\\t ]+$/', $this->xh[$the_parser]['ac']) ? (int) $this->xh[$the_parser]['ac'] : 'ERROR_NON_NUMERIC_FOUND';
                }
                $this->xh[$the_parser]['ac'] = '';
                $this->xh[$the_parser]['lv'] = 3;
                // indicate we've found a value
                break;
            case 'VALUE':
                // This if() detects if no scalar was inside <VALUE></VALUE>
                if ($this->xh[$the_parser]['vt'] == 'value') {
                    $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
                    $this->xh[$the_parser]['vt'] = $this->xmlrpcString;
                }
                // build the XML-RPC value out of the data received, and substitute it
                $temp = new XML_RPC_Values($this->xh[$the_parser]['value'], $this->xh[$the_parser]['vt']);
                if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] === 'ARRAY') {
                    // Array
                    $this->xh[$the_parser]['valuestack'][0]['values'][] = $temp;
                } else {
                    // Struct
                    $this->xh[$the_parser]['value'] = $temp;
                }
                break;
            case 'MEMBER':
                $this->xh[$the_parser]['ac'] = '';
                // If value add to array in the stack for the last element built
                if ($this->xh[$the_parser]['value']) {
                    $this->xh[$the_parser]['valuestack'][0]['values'][$this->xh[$the_parser]['valuestack'][0]['name']] = $this->xh[$the_parser]['value'];
                }
                break;
            case 'DATA':
                $this->xh[$the_parser]['ac'] = '';
                break;
            case 'PARAM':
                if ($this->xh[$the_parser]['value']) {
                    $this->xh[$the_parser]['params'][] = $this->xh[$the_parser]['value'];
                }
                break;
            case 'METHODNAME':
                $this->xh[$the_parser]['method'] = ltrim($this->xh[$the_parser]['ac']);
                break;
            case 'PARAMS':
            case 'FAULT':
            case 'METHODCALL':
            case 'METHORESPONSE':
                // We're all good kids with nuthin' to do
                break;
            default:
                // End of an Invalid Element. Taken care of during the opening tag though
                break;
        }
    }