Find a section's index by name.
If a section index or 'new' is passed, it is returned directly.

@param   mixed  $section  The section name or index to find
@return  mixed            The section index, or -1 if not found
971134
private function findSection($section)
	{
		// Check section type
		if (is_int($section) || $section === 'new') {
			return $section;
		} else if (is_string($section)) {
			// Search section names for related index
			$sections = array_keys($this->sections->byName);
			$index = array_search($section, $sections);

			// Return index if found
			if ($index !== false) {
				return $index;
			}
		}

		// Return error message and value
		$this->error = array();
		$this->error['page'] = "Section '$section' was not found on this page";
		return -1;
	}
498148
public function getProperties( $section = NULL )
	{
		if( $section && !$this->hasSection( $section ) )
			throw new InvalidArgumentException( 'Section "'.$section.'" is not existing.' ); 
		if( $section )
			return $this->data[$section];
		return $this->data;
	}
195050
public function removeSection( $section )
	{
		if( !$this->usesSections() )
			throw new RuntimeException( 'Sections are disabled' );
		if( !$this->hasSection( $section ) )
			throw new InvalidArgumentException( 'Section "'.$section.'" is not existing' );
		$index	= array_search( $section, $this->sections);
		unset( $this->sections[$index] );
		return is_int( $this->write() );
	}
78377
public function isSectionUsed(Section $section)
    {
        return $this->sectionHandler->assignmentsCount($section->id) > 0 ||
               $this->sectionHandler->policiesCount($section->id) > 0 ||
               $this->sectionHandler->countRoleAssignmentsUsingSection($section->id) > 0;
    }
1035320
public function partial_count($section)
	{
		// return the defined partial count
		return array_key_exists($section, $this->partials) ? count($this->partials[$section]) : 0;
	}
1287981
public function sectionExists(string $section): bool
    {
        return (bool) trim($this->view->yieldContent($section));
    }
418769
protected function getSection($sections, $section, $inheritance = false) {
		if (isset($sections[$section])) {
			return $sections[$section];
		}
		
		if ($inheritance) {
			foreach (array_keys($sections) as $part) {
				$colon = strpos($part, ':');

				if ($colon === false) {
					continue;
				}

				$successor = trim(substr($part, 0, $colon));
				$parent    = trim(substr($part, $colon + 1));
				
				if (! isset($successor[0], $parent[0])) {
					throw new InvalidIniSection('Invalid definition of the section "' . $part . '"');
				}

				if ($successor !== $section) {
					continue;
				}

				return array_replace(
					$this->getSection($sections, $parent, true),
					$sections[$part]
				);
			}
		}
		
		throw new InvalidIniSection('Section "' . $section . '" wasn\'t found');
	}
471564
public function findSectionOrCreate($name, Section $parent = null, $priority = 1)
    {
        if (is_null($parent)) {
            $parent = $this->getRootSection();
        }

        $section = $this->findSection($name, $parent);

        if (is_null($section)) {
            $section = $this->addSection($name, $parent, $priority);
        }

        return $section;
    }
351402
public function getValues($section = 0)
    {
        if (!isset($this->content[$section])) {
            return array();
        }
        $values = array();
        foreach ($this->content[$section] as $k => $item) {
            if ($item[0] != self::TK_VALUE && $item[0] != self::TK_ARR_VALUE) {
                continue;
            }

            if (preg_match('/^-?[0-9]$/', $item[2])) {
                $val = intval($item[2]);
            } elseif (preg_match('/^-?[0-9\.]$/', $item[2])) {
                $val = floatval($item[2]);
            } elseif (strtolower($item[2]) === 'true' || strtolower($item[2]) === 'on') {
                $val = true;
            } elseif (strtolower($item[2]) === 'false' || strtolower($item[2]) === 'off') {
                $val = false;
            } else {
                $val = $item[2];
            }

            if ($item[0] == self::TK_VALUE) {
                $values[$item[1]] = $val;
            } else {
                $values[$item[1]][$item[3]] = $val;
            }
        }

        return $values;
    }
1260507
public function getIndexByName($name)
    {
        return isset($this->indexes[$name]) ? $this->indexes[$name] : null;
    }
943322
public function getRawSection($section = null)
    {
        if (null === $section) {
            return $this->raw_parameters;
        } elseif (array_key_exists($section, $this->raw_parameters)) {
            return $this->raw_parameters[$section];
        }

        return;
    }
34463
public function delete_all($section)
	{
		// determine the section index name
		$section = $this->config['cache_id'].(empty($section)?'':'.'.$section);

		// get the directory index
		$index = xcache_get($this->config['cache_id'].'__DIR__');

		if (is_array($index))
		{
			// limit the delete if we have a valid section
			if ( ! empty($section))
			{
				$dirs = in_array($section, $index) ? array($section) : array();
			}
			else
			{
				$dirs = $index;
			}

			// loop through the indexes, delete all stored keys, then delete the indexes
			foreach ($dirs as $dir)
			{
				$list = xcache_get($dir);
				foreach ($list as $item)
				{
					xcache_unset($item[0]);
				}
				xcache_unset($dir);
			}

			// update the directory index
			$index = array_diff($index, $dirs);
			xcache_set($this->config['cache_id'].'__DIR__', $index);
		}
	}
829553
protected function check($section, $data)
    {

        // Normalized return array
        $normalized = [];

        if (isset($this->normalize[$section]) && !empty($this->normalize[$section])) {
            foreach ($this->normalize[$section] as $property => $raw) {
                // Default the value for the new key as null
                $value = null;

                if (is_array($raw)) {
                    // Iterate over the raw property we want to use
                    foreach ($raw as $check) {
                        if (array_key_exists($check, $data)) {
                            $value = $data[$check];
                            break;
                        }
                    }
                } else {
                    // String
                    if (array_key_exists($raw, $data)) {
                        $value = $data[$raw];
                    }
                }

                $normalized['gq_' . $property] = $value;
            }
        }

        return $normalized;
    }
431835
private function getIndexOf($segment){
		if($segment instanceof Segment){
			foreach($this->segments as $index=>$other){
				if($other === $segment){
					return $index;
				}
			}
		}else{
			foreach($this->segments as $index=>$other){
				if($other->getName() === $segment){
					return $index;
				}
			}
		}
		return false;
	}
913987
public function getConfig($section)
    {
        if (!isset($this->_sections[$section])) {
            $this->_sections[$section] = $this->di->getConfig($section, $this->di->environment(), []);
        }

        return $this->_sections[$section];
    }
639936
public function getSection($path = null)
	{
		if ($path !== null) {
			$parts = explode('.', $path);
			return (count($parts) == 1) ? 'PHP' : $parts[0];
		} else {
			return $this->section;
		}
	}
614202
private function get_target_section() {

        if (!$this->fixeddataset) {
            $key = rand(1, self::$paramsections[$this->size]);
        } else {
            // Using section 1.
            $key = 1;
        }

        return $key;
    }