@param array $transformers

@throws Exception\UnexpectedTypeException
968546
public function setTransformers(array $transformers)
    {
        foreach ($transformers as $transformer) {
            if (!$transformer instanceof TransformerInterface) {
                throw new UnexpectedTypeException($transformer, "NeuroSys\\FileMerger\\TransformerInterface");
            }
        }
        $this->transformers = $transformers;
    }
298902
public function add($field, DataSetTransformerInterface $transformer)
    {
        if ($this->has($field)) {
            throw new TransformerInvalidColumnException($field);
        }

        $this->items[$field] = $transformer;
    }
982868
protected function assertValid(array $classes)
    {
        parent::assertValid($classes);

        foreach ($classes as $config) {
            if (!is_subclass_of($config, ConfigurationInterface::class)) {
                throw ConfigurationException::invalidClass($config);
            }
        }
    }
159378
private function initTypeExtensions()
    {
        $this->typeExtensions = [];

        foreach ($this->loadTypeExtensions() as $extension) {
            if (!$extension instanceof BlockTypeExtensionInterface) {
                throw new Exception\UnexpectedTypeException(
                    $extension,
                    'Oro\Component\Layout\BlockTypeExtensionInterface'
                );
            }

            $type = $extension->getExtendedType();

            $this->typeExtensions[$type][] = $extension;
        }
    }
779746
private function initTypes(): void
    {
        $this->types = [];

        foreach ($this->loadTypes() as $type) {
            if (!$type instanceof ObjectTypeInterface) {
                throw new UnexpectedTypeException($type, 'Fxp\Component\DefaultValue\ObjectTypeInterface');
            }

            $this->types[$type->getClass()] = $type;
        }
    }
681280
public function validate($value, Constraint $constraint)
    {
        if (!$constraint instanceof Json) {
            throw new UnexpectedTypeException($constraint, Json::class);
        }

        if (null === $value || '' === $value) {
            return;
        }

        if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
            throw new UnexpectedTypeException($value, 'string');
        }

        if (json_decode($value) || json_last_error() === JSON_ERROR_NONE) {
            return;
        }

        $this->context->buildViolation($constraint->message)
            ->setParameter('{{ value }}', $this->formatValue($value))
            ->addViolation();
    }
733948
private function initTypeExtensions()
    {
        $this->typeExtensions = [];

        foreach ($this->loadTypeExtensions() as $extension) {
            if (!$extension instanceof BlockTypeExtensionInterface) {
                throw new UnexpectedTypeException($extension, 'Fxp\Component\Block\BlockTypeExtensionInterface');
            }

            foreach ($extension::getExtendedTypes() as $extendedType) {
                $this->typeExtensions[$extendedType][] = $extension;
            }
        }
    }
987371
public static function transformer(TransformerInterface $transformer, array $params): array
    {
        if (empty($params)) {
            return $params;
        }

        try {
            list($extra, $variadic) = self::interpretFunction(
                new \ReflectionMethod($transformer, 'transform'),
                $params
            );

            list($args) = self::interpretFunction(
                new \ReflectionMethod($transformer, '__invoke'),
                $params
            );

            return array_merge(
                $args,
                $extra,
                $variadic
            );
        } catch (\ReflectionException $e) {
            // Sorry
        }

        return [];
    }
1224151
public function reverseTransform($values)
    {
        $collection = new ArrayCollection();

        if ('' === $values || null === $values) {
            return $collection;
        }

        if (!is_array($values)) {
            throw new UnexpectedTypeException($values, 'array');
        }
        $values = Util::filterScalarValues($values);

        if (count($values) == 0) {
            return $collection;
        }
        $values = \array_unique($values);
        if (count($values) > $this->maxResults) {
            throw new TransformationFailedException(
                sprintf('This collection should contain %s elements or less.', $this->maxResults)
            );
        }

        try {
            $hash = $this->getCacheHash($values);
            if (array_key_exists($hash, $this->cachedResults)) {
                $collection = $this->cachedResults[$hash];
            } else {
                //Result not in cache

                $queryBuilderLoader = new ORMQueryBuilderLoader($this->queryBuilder);

                foreach ($queryBuilderLoader->getEntitiesByIds($this->identifier, $values) as $entity) {
                    $collection->add($entity);
                }
                $this->cachedResults[$hash] = $collection; //Saves result in cache
            }
        } catch (\Exception $e) {
            throw new TransformationFailedException('Tranformation: Query Error');
        }

        return $collection;
    }
