null
/** * Reads the next token from the INI file * * @throws IOException On error * @return Token */ function readToken() { if ($this->file === null) { throw new BuildException("No File set for IniFileTokenReader"); } static $tokens = null; if ($tokens === null) { $tokens = array(); $arr = parse_ini_file($this->file->getAbsolutePath(), true); if ($this->section === null) { foreach ($arr as $sec_name => $values) { foreach ($arr[$sec_name] as $key => $value) { $tok = new Token(); $tok->setKey($key); $tok->setValue($value); $tokens[] = $tok; } } } else { if (isset($arr[$this->section])) { foreach ($arr[$this->section] as $key => $value) { $tok = new Token(); $tok->setKey($key); $tok->setValue($value); $tokens[] = $tok; } } } } if (count($tokens) > 0) { return array_pop($tokens); } else { return null; } }
/** * Initializes tokens and loads the replacee-replacer hashtable. * This method is only called when this filter is used through * a <filterreader> tag in build file. */ private function _initialize() { $params = $this->getParameters(); if ($params !== null) { for ($i = 0; $i < count($params); $i++) { if ($params[$i] !== null) { $type = $params[$i]->getType(); if ($type === "tokenchar") { $name = $params[$i]->getName(); if ($name === "begintoken") { $this->_beginToken = substr($params[$i]->getValue(), 0, 1); } else { if ($name === "endtoken") { $this->_endToken = substr($params[$i]->getValue(), 0, 1); } } } else { if ($type === "token") { $name = $params[$i]->getName(); $value = $params[$i]->getValue(); $tok = new Token(); $tok->setKey($name); $tok->setValue($value); array_push($this->_tokens, $tok); } else { if ($type === "tokensource") { // Store data from nested tags in local array $arr = array(); $subparams = $params[$i]->getParams(); $count = count($subparams); for ($i = 0; $i < $count; $i++) { $arr[$subparams[$i]->getName()] = $subparams[$i]->getValue(); } // Create TokenSource $tokensource = new TokenSource(); if (isset($arr["classname"])) { $tokensource->setClassname($arr["classname"]); } // Copy other parameters 1:1 to freshly created TokenSource foreach ($arr as $key => $value) { if (strtolower($key) === "classname") { continue; } $param = $tokensource->createParam(); $param->setName($key); $param->setValue($value); } $this->_tokensources[] = $tokensource; } } } } } } }
/** * Process an individual section * * @param array $section */ protected function processSection(array $section) { foreach ($section as $key => $value) { $tok = new Token(); $tok->setKey($key); $tok->setValue($value); $this->tokens[] = $tok; } }