/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
src/Illuminate/Validation/Rules/Contains.php
48 строк
1 KB
Sumaia Zaman
[13.x] Fix deprecation warning in Contains and DoesntContain rules when values contain null (#59561)
06 апр 2026, 15:51
Не верифицирован
06 апр 2026, 15:51
e15f891
Код
Авторство
О чём код?
<?php namespace Illuminate\Validation\Rules; use Illuminate\Contracts\Support\Arrayable; use Stringable; use function Illuminate\Support\enum_value; class Contains implements Stringable { /** * The values that should be contained in the attribute. * * @var array */ protected $values; /** * Create a new contains rule instance. * * @param \Illuminate\Contracts\Support\Arrayable|\UnitEnum|array|string $values */ public function __construct($values) { if ($values instanceof Arrayable) { $values = $values->toArray(); } $this->values = is_array($values) ? $values : func_get_args(); } /** * Convert the rule to a validation string. * * @return string */ public function __toString() { $values = array_map(function ($value) { $value = enum_value($value); return '"'.str_replace('"', '""', (string) $value).'"'; }, $this->values); return 'contains:'.implode(',', $values); } }