original_string: private function _parseIni($iniFile)
      {
          $aParsedIni = parse_ini_file($iniFile, true, INI_SCANNER_RAW);
          $tmpArray = array();
          foreach ($aParsedIni as $key=>$value) {
              if (strpos($key, ':') !== false) {
                  $sections = explode(':', $key);
                  if (count($sections) != 2) {
                      throw new Exception('Malformed section header!');
                  }
                  $currentSection = trim($sections[0]);
                  $parentSection = trim($sections[1]);
                  $value = array_merge_recursive(
                      $aParsedIni[$parentSection],
                      $aParsedIni[$key]
                  );
                  $aParsedIni[$currentSection] = $value;
                  unset($aParsedIni[$key]);
                  $key = $currentSection;
              }
              if (is_array($value)) {
                  foreach ($value as $vk=>$vv) {
                      $newKey = $key.".".$vk;
                      $tmpArray[$newKey] = $vv;
                      if (
                             is_string($vv) &&
                             preg_match_all('/\${([a-zA-Z0-9\.]+)}/', $vv, $match)
                          ) {
                          if (!isset($match[1])) {
                              continue;
                          }
                          $variableKey = $match[1];
                          foreach ($variableKey as &$var) {
                              if (strpos($var, '.') === false) {
                                  $var = $key . '.' . $var;
                              }
                          }
                          $this->_varDeps[$newKey] = $variableKey;
                      }
                  }
              }
          }
          if (!empty($tmpArray)) {
              $aParsedIni = $tmpArray;
          }
          foreach ($aParsedIni as $key=>$value) {    //extract parsed array keys
              if (array_key_exists($key, $this->_varDeps)) {
                  $deps = &$this->_varDeps;
                  $value = preg_replace_callback(
                      '/\${([a-zA-Z0-9\.]+)}/',
                      function ($match) use ($key, $aParsedIni, &$deps) {
                          return $aParsedIni[array_shift($deps[$key])];
                      },
                      $value
                  );
                  $aParsedIni[$key] = $value;
              }
              $this->_tmpValue = $value;//set temporay value to current ini value
              $aXKey = explode($this->_delimiter, $key);    //get ini key segments
              //set object properties recursively based on parsed ini
              $this->_recursiveInit($this->_obj, $aXKey);
          }
      }
code: private function _parseIni($iniFile)
      {
          $aParsedIni = parse_ini_file($iniFile, true, INI_SCANNER_RAW);
          $tmpArray = array();
          foreach ($aParsedIni as $key=>$value) {
              if (strpos($key, ':') !== false) {
                  $sections = explode(':', $key);
                  if (count($sections) != 2) {
                      throw new Exception('Malformed section header!');
                  }
                  $currentSection = trim($sections[0]);
                  $parentSection = trim($sections[1]);
                  $value = array_merge_recursive(
                      $aParsedIni[$parentSection],
                      $aParsedIni[$key]
                  );
                  $aParsedIni[$currentSection] = $value;
                  unset($aParsedIni[$key]);
                  $key = $currentSection;
              }
              if (is_array($value)) {
                  foreach ($value as $vk=>$vv) {
                      $newKey = $key.".".$vk;
                      $tmpArray[$newKey] = $vv;
                      if (
                             is_string($vv) &&
                             preg_match_all('/\${([a-zA-Z0-9\.]+)}/', $vv, $match)
                          ) {
                          if (!isset($match[1])) {
                              continue;
                          }
                          $variableKey = $match[1];
                          foreach ($variableKey as &$var) {
                              if (strpos($var, '.') === false) {
                                  $var = $key . '.' . $var;
                              }
                          }
                          $this->_varDeps[$newKey] = $variableKey;
                      }
                  }
              }
          }
          if (!empty($tmpArray)) {
              $aParsedIni = $tmpArray;
          }
          foreach ($aParsedIni as $key=>$value) {    //extract parsed array keys
              if (array_key_exists($key, $this->_varDeps)) {
                  $deps = &$this->_varDeps;
                  $value = preg_replace_callback(
                      '/\${([a-zA-Z0-9\.]+)}/',
                      function ($match) use ($key, $aParsedIni, &$deps) {
                          return $aParsedIni[array_shift($deps[$key])];
                      },
                      $value
                  );
                  $aParsedIni[$key] = $value;
              }
              $this->_tmpValue = $value;//set temporay value to current ini value
              $aXKey = explode($this->_delimiter, $key);    //get ini key segments
              //set object properties recursively based on parsed ini
              $this->_recursiveInit($this->_obj, $aXKey);
          }
      }
code_tokens: private function _parseIni ( $ iniFile ) { $ aParsedIni = parse_ini_file ( $ iniFile , true , INI_SCANNER_RAW ) ; $ tmpArray = array ( ) ; foreach ( $ aParsedIni as $ key => $ value ) { if ( strpos ( $ key , ':' ) !== false ) { $ sections = explode ( ':' , $ key ) ; if ( count ( $ sections ) != 2 ) { throw new Exception ( 'Malformed section header!' ) ; } $ currentSection = trim ( $ sections [ 0 ] ) ; $ parentSection = trim ( $ sections [ 1 ] ) ; $ value = array_merge_recursive ( $ aParsedIni [ $ parentSection ] , $ aParsedIni [ $ key ] ) ; $ aParsedIni [ $ currentSection ] = $ value ; unset ( $ aParsedIni [ $ key ] ) ; $ key = $ currentSection ; } if ( is_array ( $ value ) ) { foreach ( $ value as $ vk => $ vv ) { $ newKey = $ key . "." . $ vk ; $ tmpArray [ $ newKey ] = $ vv ; if ( is_string ( $ vv ) && preg_match_all ( '/\${([a-zA-Z0-9\.]+)}/' , $ vv , $ match ) ) { if ( ! isset ( $ match [ 1 ] ) ) { continue ; } $ variableKey = $ match [ 1 ] ; foreach ( $ variableKey as & $ var ) { if ( strpos ( $ var , '.' ) === false ) { $ var = $ key . '.' . $ var ; } } $ this -> _varDeps [ $ newKey ] = $ variableKey ; } } } } if ( ! empty ( $ tmpArray ) ) { $ aParsedIni = $ tmpArray ; } foreach ( $ aParsedIni as $ key => $ value ) { //extract parsed array keys if ( array_key_exists ( $ key , $ this -> _varDeps ) ) { $ deps = & $ this -> _varDeps ; $ value = preg_replace_callback ( '/\${([a-zA-Z0-9\.]+)}/' , function ( $ match ) use ( $ key , $ aParsedIni , & $ deps ) { return $ aParsedIni [ array_shift ( $ deps [ $ key ] ) ] ; } , $ value ) ; $ aParsedIni [ $ key ] = $ value ; } $ this -> _tmpValue = $ value ; //set temporay value to current ini value $ aXKey = explode ( $ this -> _delimiter , $ key ) ; //get ini key segments //set object properties recursively based on parsed ini $ this -> _recursiveInit ( $ this -> _obj , $ aXKey ) ; } }
docstring: Parses ini file and extract its keys and prepare it for object creation
docstring_tokens: Parses ini file and extract its keys and prepare it for object creation