837541
private function initTypes()
    {
        $this->types = [];

        foreach ($this->loadTypes() as $type) {
            if (!$type instanceof BlockTypeInterface) {
                throw new Exception\UnexpectedTypeException(
                    $type,
                    'Oro\Component\Layout\BlockTypeInterface'
                );
            }

            $this->types[$type->getName()] = $type;
        }
    }
791839
private function verifyElementsType(array $elements): void
    {
        $allowedType = $this->getAllowedType();
        if ($allowedType !== DTO::class
            && (!\class_exists($allowedType) || !\in_array(DTO::class, \class_implements($allowedType), true))
        ) {
            throw new InvalidCollectionTypeException(\sprintf(
                'Allowed class type for %s should be a %s, %s given',
                static::class,
                DTO::class,
                $allowedType
            ));
        }

        foreach ($elements as $element) {
            if (!\is_object($element) || !\is_a($element, $allowedType)) {
                throw new InvalidParameterException(\sprintf(
                    'All elements of %s should be instances of %s, %s given',
                    static::class,
                    $allowedType,
                    \is_object($element) ? \get_class($element) : \gettype($element)
                ));
            }
        }
    }
888082
public void execute(
          TransformerImpl transformer)
            throws TransformerException
  {

    int sourceNode = transformer.getXPathContext().getCurrentNode();
    String countString = getCountString(transformer, sourceNode);

    try
    {
      transformer.getResultTreeHandler().characters(countString.toCharArray(),
                                                    0, countString.length());
    }
    catch(SAXException se)
    {
      throw new TransformerException(se);
    }
  }
1030659
public static function setDataTypes(array $types) : void
    {
        // Datatypes key validation
        foreach ($types as $key => $value) {
            if (!preg_match('/^[A-Za-z0-9-_]+$/', $key)) {
                throw new \UnexpectedValueException("<b>$key</b> is not a valid datatype key", 1);

            } elseif (!is_string($value)) {
                throw new \LogicException("<b>$key</b> must have a string value", 1);
            }
        }

        // Put keys between brackets
        self::$datatypes = array_combine(
            array_map(function ($t) {
                return '/\{' . $t . '\}/';
            }, array_keys($types)),
            $types
        );
    }
183958
protected function getTransformers()
    {
        $out = [];

        foreach ($this->transformers as $transformer) {
            if ($transformer instanceof Transformer) {
                $out[] = $transformer;
            } else if (is_string($transformer)) {
                $out[] = TransformerLibrary::make($transformer);
            } else {
                throw new LogicException("All transformers must implement " . Transformer::class);
            }
        }

        return $out;
    }
311181
protected function addChildren(
        ResourceTransformer $transformer,
        PropertySetter $propertySetter,
        $entity,
        RelationshipField $field,
        array $childEntities,
        Context $context
    )
    {
        if (count($childEntities) > 0) {
            $propertySetter->setChild($transformer, $entity, $this->getField(), $childEntities[0], $context);
        }
    }
636447
public function editChildren(
        ResourceTransformer $transformer,
        $entity,
        RelationshipField $field,
        array $childEntities,
        Context $context
    )
    {
        list($entity, $name, $parameters) = $this->resolvePath($transformer, $entity, $field, $context);
        $this->editChildrenInEntity($entity, $name, $childEntities, $parameters);
    }
257048
public function transform(array &$samples) : void
    {
        if ($this->selected === null) {
            throw new RuntimeException('Transformer has not been fitted.');
        }

        foreach ($samples as &$sample) {
            $sample = array_intersect_key($sample, $this->selected);
        }
    }