Skip to content

Commit

Permalink
Merge pull request EC-CUBE#1086 from nanasess/apply-php-cs-fixer
Browse files Browse the repository at this point in the history
php-cs-fixer を適用
  • Loading branch information
nanasess authored Dec 20, 2024
2 parents 0ac0b1d + 1daa15b commit 6235b10
Show file tree
Hide file tree
Showing 146 changed files with 2,122 additions and 2,054 deletions.
5 changes: 5 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
'no_superfluous_phpdoc_tags' => false, // 副作用があるため
'increment_style' => false, // 強制しなくて良い
'yoda_style' => false, // 強制しなくて良い
'blank_line_after_opening_tag' => false, // 強制しなくて良い
'fully_qualified_strict_types' => false, // 強制しなくて良い
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays']], // elements で arrays 以外を指定するとPHP7.4でエラーになる

// @Symfony:risky のうち、以下のルールを無効化
'psr_autoloading' => false, // PSR-4 に準拠していないため
'is_null' => false, // 副作用があるため
'native_constant_invocation' => false, // namespace を使用していないため不要
'string_length_to_empty' => false, // 副作用があるため
'ternary_to_elvis_operator' => false, // 副作用があるため
'get_class_to_class_keyword' => false, // 副作用があるため
];

$finder = \PhpCsFixer\Finder::create()
Expand All @@ -31,6 +35,7 @@
->in(__DIR__.'/data/module')
->in(__DIR__.'/data/smarty_extends')
->in(__DIR__.'/tests')
->exclude('SOAP')
->name('*.php')
;
$config = new \PhpCsFixer\Config();
Expand Down
1 change: 1 addition & 0 deletions data/class/SC_CartSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ public function getQuantity($cart_no, $product_type_id)
* @param int $quantity 設定する数量
* @param int $cart_no カート番号
* @param int $product_type_id 商品種別ID
*
* @retrun void
*/
public function setQuantity($quantity, $cart_no, $product_type_id)
Expand Down
4 changes: 2 additions & 2 deletions data/class/SC_CheckError.php
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ public function IP_CHECK($value)
// 改行コードが含まれている場合には配列に変換
$params = str_replace("\r", '', $this->arrParam[$keyname]);
if (!empty($params)) {
if (strpos($params, "\n") === false) {
if (!str_contains($params, "\n")) {
$params .= "\n";
}
$params = explode("\n", $params);
Expand Down Expand Up @@ -1224,7 +1224,7 @@ public function FILE_SIZE_CHECK($value)
if ($_FILES[$keyname]['size'] > $max_file_size * 1024) {
$byte = 'KB';
if ($max_file_size >= 1000) {
$max_file_size = $max_file_size / 1000;
$max_file_size /= 1000;
$byte = 'MB';
}
$this->arrErr[$keyname] = sprintf(
Expand Down
4 changes: 2 additions & 2 deletions data/class/SC_ClassAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_R
} elseif (($arrClassNamePart[0] === 'SC' || $arrClassNamePart[0] === 'LC') && $is_ex === true && $count >= 4) {
$arrClassNamePartTemp = $arrClassNamePart;
// FIXME クラスファイルのディレクトリ命名が変。変な現状に合わせて強引な処理をしてる。
$arrClassNamePartTemp[1] = $arrClassNamePartTemp[1].'_extends';
$arrClassNamePartTemp[1] .= '_extends';
if ($count <= 5 && $arrClassNamePart[2] === 'Admin' && !in_array($arrClassNamePart[3], ['Home', 'Index', 'Logout'])) {
$classpath .= strtolower(implode('/', array_slice($arrClassNamePartTemp, 1, -1))).'/';
} else {
Expand Down Expand Up @@ -136,7 +136,7 @@ public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_R

if ($is_ex) {
// *_Ex ファイルが存在しない場合は、元クラスのエイリアスとする
if (!file_exists($classpath) && strpos($class, '_Ex') !== false) {
if (!file_exists($classpath) && str_contains($class, '_Ex')) {
class_alias(preg_replace('/_Ex$/', '', $class), $class);
}
}
Expand Down
4 changes: 2 additions & 2 deletions data/class/SC_Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ public function doLogin($login_email, $login_pass)
{
switch (SC_Display_Ex::detectDevice()) {
case DEVICE_TYPE_MOBILE:
if (!$this->getCustomerDataFromMobilePhoneIdPass($login_pass) &&
!$this->getCustomerDataFromEmailPass($login_pass, $login_email, true)
if (!$this->getCustomerDataFromMobilePhoneIdPass($login_pass)
&& !$this->getCustomerDataFromEmailPass($login_pass, $login_email, true)
) {
return false;
} else {
Expand Down
8 changes: 4 additions & 4 deletions data/class/SC_CustomerList.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ public function __construct($array, $mode = '')
if (!isset($this->arrSql['search_end_day'])) {
$this->arrSql['search_end_day'] = '';
}
if ((strlen($this->arrSql['search_start_year']) > 0 && strlen($this->arrSql['search_start_month']) > 0 && strlen($this->arrSql['search_start_day']) > 0) ||
(strlen($this->arrSql['search_end_year']) > 0 && strlen($this->arrSql['search_end_month']) > 0 && strlen($this->arrSql['search_end_day']) > 0)) {
if ((strlen($this->arrSql['search_start_year']) > 0 && strlen($this->arrSql['search_start_month']) > 0 && strlen($this->arrSql['search_start_day']) > 0)
|| (strlen($this->arrSql['search_end_year']) > 0 && strlen($this->arrSql['search_end_month']) > 0 && strlen($this->arrSql['search_end_day']) > 0)) {
$arrRegistTime = $this->selectTermRange($this->arrSql['search_start_year'], $this->arrSql['search_start_month'], $this->arrSql['search_start_day'],
$this->arrSql['search_end_year'], $this->arrSql['search_end_month'], $this->arrSql['search_end_day'], $regdate_col);
foreach ($arrRegistTime as $data) {
Expand Down Expand Up @@ -348,8 +348,8 @@ public function __construct($array, $mode = '')
$this->arrSql['search_buy_end_day'] = '';
}

if ((strlen($this->arrSql['search_buy_start_year']) > 0 && strlen($this->arrSql['search_buy_start_month']) > 0 && strlen($this->arrSql['search_buy_start_day']) > 0) ||
(strlen($this->arrSql['search_buy_end_year']) > 0 && strlen($this->arrSql['search_buy_end_month']) > 0 && strlen($this->arrSql['search_buy_end_day']) > 0)) {
if ((strlen($this->arrSql['search_buy_start_year']) > 0 && strlen($this->arrSql['search_buy_start_month']) > 0 && strlen($this->arrSql['search_buy_start_day']) > 0)
|| (strlen($this->arrSql['search_buy_end_year']) > 0 && strlen($this->arrSql['search_buy_end_month']) > 0 && strlen($this->arrSql['search_buy_end_day']) > 0)) {
$arrRegistTime = $this->selectTermRange($this->arrSql['search_buy_start_year'], $this->arrSql['search_buy_start_month'], $this->arrSql['search_buy_start_day'],
$this->arrSql['search_buy_end_year'], $this->arrSql['search_buy_end_month'], $this->arrSql['search_buy_end_day'], 'last_buy_date');
foreach ($arrRegistTime as $data) {
Expand Down
4 changes: 2 additions & 2 deletions data/class/SC_Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class SC_Date
public $day;
public $end_year;

public static $arrHoliday = null;
public static $arrRegularHoliday = null;
public static $arrHoliday;
public static $arrRegularHoliday;

// コンストラクタ
public function __construct($start_year = '', $end_year = '')
Expand Down
8 changes: 4 additions & 4 deletions data/class/SC_Fpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ private function setOrderData()
$this->lfText(27, $y, $line, 8);
$cut = strlen($line);
$text = substr($text, $cut, strlen($text) - $cut);
$y = $y + 3;
$y += 3;
}
if ($text != '') {
$this->lfText(27, $y, $text, 8);
$y = $y + 3;
$y += 3;
}

$text = $this->arrDisp['order_addr02']; // 購入者住所2
Expand All @@ -206,11 +206,11 @@ private function setOrderData()
$this->lfText(27, $y, $line, 8);
$cut = strlen($line);
$text = substr($text, $cut, strlen($text) - $cut);
$y = $y + 3;
$y += 3;
}
if ($text != '') {
$this->lfText(27, $y, $text, 8);
$y = $y + 3;
$y += 3;
}

$text = $this->arrDisp['order_name01'].' '.$this->arrDisp['order_name02'].' 様';
Expand Down
4 changes: 2 additions & 2 deletions data/class/SC_Initial.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ public function defineDirectoryIndex()
$useFilenameDirIndex = USE_FILENAME_DIR_INDEX;
} else {
if (isset($_SERVER['SERVER_SOFTWARE'])) {
if (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false
|| strpos($_SERVER['SERVER_SOFTWARE'], 'Symfony') !== false) {
if (str_contains($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS')
|| str_contains($_SERVER['SERVER_SOFTWARE'], 'Symfony')) {
$useFilenameDirIndex = true;
}
}
Expand Down
1 change: 1 addition & 0 deletions data/class/SC_Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ public static function setPriceTaxTo(&$arrProducts)
$arrProduct['price02_min_tax_format'] = &$arrProduct['price02_min_inctax_format'];
$arrProduct['price02_max_tax_format'] = &$arrProduct['price02_max_inctax_format'];
}

// @deprecated 2.12.4
// 旧バージョン互換用
// 現在は参照渡しで戻せる
Expand Down
5 changes: 4 additions & 1 deletion data/class/SC_Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public static function actionExit()
* @param bool|null $useSsl true:HTTPSを強制, false:HTTPを強制, null:継承
*
* @return void
*
* @static
*/
public static function sendRedirect($location, $arrQueryString = [], $inheritQueryString = false, $useSsl = null)
Expand Down Expand Up @@ -259,6 +260,7 @@ public static function sendRedirect($location, $arrQueryString = [], $inheritQue
* @param string $location /html/ からのパス。先頭に / を含むかは任意。「../」の解釈は行なわない。
*
* @return void
*
* @static
*/
public static function sendRedirectFromUrlPath($location, $arrQueryString = [], $inheritQueryString = false, $useSsl = null)
Expand Down Expand Up @@ -311,12 +313,13 @@ public function setStatusCode($statusCode = null)
* @see http://ja.wikipedia.org/wiki/HTTP%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82%B9%E3%82%B3%E3%83%BC%E3%83%89 (邦訳)
*
* @license http://www.gnu.org/licenses/fdl.html GFDL (邦訳)
*
* @static
*/
public static function sendHttpStatus($statusCode)
{
$protocol = $_SERVER['SERVER_PROTOCOL'];
$httpVersion = (strpos($protocol, '1.1') !== false) ? '1.1' : '1.0';
$httpVersion = (str_contains($protocol, '1.1')) ? '1.1' : '1.0';
$messages = [
// Informational 1xx // 【情報】
100 => 'Continue', // 継続
Expand Down
2 changes: 1 addition & 1 deletion data/class/SC_SelectSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function selectTermRange($from_year, $from_month, $from_day, $to_year, $t
// @see http://svn.ec-cube.net/open_trac/ticket/328
// FIXME とりあえずintvalで対策...
$date2 = mktime(0, 0, 0, (int) $to_month, (int) $to_day, (int) $to_year);
$date2 = $date2 + 86400;
$date2 += 86400;
// SQL文のdate関数に与えるフォーマットは、yyyy/mm/ddで指定する。
$date2 = date('Y/m/d', $date2);

Expand Down
8 changes: 4 additions & 4 deletions data/class/SC_SendMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ public function setHost($host)
trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING);
$this->host = $host;
$arrHost = [
'host' => $this->host,
'port' => $this->port,
'host' => $this->host,
'port' => $this->port,
];
// PEAR::Mailを使ってメール送信オブジェクト作成
$this->objMail = &Mail::factory('smtp', $arrHost);
Expand All @@ -184,8 +184,8 @@ public function setPort($port)
trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING);
$this->port = $port;
$arrHost = [
'host' => $this->host,
'port' => $this->port,
'host' => $this->host,
'port' => $this->port,
];
// PEAR::Mailを使ってメール送信オブジェクト作成
$this->objMail = &Mail::factory('smtp', $arrHost);
Expand Down
1 change: 1 addition & 0 deletions data/class/SC_SmartphoneUserAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class SC_SmartphoneUserAgent
public static function isSmartphone()
{
$detect = new MobileDetect();

// SPでかつPC表示OFFの場合
// TabletはPC扱い
return ($detect->isMobile() && !$detect->isTablet()) && !SC_SmartphoneUserAgent_Ex::getSmartphonePcFlag();
Expand Down
22 changes: 12 additions & 10 deletions data/class/api/SC_Api_Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,12 @@ public static function doApiAction($arrPost)

if (count($arrErr) == 0) {
// 実行成功
$arrResponseValidSection = ['Request' => [
'IsValid' => 'True',
$operation_name.'Request' => $arrOperationRequestValid,
],
];
$arrResponseValidSection = [
'Request' => [
'IsValid' => 'True',
$operation_name.'Request' => $arrOperationRequestValid,
],
];
$response_outer = $operation_name.'Response';
SC_Api_Utils_Ex::printApiLog('Operation SUCCESS', $start_time, $response_outer);
} else {
Expand All @@ -380,11 +381,12 @@ public static function doApiAction($arrPost)
foreach ($arrErr as $error_code => $error_msg) {
$arrResponseErrorSection[] = ['Code' => $error_code, 'Message' => $error_msg];
}
$arrResponseValidSection = ['Request' => [
'IsValid' => 'False',
'Errors' => ['Error' => $arrResponseErrorSection],
],
];
$arrResponseValidSection = [
'Request' => [
'IsValid' => 'False',
'Errors' => ['Error' => $arrResponseErrorSection],
],
];
if (is_object($objApiOperation)) {
$response_outer = $operation_name.'Response';
} else {
Expand Down
3 changes: 2 additions & 1 deletion data/class/api/SC_Api_Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public static function getApiConfig($operation_name)
*
* @param string $msg 出力文字列
* @param text $operation_name
@ @rturn void
*
* @return void
*/
public static function printApiLog($msg, $start_time = '', $operation_name = '')
{
Expand Down
8 changes: 4 additions & 4 deletions data/class/api/operations/AddrFromZip.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public function doAction($arrParam)
$arrAddrList = SC_Utils_Ex::sfGetAddress($zipcode);
if (!SC_Utils_Ex::isBlank($arrAddrList)) {
$this->setResponse('Address', [
'State' => $arrAddrList[0]['state'],
'City' => $arrAddrList[0]['city'],
'Town' => $arrAddrList[0]['town'],
]
'State' => $arrAddrList[0]['state'],
'City' => $arrAddrList[0]['city'],
'Town' => $arrAddrList[0]['town'],
]
);

return true;
Expand Down
2 changes: 1 addition & 1 deletion data/class/api/operations/BrowseNodeLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function doAction($arrParam)
'Name' => $category['category_name'],
'PageURL' => HTTP_URL.'products/list.php?category_id='.$category['category_id'],
'has_children' => $category['has_children'],
];
];
}
}
$this->setResponse('BrowseNode', $arrData);
Expand Down
2 changes: 1 addition & 1 deletion data/class/api/operations/ItemSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function doAction($arrParam)
'product_id' => $val['product_id'],
'DetailPageURL' => HTTP_URL.'products/detail.php?product_id='.$val['product_id'],
'ItemAttributes' => $val,
];
];
}
$this->setResponse('Item', $arrData);

Expand Down
14 changes: 7 additions & 7 deletions data/class/db/SC_DB_DBFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public function getDSN($dsn = '')
if (empty($dsn)) {
if (defined('DEFAULT_DSN')) {
$dsn = ['phptype' => DB_TYPE,
'username' => DB_USER,
'password' => DB_PASSWORD,
'protocol' => 'tcp',
'hostspec' => DB_SERVER,
'port' => DB_PORT,
'database' => DB_NAME,
];
'username' => DB_USER,
'password' => DB_PASSWORD,
'protocol' => 'tcp',
'hostspec' => DB_SERVER,
'port' => DB_PORT,
'database' => DB_NAME,
];
} else {
return '';
}
Expand Down
2 changes: 1 addition & 1 deletion data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public function sfChangeTrunc($sql)
*/
public function sfChangeArrayToString($sql)
{
if (strpos(strtoupper($sql), 'ARRAY_TO_STRING') !== false) {
if (str_contains(strtoupper($sql), 'ARRAY_TO_STRING')) {
preg_match_all('/ARRAY_TO_STRING.*?\(.*?ARRAY\(.*?SELECT (.+?) FROM (.+?) WHERE (.+?)\).*?\,.*?\'(.+?)\'.*?\)/is', $sql, $match, PREG_SET_ORDER);

foreach ($match as $item) {
Expand Down
2 changes: 1 addition & 1 deletion data/class/graph/SC_Graph_Pie.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function drawGraph()
list($ax, $ay) = $this->lfGetArcPos($x, $y, $w, $h, $end);
// ラインのずれを補正する
if ($end > 180) {
$ax = $ax + 1;
++$ax;
}
imageline($this->image, $ax, $ay, $ax, $ay + $z, $this->flame_color);
}
Expand Down
2 changes: 1 addition & 1 deletion data/class/helper/SC_Helper_Bloc.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
class SC_Helper_Bloc
{
private $device_type_id = null;
private $device_type_id;

public function __construct($devide_type_id = DEVICE_TYPE_PC)
{
Expand Down
Loading

0 comments on commit 6235b10

Please sign in to comment.