Skip to content

Commit

Permalink
Merge pull request #43 from mikoim/feature/reference
Browse files Browse the repository at this point in the history
書き換えを伴う foreach でリファレンスを使用するように変更
  • Loading branch information
logue committed May 1, 2016
2 parents b719359 + 5ed306e commit bbc4f82
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions wiki-common/lib/PukiWiki/File/FileUtility.php
Expand Up @@ -205,11 +205,11 @@ private static function getHeadings($dir = DATA_DIR, $force = false){
// ページの索引でソート
ksort($ret, SORT_NATURAL);

foreach ($ret as $initial=>$pages){
foreach ($ret as $initial => &$pages){
// ページ名の「読み」でソート
asort($ret[$initial], SORT_NATURAL);
asort($pages, SORT_NATURAL);
// 「読み」でソートしたやつを$headingに保存
$heading[$func][$initial] = array_keys($ret[$initial]);
$heading[$func][$initial] = array_keys($pages);
}
unset($ret);

Expand Down
6 changes: 3 additions & 3 deletions wiki-common/lib/PukiWiki/Listing.php
Expand Up @@ -92,11 +92,11 @@ private static function getHeadings($type='wiki', $force = false){
// ページの索引でソート
ksort($ret, SORT_NATURAL);

foreach ($ret as $initial=>$pages){
foreach ($ret as $initial => &$pages){
// ページ名の「読み」でソート
asort($ret[$initial], SORT_NATURAL);
asort($pages, SORT_NATURAL);
// 「読み」でソートしたやつを$headingに保存
$heading[$type][$initial] = array_keys($ret[$initial]);
$heading[$type][$initial] = array_keys($pages);
}
unset($ret);

Expand Down
4 changes: 2 additions & 2 deletions wiki-common/lib/PukiWiki/Mailer.php
Expand Up @@ -49,8 +49,8 @@ function notify($subject, $message, $summary = array(), $summary_position = FALS

if (! empty($summary)) {
$_separator = empty($message) ? '' : self::SUMMRY_SEPARATOR . "\n";
foreach($summary as $key => $value) {
$summary[$key] = $key . ': ' . $value . "\n";
foreach($summary as $key => &$value) {
$value = $key . ': ' . $value . "\n";
}
// Top or Bottom
if ($summary_position) {
Expand Down
4 changes: 2 additions & 2 deletions wiki-common/lib/PukiWiki/Renderer/Element/RootElement.php
Expand Up @@ -263,8 +263,8 @@ public function toString()
private function comment($matches)
{
$comments = explode("\n", $matches[0]);
foreach ($comments as $key=>$comment) {
$comments[$key] = array_shift($this->comments);
foreach ($comments as &$comment) {
$comment = array_shift($this->comments);
}
$comment = join("\n", $comments);
return '<span class="fa fa-comment" title="' . Utility::htmlsc($comment) . '"></span>';
Expand Down
4 changes: 2 additions & 2 deletions wiki-common/lib/PukiWiki/Search.php
Expand Up @@ -126,8 +126,8 @@ public static function do_search($word, $type = 'and', $non_format = FALSE, $bas

// 検索ワードをパース
$keys = self::get_search_words(preg_split('/\s+/', $word, -1, PREG_SPLIT_NO_EMPTY));
foreach ($keys as $key=>$value)
$keys[$key] = '/' . $value . '/S';
foreach ($keys as &$value)
$value = '/' . $value . '/S';

// AND:TRUE OR:FALSE
$b_type = ($type == 'and');
Expand Down
4 changes: 2 additions & 2 deletions wiki-common/lib/PukiWiki/Spam/Spam.php
Expand Up @@ -590,11 +590,11 @@ public static function summarize_detail_badhost($progress = array())
// Shrink per list
// From: 'A-1' => array('ie.to')
// To: 'A-1' => 'ie.to'
foreach($blocked as $list => $lvalue) {
foreach($blocked as &$lvalue) {
if (is_array($lvalue) &&
count($lvalue) == 1 &&
is_numeric(key($lvalue))) {
$blocked[$list] = current($lvalue);
$lvalue = current($lvalue);
}
}

Expand Down
6 changes: 3 additions & 3 deletions wiki-common/lib/PukiWiki/Spam/SpamUtility.php
Expand Up @@ -298,12 +298,12 @@ function array_unique_recursive($array = array())
if (! is_array($array)) return $array;

$tmp = array();
foreach($array as $key => $value){
foreach($array as &$value){
if (is_array($value)) {
$array[$key] = self::array_unique_recursive($value);
$value = self::array_unique_recursive($value);
} else {
if (isset($tmp[$value])) {
unset($array[$key]);
unset($value);
} else {
$tmp[$value] = TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions wiki-common/plugin/htdigest.inc.php
Expand Up @@ -325,15 +325,15 @@ function htdigest_save($username,$p_realm,$hash,$role)
}

$sw = FALSE;
foreach($lines as $no=>$line) {
foreach($lines as &$line) {
$field = explode(':', trim($line));
if ($field[0] == $username && $field[1] == $p_realm) {
if ($field[2] == $decrypted_hash) {
return $_htdigest_msg['msg_not_update'];
}

$sw = TRUE;
$lines[$no] = $field[0].':'.$field[1].':'.$decrypted_hash."\n";
$line = $field[0].':'.$field[1].':'.$decrypted_hash."\n";
break;
}
}
Expand Down
18 changes: 9 additions & 9 deletions wiki-common/plugin/htmlinsert.inc.php
Expand Up @@ -73,12 +73,12 @@ function parse_args_action($vars, $default_options)
$options = $default_options;
unset($vars['cmd']); // pukiwiki reserved key
unset($vars['page']); //
foreach ($vars as $key => $val) {
foreach ($vars as $key => &$val) {
if (isset($options[$key])) {
$options[$key] = $val;
unset($vars[$key]);
unset($val);
} else {
$vars[$key] = htmlsc($val);
$val = htmlsc($val);
}
}
return array($page, $vars, $options);
Expand Down Expand Up @@ -227,26 +227,26 @@ function replace_variables($body, $variables)
return;
}
}
foreach ($values as $idx => $value) {
foreach ($values as $idx => &$value) {
switch ($encs[$idx]) {
case 'enc':
$values[$idx] = rawurlencode($value);
$value = rawurlencode($value);
break;
case 'utf8':
$value = mb_convert_encoding($value, 'UTF-8', SOURCE_ENCODING);
$values[$idx] = rawurlencode($value);
$value = rawurlencode($value);
break;
case 'euc':
$value = mb_convert_encoding($value, 'EUC', SOURCE_ENCODING);
$values[$idx] = rawurlencode($value);
$value = rawurlencode($value);
break;
case 'sjis':
$value = mb_convert_encoding($value, 'SJIS', SOURCE_ENCODING);
$values[$idx] = rawurlencode($value);
$value = rawurlencode($value);
break;
case 'jis':
$value = mb_convert_encoding($value, 'JIS', SOURCE_ENCODING);
$values[$idx] = rawurlencode($value);
$value = rawurlencode($value);
break;
case '':
case 'raw':
Expand Down
4 changes: 2 additions & 2 deletions wiki-common/plugin/vote.inc.php
Expand Up @@ -207,11 +207,11 @@ function get_update_inline(&$lines, $vote_id, $choice_id)
list($votes, $options) = $this->parse_args_inline($args, $this->default_options);
if ($options['readonly']) return array(false, false, false, false);

foreach ($votes as $i => $vote) {
foreach ($votes as $i => &$vote) {
list($choice, $count) = $vote;
if ($i == $choice_id) {
++$count;
$votes[$i] = array($choice, $count);
$vote = array($choice, $count);
}
}
$new_args = $this->restore_args_inline($votes, $options, $this->default_options);
Expand Down

0 comments on commit bbc4f82

Please sign in to comment.