Index: branches/version-2_12-dev/data/class/util/SC_Utils.php
===================================================================
--- branches/version-2_12-dev/data/class/util/SC_Utils.php	(revision 21920)
+++ branches/version-2_12-dev/data/class/util/SC_Utils.php	(revision 21927)
@@ -336,4 +336,5 @@
     function sfMergeCheckBoxes($array, $max) {
         $ret = '';
+        $arrTmp = array();
         if (is_array($array)) {
             foreach ($array as $val) {
@@ -472,4 +473,5 @@
         }
 
+        $keyValues = array();
         for ($cnt = 0; $cnt < $max; $cnt++) {
             if ($keysize != '') {
@@ -481,10 +483,10 @@
 
             if ($connect != '') {
-                $arrRet[$key].= "$val".$connect;
+                $keyValues[$key].= "$val".$connect;
             } else {
-                $arrRet[$key][] = $val;
-            }
-        }
-        return $arrRet;
+                $keyValues[$key][] = $val;
+            }
+        }
+        return $keyValues;
     }
 
@@ -518,5 +520,5 @@
         $line = '';
         if (count($array) > 0) {
-            foreach ($array as $key => $val) {
+            foreach ($array as $val) {
                 $val = mb_convert_encoding($val, CHAR_CODE, CHAR_CODE);
                 $line .= '"' .$val. '",';
@@ -666,5 +668,13 @@
     }
 
-    /* ポイント付与 */
+    /**
+     * ポイント付与
+     * $product_id が使われていない。
+     * @param int $price
+     * @param float $point_rate
+     * @param int $rule
+     * @param int $product_id
+     * @return int 
+     */
     function sfPrePoint($price, $point_rate, $rule = POINT_RULE, $product_id = '') {
         $real_point = $point_rate / 100;
@@ -705,4 +715,11 @@
     }
 
+    /**
+     * $classcategory_id1 と $classcategory_id2 が使用されていない。
+     * @param int $product_id
+     * @param int $classcategory_id1
+     * @param int $classcategory_id2
+     * @return int 
+     */
     function sfGetProductClassId($product_id, $classcategory_id1, $classcategory_id2) {
         $where = 'product_id = ?';
@@ -924,7 +941,4 @@
         $end_month = $month;
 
-        // 開始月が終了月と同じか否か
-        $same_month = false;
-
         // 該当月の末日を求める。
         $end_last_day = date('d', mktime(0, 0, 0, $month + 1, 0, $year));
@@ -1116,5 +1130,5 @@
         $fileArray=glob($src.'*');
         if (is_array($fileArray)) {
-            foreach ($fileArray as $key => $data_) {
+            foreach ($fileArray as $data_) {
                 // CVS管理ファイルはコピーしない
                 if (strpos($data_, '/CVS/Entries') !== false) {
Index: branches/version-2_12-dev/data/class/util/GC_Utils.php
===================================================================
--- branches/version-2_12-dev/data/class/util/GC_Utils.php	(revision 21867)
+++ branches/version-2_12-dev/data/class/util/GC_Utils.php	(revision 21927)
@@ -273,4 +273,5 @@
     function gfMailHeaderAddr($str) {
         $addrs = explode(',', $str); //アドレスを配列に入れる
+        $mailaddrs = array();
         foreach ($addrs as $addr) {
             if (preg_match("/^(.+)<(.+)>$/", $addr, $matches)) {
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_Mobile.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Mobile.php	(revision 21867)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Mobile.php	(revision 21927)
@@ -96,5 +96,5 @@
     function lfMobileConvertInputValue(&$value) {
         if (is_array($value)) {
-            foreach ($value as $key => $val) {
+            foreach (array_keys($value) as $key) {
                 $this->lfMobileConvertInputValue($value[$key]);
             }
@@ -126,5 +126,5 @@
      */
     function lfMobileGetExtSessionId() {
-        if (!preg_match('|^' . ROOT_URLPATH . '(.*)$|', $_SERVER['SCRIPT_NAME'], $matches)) {
+        if (!preg_match('|^' . ROOT_URLPATH . '(.*)$|', $_SERVER['SCRIPT_NAME'], $matches = array())) {
             return null;
         }
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_FileManager.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_FileManager.php	(revision 21867)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_FileManager.php	(revision 21927)
@@ -42,6 +42,8 @@
 
         if (is_dir($dir)) {
-            if ($dh = opendir($dir)) {
+            $dh = opendir($dir);
+            if ($dh) {
                 $cnt = 0;
+                $arrDir = array();
                 // 行末の/を取り除く
                 while (($file = readdir($dh)) !== false) $arrDir[] = $file;
@@ -55,5 +57,4 @@
                         $path = $dir.'/'.$file;
                         // SELECT内の見た目を整えるため指定文字数で切る
-                        $file_name = SC_Utils_Ex::sfCutString($file, FILE_NAME_LEN);
                         $file_size = SC_Utils_Ex::sfCutString(SC_Helper_FileManager::sfGetDirSize($path), FILE_NAME_LEN);
                         $file_time = date('Y/m/d', filemtime($path));
@@ -172,5 +173,7 @@
 
         if (file_exists($dir)) {
-            if ($handle = opendir("$dir")) {
+            $handle = opendir($dir);
+            if ($handle) {
+                $arrDir = array();
                 while (false !== ($item = readdir($handle))) $arrDir[] = $item;
                 // アルファベットと数字でソート
@@ -336,4 +339,5 @@
         // ファイル一覧取得
         $arrFileHash = SC_Helper_FileManager_Ex::sfGetFileList($dir);
+        $arrFileList = array();
         foreach ($arrFileHash as $val) {
             $arrFileList[] = $val['file_name'];
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_PageLayout.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_PageLayout.php	(revision 21867)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_PageLayout.php	(revision 21927)
@@ -183,6 +183,4 @@
     function lfDelPageData($page_id, $device_type_id = DEVICE_TYPE_PC) {
         $objQuery =& SC_Query_Ex::getSingletonInstance();
-        $arrDelData = array();      // 抽出データ用
-
         // page_id が空でない場合にはdeleteを実行
         if ($page_id != '') {
@@ -325,5 +323,5 @@
      * @return void
      */
-    function setBlocPathTo($device_type_id = DEVICE_TYPE_PC, &$arrBlocs) {
+    function setBlocPathTo($device_type_id = DEVICE_TYPE_PC, &$arrBlocs = array()) {
         foreach (array_keys($arrBlocs) as $key) {
             $arrBloc =& $arrBlocs[$key];
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_Purchase.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Purchase.php	(revision 21867)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Purchase.php	(revision 21927)
@@ -122,4 +122,5 @@
         }
 
+        $arrParams = array();
         $arrParams['status'] = $orderStatus;
         if ($is_delete) {
@@ -271,4 +272,5 @@
         // 存在するカラムのみを対象とする
         $cols = $objQuery->listTableFields('dtb_order_temp');
+        $sqlval = array();
         foreach ($params as $key => $val) {
             if (in_array($key, $cols)) {
@@ -542,4 +544,5 @@
         $objQuery->setOrder('rank DESC');
         $payments = $objQuery->select('payment_id, payment_method, rule_max, upper_rule, note, payment_image, charge', 'dtb_payment', $where, $arrPaymentIds);
+        $arrPayment = array();
         foreach ($payments as $data) {
             // 下限と上限が設定されている
@@ -842,4 +845,5 @@
         $objProduct = new SC_Product_Ex();
         $i = 0;
+        $arrDetail = array();
         foreach ($cartItems as $item) {
             $p =& $item['productsClass'];
@@ -1068,5 +1072,4 @@
 
         if ($has_items) {
-            $objProduct = new SC_Product_Ex();
             foreach (array_keys($arrResults) as $shipping_id) {
                 $arrResults[$shipping_id]['shipment_item']
@@ -1136,5 +1139,5 @@
      * @return void
      */
-    function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddPoint = null, $newUsePoint = null, &$sqlval) {
+    function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddPoint = null, $newUsePoint = null, &$sqlval = array()) {
         $objQuery =& SC_Query_Ex::getSingletonInstance();
         $arrOrderOld = $objQuery->getRow('status, add_point, use_point, customer_id', 'dtb_order', 'order_id = ?', array($orderId));
@@ -1331,4 +1334,6 @@
      * 加える機会を与える.
      *
+     * $orderId が使われていない。
+     * 
      * @param integer $orderId 注文番号
      * @param SC_CartSession $objCartSession カート情報のインスタンス
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_CSV.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_CSV.php	(revision 21867)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_CSV.php	(revision 21927)
@@ -144,5 +144,5 @@
     function sfIsImportCSVFrame(&$arrCSVFrame) {
         $result = true;
-        foreach ($arrCSVFrame as $key => $val) {
+        foreach ($arrCSVFrame as $val) {
             if ($val['status'] != CSV_COLUMN_STATUS_FLG_ENABLE
                 && $val['rw_flg'] == CSV_COLUMN_RW_FLG_READ_WRITE
@@ -165,5 +165,5 @@
     function sfIsUpdateCSVFrame(&$arrCSVFrame) {
         $result = true;
-        foreach ($arrCSVFrame as $key => $val) {
+        foreach ($arrCSVFrame as $val) {
             if ($val['status'] != CSV_COLUMN_STATUS_FLG_ENABLE
                 && $val['rw_flg'] == CSV_COLUMN_RW_FLG_KEY_FIELD
@@ -337,6 +337,6 @@
 
         /* HTTPヘッダの出力 */
-        Header("Content-disposition: attachment; filename=${file_name}");
-        Header("Content-type: application/octet-stream; name=${file_name}");
+        Header("Content-disposition: attachment; filename={$file_name}");
+        Header("Content-type: application/octet-stream; name={$file_name}");
         Header('Cache-Control: ');
         Header('Pragma: ');
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_Plugin.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Plugin.php	(revision 21915)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Plugin.php	(revision 21927)
@@ -109,5 +109,5 @@
 
             krsort($this->arrRegistedPluginActions[$hook_point]);
-            foreach ($this->arrRegistedPluginActions[$hook_point] as $priority => $arrFuncs) {
+            foreach ($this->arrRegistedPluginActions[$hook_point] as $arrFuncs) {
 
                 foreach ($arrFuncs as $func) {
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_Mail.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Mail.php	(revision 21867)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Mail.php	(revision 21927)
@@ -141,5 +141,5 @@
             $arrItems = $objQuery->select('*', 'dtb_shipment_item', 'order_id = ? AND shipping_id = ?',
                                           array($order_id, $arrRet[$key]['shipping_id']));
-            foreach ($arrItems as $itemKey => $arrDetail) {
+            foreach ($arrItems as $arrDetail) {
                 foreach ($arrDetail as $detailKey => $detailVal) {
                     $arrRet[$key]['shipment_item'][$arrDetail['product_class_id']][$detailKey] = $detailVal;
@@ -266,4 +266,5 @@
     // メール配信履歴への登録
     function sfSaveMailHistory($order_id, $template_id, $subject, $body) {
+        $sqlval = array();
         $sqlval['subject'] = $subject;
         $sqlval['order_id'] = $order_id;
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_DB.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_DB.php	(revision 21898)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_DB.php	(revision 21927)
@@ -75,6 +75,4 @@
         // 正常に接続されている場合
         if (!$objQuery->isError()) {
-            list($db_type) = explode(':', $dsn);
-
             // カラムリストを取得
             $columns = $objQuery->listTableFields($table_name);
@@ -111,9 +109,14 @@
         $exists = $objQuery->exists($table_name, $where, $arrWhereVal);
 
-        // データを追加する
-        if (!$exists && $add) {
-            $objQuery->exec($sql);
-        }
-        return $ret;
+        // データが存在する場合 TRUE
+        if ($exists) {
+            return TRUE;
+        // $add が TRUE の場合はデータを追加する
+        } elseif ($add) {
+            return $objQuery->exec($sql);
+        // $add が FALSE で、データが存在しない場合 FALSE
+        } else {
+            return FALSE;
+        }
     }
 
@@ -129,7 +132,7 @@
      */
     function sfGetBasisData($force = false, $col = '') {
-        static $data;
-
-        if ($force || !isset($data)) {
+        static $data = array();
+
+        if ($force || empty($data)) {
             $objQuery =& SC_Query_Ex::getSingletonInstance();
 
@@ -177,5 +180,4 @@
         if (!$this->g_root_on) {
             $this->g_root_on = true;
-            $objQuery =& SC_Query_Ex::getSingletonInstance();
 
             if (!isset($_GET['product_id'])) $_GET['product_id'] = '';
@@ -292,5 +294,5 @@
             return;
         } else {
-            foreach ($arrTree as $key => $val) {
+            foreach ($arrTree as $val) {
                 if ($val['category_id'] == $parent) {
                     $result[] = array(
@@ -367,5 +369,5 @@
 
         // カテゴリ名称を取得する
-        foreach ($arrCatID as $key => $val) {
+        foreach ($arrCatID as $val) {
             $sql = 'SELECT category_name FROM dtb_category WHERE category_id = ?';
             $arrVal = array($val);
@@ -448,4 +450,5 @@
 
         $max = count($arrRet);
+        $arrList = array();
         for ($cnt = 0; $cnt < $max; $cnt++) {
             $id = $arrRet[$cnt]['category_id'];
@@ -486,4 +489,6 @@
         $max = count($arrRet);
 
+        $arrValue = array();
+        $arrOutput = array();
         for ($cnt = 0; $cnt < $max; $cnt++) {
             if ($parent_zero) {
@@ -523,5 +528,4 @@
         } else if (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_products','product_id', $product_id, $status)) {
             $objQuery =& SC_Query_Ex::getSingletonInstance();
-            $where = 'product_id = ?';
             $category_id = $objQuery->getCol('category_id', 'dtb_product_categories', 'product_id = ?', array($product_id));
         } else {
@@ -943,4 +947,5 @@
         $arrList = $objQuery->select($col, $table, $where, $arrVal);
         $count = count($arrList);
+        $arrRet = array();
         for ($cnt = 0; $cnt < $count; $cnt++) {
             $key = $arrList[$cnt][$keyname];
@@ -1278,5 +1283,4 @@
             } else if (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && $this->sfIsRecord('dtb_products','product_id', $product_id, $status)) {
                 $objQuery =& SC_Query_Ex::getSingletonInstance();
-                $where = 'product_id = ?';
                 $maker_id = $objQuery->getCol('maker_id', 'dtb_products', 'product_id = ?', array($product_id));
                 $this->g_maker_id = $maker_id;
@@ -1320,4 +1324,5 @@
 
         $max = count($arrRet);
+        $arrList = array();
         for ($cnt = 0; $cnt < $max; $cnt++) {
             $id = $arrRet[$cnt]['maker_id'];
@@ -1343,4 +1348,5 @@
     /**
      * 店舗基本情報に基づいて税金付与した金額を返す
+     * SC_Utils_Ex::sfCalcIncTax とどちらか統一したほうが良い
      *
      * @param integer $price 計算対象の金額
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_HandleError.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_HandleError.php	(revision 21867)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_HandleError.php	(revision 21927)
@@ -91,7 +91,4 @@
         $error_type_name = GC_Utils_Ex::getErrorTypeName($errno);
 
-        $now = date('Y/m/d H:i:s');
-        // 本来 realpath() で正規化したいところだが、NULL を返すケースがあるため避けている (#1618)
-        $log_file_path = DATA_REALDIR . 'logs/site.log';
         switch ($errno) {
             case E_USER_ERROR:
@@ -130,8 +127,5 @@
      */
     static function &_fatal_error_handler(&$buffer) {
-        if (preg_match('/<b>(Fatal error)<\/b>: +(.+) in <b>(.+)<\/b> on line <b>(\d+)<\/b><br \/>/i', $buffer, $matches)) {
-            $now = date('Y/m/d H:i:s');
-            // realpath() で正規化したいが、NULL を返すケースがあるため避けている (#1618)
-            $log_file_path = DATA_REALDIR . 'logs/site.log';
+        if (preg_match('/<b>(Fatal error)<\/b>: +(.+) in <b>(.+)<\/b> on line <b>(\d+)<\/b><br \/>/i', $buffer, $matches = array())) {
             $message = "$matches[1]: $matches[2] on [$matches[3]($matches[4])]";
             GC_Utils_Ex::gfPrintLog($message, ERROR_LOG_REALFILE, true);
@@ -181,6 +175,4 @@
         $errstr = "Fatal error($error_type_name): {$arrError[message]} on [{$arrError[file]}({$arrError[line]})]";
 
-        // 本来 realpath() で正規化したいところだが、NULL を返すケースがあるため避けている (#1618)
-        $log_file_path = DATA_REALDIR . 'logs/site.log';
         GC_Utils_Ex::gfPrintLog($errstr, ERROR_LOG_REALFILE, true);
 
