Skip to content

Commit

Permalink
PHPStan再実行後の修正
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisL-meier committed Nov 15, 2023
1 parent 954887b commit 164902d
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Eccube/Command/LoadDataFixturesEccubeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getEntityManager(null);
$em = $this->getEntityManager($this->getDoctrine()->getDefaultManagerName());

// for full locale code cases
$locale = env('ECCUBE_LOCALE', 'ja_JP');
Expand Down
11 changes: 10 additions & 1 deletion src/Eccube/Command/UpdateSchemaDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@

use Doctrine\Bundle\DoctrineBundle\Command\Proxy\DoctrineCommandHelper;
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand as BaseUpdateSchemaDoctrineCommand;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\ORM\Tools\SchemaTool;
use Eccube\Kernel;
use Eccube\Repository\PluginRepository;
use Eccube\Service\PluginService;
use Eccube\Service\SchemaService;
use Eccube\Util\StringUtil;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -77,7 +81,12 @@ protected function configure(): void
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
/** @var Application $app */
$app = $this->getApplication();
$eccubeKernel = $app->getKernel();
$em = $eccubeKernel->getContainer()->get('doctrine')->getManager($input->getOption('em'));
assert($em instanceof EntityManagerInterface);
$this->getApplication()->getHelperSet()->set(new EntityManagerHelper($em), 'em');
$noProxy = true === $input->getOption('no-proxy');
$dumpSql = true === $input->getOption('dump-sql');
$force = true === $input->getOption('force');
Expand Down
8 changes: 7 additions & 1 deletion src/Eccube/Controller/Admin/Setting/System/LogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class LogController extends AbstractController
* @Template("@admin/Setting/System/log.twig")
*
* @return array<string, mixed> | StreamedResponse
* @throws \Exception
*/
public function index(Request $request)
{
Expand Down Expand Up @@ -69,9 +70,14 @@ public function index(Request $request)
$logFile = $logDir.'/'.$formData['files'];
/** @var \Symfony\Component\Form\Form $form */
if ($form->getClickedButton() && $form->getClickedButton()->getName() === 'download' && $form->isValid()) {
$fileSizeLogFile = filesize($logFile);
if($fileSizeLogFile === false){
throw new \Exception("ファイルサイズの取得に失敗しました。");
}

$bufferSize = 1024 * 50;
$response = new StreamedResponse();
$response->headers->set('Content-Length', (string)filesize($logFile));
$response->headers->set('Content-Length', (string)$fileSizeLogFile);
$response->headers->set('Content-Disposition', 'attachment; filename='.basename($logFile));
$response->headers->set('Content-Type', 'application/octet-stream');
$response->setCallback(function () use ($logFile, $bufferSize) {
Expand Down
4 changes: 2 additions & 2 deletions src/Eccube/Doctrine/Query/JoinClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public function build(QueryBuilder $builder)
} else {
$builder->innerJoin($this->join, $this->alias, $this->conditionType, $this->condition, $this->indexBy);
}
$this->whereCustomizer->customize($builder, null, '');
$this->orderByCustomizer->customize($builder, null, '');
$this->whereCustomizer->customize($builder, [], '');
$this->orderByCustomizer->customize($builder, [], '');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Doctrine/Query/OrderByCustomizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class OrderByCustomizer implements QueryCustomizer
{
/**
* @param QueryBuilder $builder
* @param array|null $params
* @param array $params
* @param string $queryKey
*/
final public function customize(QueryBuilder $builder, $params, $queryKey)
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Doctrine/Query/WhereCustomizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class WhereCustomizer implements QueryCustomizer
{
/**
* @param QueryBuilder $builder
* @param array|null $params
* @param array $params
* @param string $queryKey
*/
final public function customize(QueryBuilder $builder, $params, $queryKey)
Expand Down
5 changes: 4 additions & 1 deletion src/Eccube/Entity/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,10 @@ public function getTags()
}

usort($tags, function (Tag $tag1, Tag $tag2) {
return (int)($tag1->getSortNo() < $tag2->getSortNo());
if($tag1->getSortNo() === $tag2->getSortNo()) {
return 0;
}
return ($tag1->getSortNo() < $tag2->getSortNo()) ? -1 : 1;
});

return $tags;
Expand Down
8 changes: 4 additions & 4 deletions src/Eccube/Form/Type/Admin/SecurityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$data = $form->getData();

// フロント画面のアクセス許可リストのvalidate
$ips = preg_split("/\R/", $data['front_allow_hosts'], null, PREG_SPLIT_NO_EMPTY);
$ips = preg_split("/\R/", $data['front_allow_hosts'], -1, PREG_SPLIT_NO_EMPTY);

foreach ($ips as $ip) {
// 適切なIPとビットマスクになっているか
Expand All @@ -160,7 +160,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

// フロント画面のアクセス拒否リストのvalidate
$ips = preg_split("/\R/", $data['front_deny_hosts'], null, PREG_SPLIT_NO_EMPTY);
$ips = preg_split("/\R/", $data['front_deny_hosts'], -1, PREG_SPLIT_NO_EMPTY);

foreach ($ips as $ip) {
// 適切なIPとビットマスクになっているか
Expand All @@ -176,7 +176,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

// 管理画面のアクセス許可リストのvalidate
$ips = preg_split("/\R/", $data['admin_allow_hosts'], null, PREG_SPLIT_NO_EMPTY);
$ips = preg_split("/\R/", $data['admin_allow_hosts'], -1, PREG_SPLIT_NO_EMPTY);

foreach ($ips as $ip) {
// 適切なIPとビットマスクになっているか
Expand All @@ -192,7 +192,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

// 管理画面のアクセス拒否リストのvalidate
$ips = preg_split("/\R/", $data['admin_deny_hosts'], null, PREG_SPLIT_NO_EMPTY);
$ips = preg_split("/\R/", $data['admin_deny_hosts'], -1, PREG_SPLIT_NO_EMPTY);

foreach ($ips as $ip) {
// 適切なIPとビットマスクになっているか
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Form/Type/Install/Step3Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$form = $event->getForm();
$data = $form->getData();

$ips = preg_split("/\R/", $data['admin_allow_hosts'], null, PREG_SPLIT_NO_EMPTY);
$ips = preg_split("/\R/", $data['admin_allow_hosts'], -1, PREG_SPLIT_NO_EMPTY);

foreach ($ips as $ip) {
$errors = $this->validator->validate($ip, [
Expand Down

0 comments on commit 164902d

Please sign in to comment.