Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix #14

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:
tests:
name: tests
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
Expand Down
37 changes: 37 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

if (php_sapi_name() !== 'cli') {
throw new \LogicException();
}

$rules = [
'@Symfony' => true,
'@Symfony:risky' => true,
// '@PHP83Migration' => true,

// @Symfony のうち、以下のルールを無効化
'phpdoc_align' => false, // phpdoc の内容が削除されてしまう場合がある
'phpdoc_summary' => false, // 日本語なので不要
'phpdoc_annotation_without_dot' => false, // 日本語なので不要
'no_superfluous_phpdoc_tags' => false, // 副作用があるため
'increment_style' => false, // 強制しなくて良い
'yoda_style' => false, // 強制しなくて良い

// @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, // 副作用があるため
];

$finder = \PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
->name('*.php')
;
$config = new \PhpCsFixer\Config();
return $config
->setRules($rules)
->setFinder($finder)
;
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
Application::appendConfigPath(__DIR__.'/config');
}

\class_exists('\Eccube2\Tests\Fixture\Generator');
class_exists('\Eccube2\Tests\Fixture\Generator');
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "nanasess/eccube2-fixture-generator",
"type": "library",
"require-dev": {
"symfony/console": "^2.8 || ^3.4 || ^4.4 || ^5.4 || ^6.4"
"symfony/console": "^2.8 || ^3.4 || ^4.4 || ^5.4 || ^6.4",
"friendsofphp/php-cs-fixer": "^3.65"
},
"license": "LGPL-3.0",
"autoload": {
Expand Down
12 changes: 6 additions & 6 deletions src/Command/GenerateDummyDataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class GenerateDummyDataCommand extends Command
/** @var string */
protected static $defaultName = 'eccube:fixtures:generate';

public function __construct(string $name = null)
public function __construct(?string $name = null)
{
parent::__construct($name);
}
Expand Down Expand Up @@ -86,10 +86,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
// 5件以上のカテゴリを生成する
do {
$category_ids = array_merge($category_ids, $objGenerator->createCategories());
} while (count($category_ids) < 5);
} while (\count($category_ids) < 5);

foreach ($product_ids as $product_id) {
$num = $faker->numberBetween(2, count($category_ids) - 1);
$num = $faker->numberBetween(2, \count($category_ids) - 1);
$objGenerator->relateProductCategories($product_id, array_rand(array_flip($category_ids), $num >= 2 ? $num : 2));
}
$objDb = new \SC_Helper_DB_Ex();
Expand All @@ -105,14 +105,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($num < $numberOfOrder) {
$io->write('Generating Orders');
foreach ($customer_ids as $customer_id) {
$target_product_class_ids = array_rand(array_flip($product_class_ids), $faker->numberBetween(2, count($product_class_ids) - 1));
$target_product_class_ids = array_rand(array_flip($product_class_ids), $faker->numberBetween(2, \count($product_class_ids) - 1));
$charge = $faker->randomNumber(4);
$discount = $faker->numberBetween(0, $charge);
$order_count_per_customer = $objQuery->count('dtb_order', 'customer_id = ?', [$customer_id]);
for ($i = $order_count_per_customer; $i < $numberOfOrder / count($customer_ids); $i++) {
for ($i = $order_count_per_customer; $i < $numberOfOrder / \count($customer_ids); $i++) {
// キャンセルと決済処理中は除外して注文を生成する
$target_statuses = [ORDER_NEW, ORDER_PAY_WAIT, ORDER_PRE_END, ORDER_BACK_ORDER, ORDER_DELIV];
$order_status_id = $target_statuses[$faker->numberBetween(0, count($target_statuses) - 1)];
$order_status_id = $target_statuses[$faker->numberBetween(0, \count($target_statuses) - 1)];
$objGenerator->createOrder($customer_id, $target_product_class_ids, 1, $charge, $discount, $order_status_id);
$io->write('.');
}
Expand Down
Loading
Loading