EC-CUBE / EC-CUBE/ec-cube3

min() 関数のワーニングが大量に発生する

Open
#80 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
PHP
Stars
13
Forks
26
PR merge metrics
No merged PRs in 30d

Description

@mattintosh4 commented on [Wed Dec 18 2019](https://github.com/EC-CUBE/ec-cube/issues/4418)

## 概要(Overview)
下記のワーニングが大量に出力されてしまいます。
```
PHP Warning: min(): Array must contain at least one element in /var/www/html/Eccube/Entity/Product.php on line 298
```

`getPrice01Min()` や `getPrice01Max()` では配列が空かどうかのチェックをしているようですが、他の関数では判定を行っておらず、`min()` がワーニングを返します。

**判定をしている関数**
https://github.com/EC-CUBE/ec-cube/blob/d6dab8fcc97013f1a79689e198e28d91ae499446/src/Eccube/Entity/Product.php#L240
```php
public function getPrice01Min()
{
$this->_calc();
if (count($this->price01) == 0) {
return null;
}
return min($this->price01);
}
```

**判定をしていない関数**
https://github.com/EC-CUBE/ec-cube/blob/d6dab8fcc97013f1a79689e198e28d91ae499446/src/Eccube/Entity/Product.php#L296
```php
public function getPrice01IncTaxMin()
{
$this->_calc();
return min($this->price01IncTaxs);
}
```

敢えてこのようにしているのか、想定されていない使い方なので対応していないのかがわかりません。

## 期待する内容(Expect) or 要望 (Requirement)
- ワーニングの出力を抑えたいため `getPrice01IncTaxMin()` 等の関数も空の配列であれば `min()`、`max()` をスキップさせたいが影響があるかどうか知りたい。
- 現状では `min()` でワーニングが発生しているので `false` が返っていると思われるが `false`、`null` のどちらで返すのが適切か知りたい。

### 環境 (environment)
+ EC-CUBE: 3.1 系
+ PHP: 7.0.8

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.