/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/ObjectMapper/Condition/SourceClass.php
44 строки
1 KB
Ryan RAJKOMAR
[ObjectMapper] Allow class FQDN arrays as TargetClass and SourceClass param
06 мар 2026, 18:16
06 мар 2026, 18:16
bf07ee6
Код
Авторство
О чём код?
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ObjectMapper\Condition; /** * @template T of object * * @implements ClassRuleConditionCallableInterface<T, object> */ final class SourceClass implements ClassRuleConditionCallableInterface { /** * @var non-empty-array<class-string> */ private readonly array $sources; /** * @param class-string<T>|array<class-string<T>> $className */ public function __construct(string|array $className) { $this->sources = \is_array($className) ? $className : [$className]; } public function __invoke(mixed $value, object $source, ?object $target): bool { foreach ($this->sources as $validSource) { if ($source instanceof $validSource) { return true; } } return false; } }