mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Raise version min PHP 7.3.
This commit is contained in:
@ -14,38 +14,34 @@ use yii\helpers\VarDumper;
|
||||
*/
|
||||
class IsOneOfAssert extends \PHPUnit\Framework\Constraint\Constraint
|
||||
{
|
||||
private $allowedValues;
|
||||
|
||||
/**
|
||||
* IsOneOfAssert constructor.
|
||||
* @param array $allowedValues
|
||||
* @var array the expected values
|
||||
*/
|
||||
public function __construct(array $allowedValues)
|
||||
private $allowedValues = [];
|
||||
|
||||
public function __construct($allowedValues)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->allowedValues = $allowedValues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string representation of the object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
public function toString(): string
|
||||
{
|
||||
$allowedValues = array_map(function ($value) {
|
||||
return VarDumper::dumpAsString($value);
|
||||
}, $this->allowedValues);
|
||||
$allowedValues = [];
|
||||
|
||||
foreach ($this->allowedValues as $value) {
|
||||
$this->allowedValues[] = VarDumper::dumpAsString($value);
|
||||
}
|
||||
|
||||
$expectedAsString = implode(', ', $allowedValues);
|
||||
|
||||
return "is one of $expectedAsString";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function matches($other)
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return in_array($other, $this->allowedValues, false);
|
||||
return in_array($other, $this->allowedValues);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user