Parse a section.

@param  array $section
@return array
426313
private function parseSection(array $section)
    {
        $config = [];

        foreach ($section as $key => $value) {
            $this->parseKey($key, $value, $config);
        }

        return $config;
    }
1303274
protected function parse(array $sections = [])
    {
        if (isset($sections['subject']) && ! is_null($sections['subject'])) {
            $this->subject = $sections['subject'];
        }

        if (isset($sections['view']) && ! is_null($sections['view'])) {
            $this->view = $sections['view'];
        }
    }
309102
public function setSection(Section $section)
    {
        if ($section !== $this->_mainsection) {
            $this->_mainsection = null;
            $this->_level = $section->getLevel() + 1;
            if (0 === $this->_position) {
                $this->_position = 1;
            }
        }

        $this->_section = $section;

        return $this;
    }
1335680
protected static function formalUsage($section) {
        list (, $section) = explode(':', $section, 2);  # drop "usage:"
        $pu = preg_split('/\s+/', trim($section));

        $ret = [];
        foreach (array_slice($pu, 1) as $s) {
            if ($s == $pu[0]) $ret[] = ') | (';
            else              $ret[] = $s;
        }
        return '( '.join(' ', $ret).' )';
    }
658361
private static function processSection($section, array $contents)
    {
        // the section does not extend another section
        if (stripos($section, ':') === false) {
            self::$result[$section] = self::processSectionContents($contents);
            
            // section extends another section
        } else {
            // extract section names
            list ($ext_target, $ext_source) = explode(':', $section);
            $ext_target = trim($ext_target);
            $ext_source = trim($ext_source);
            
            // check if the extended section exists
            if (! isset(self::$result[$ext_source])) {
                throw new \Exception('Unable to extend section ' . $ext_source . ', section not found');
            }
            
            // process section contents
            self::$result[$ext_target] = self::processSectionContents($contents);
            
            // merge the new section with the existing section values
            self::$result[$ext_target] = self::arrayMergeRecursive(self::$result[$ext_source], self::$result[$ext_target]);
        }
    }
1300109
private function parseSections(array $simple_parsed) {
        // do an initial pass to gather section names
        $sections = array();
        $globals = array();
        foreach ($simple_parsed as $k => $v) {
            if (is_array($v)) {
                // $k is a section name
                $sections[$k] = $v;
            } else {
                $globals[$k] = $v;
            }
        }

        // now for each section, see if it uses inheritance
        $output_sections = array();
        foreach ($sections as $k => $v) {
            $sects = array_map('trim', array_reverse(explode(':', $k)));
            $root = array_pop($sects);
            $arr = $v;
            foreach ($sects as $s) {
                if ($s === '^') {
                    $arr = array_merge($globals, $arr);
                } elseif (array_key_exists($s, $output_sections)) {
                    $arr = array_merge($output_sections[$s], $arr);
                } elseif (array_key_exists($s, $sections)) {
                    $arr = array_merge($sections[$s], $arr);
                } else {
                    throw new UnexpectedValueException("IniParser: In file '{$this->file}', section '{$root}': Cannot inherit from unknown section '{$s}'");
                }
            }

            if ($this->include_original_sections) {
                $output_sections[$k] = $v;
            }
            $output_sections[$root] = $arr;
        }


        return $globals + $output_sections;
    }
1284710
public function info($section = null)
    {
        if ($section) {
            return $this->client->info($section);
        }

        return $this->client->info();
    }
101405
public function addSection( $section )
	{
		if ( !( isset( $this->data[$section] ) && is_array( $this->data[$section] ) ) )
			$this->data[$section]	= array();
		$this->currentSection	= $section;
	}
1033724
public static function get_config($section = '') {

        $params = self::validate_parameters(self::get_config_parameters(), array('section' => $section));

        $settings = api::get_config($params['section']);
        $result['settings'] = array();
        foreach ($settings as $name => $value) {
            $result['settings'][] = array(
                'name' => $name,
                'value' => $value,
            );
        }

        $result['warnings'] = array();
        return $result;
    }
1090920
public function parse() : array
    {
        $buffer = $this->routing_rule;
        
        $section_list_set = [];
        $current_list = [];
        do
        {
            $pos = strpos(substr($buffer,1),'/');
            $section = $pos !== false ? substr($buffer, 1, $pos) : substr($buffer, 1);
            $buffer = $pos !== false ? substr($buffer, $pos + 1) : '';
            
            $length = strlen($section);
            if ($length === 0){
                $current_list[] = new class implements EmptyRoutingPathInterface {};
                if (!empty($buffer)){
                    throw new RoutingRuleParseException($this->routing_rule, "Empty routing section is allowed only for last element");
                }
                break;
            }
            $first = $section[0];
            $last = $section[$length - 1];
            if ($first === '[' && $last === ']'){
                // push current list
                $section_list_set[] = $current_list + ['()'];
                // add optional part to current list
                $inside = substr($section, 1, $length - 2);
                if ($inside[0] === ':') {
                    $current_list[] = self::parseVariablePattern($inside);
                }
                else {
                    $current_list[] = $inside;
                }
            }
            else if ($first === ':') {
                $current_list[] = self::parseVariablePattern($section);
            }
            else {
                $current_list[] = $section;
            }
        }
        while(!empty($buffer));
        
        $section_list_set[] = $current_list;
        return $section_list_set;
    }
213389
public static function create_from_section($section) {
        $event = self::create([
            'context' => \context_course::instance($section->course),
            'objectid' => $section->id,
            'other' => ['sectionnum' => $section->section]
        ]);
        $event->add_record_snapshot('course_sections', $section);
        return $event;
    }
5785
public static function Section($Section, $Method = 'add') {
      $Section = array_fill_keys((array)$Section, TRUE);
      
      
      switch (strtolower($Method)) {
         case 'add':
            self::$_Section = array_merge(self::$_Section, $Section);
            break;
         case 'remove':
            self::$_Section = array_diff_key(self::$_Section, $Section);
            break;
         case 'set':
            self::$_Section = $Section;
            break;
         case 'get':
         default:
            return array_keys(self::$_Section);
      }
   }
746245
protected function findClass($section)
    {
        try {
            if ($section instanceof Closure) {
                return get_class($section());
            }
            if (is_object($section)) {
                return get_class($section);
            }
            if (is_string($section)) {
                return $section;
            }
            if (is_array($section) && isset($section['class'])) {
                return $section['class'];
            }
        } catch (Exception $exception) {
            # Ignore
        }
        return false;
    }
929358
private static function processSectionContents(array $contents)
    {
        $result = array();
        
        // loop through each line and convert it to an array
        foreach ($contents as $path => $value) {
            // convert all a.b.c.d to multi-dimensional arrays
            $process = self::processContentEntry($path, $value);
            
            // merge the current line with all previous ones
            $result = self::arrayMergeRecursive($result, $process);
        }
        
        return $result;
    }
995425
public function get_section_name($section) {
        $section = $this->get_section($section);
        if ((string)$section->name !== '') {
            // Return the name the user set.
            return format_string($section->name, true, array('context' => context_course::instance($this->courseid)));
        } else {
            return $this->get_default_section_name($section);
        }
    }
875421
public function getSection($section)
    {
        if (!array_key_exists($section, $this->config)) {
            return null;
        }

        return $this->config[$section];
    }
605188
public function loadSections()
    {
        $response = $this->client->request(
            'GET',
            $this->requestParser->generate('sections'),
            new Message(
                array('Accept' => $this->outputVisitor->getMediaType('SectionList'))
            )
        );

        return $this->inputDispatcher->parse($response);
    }