@param $typeName
@param array|null $typeParams
@param null       $group
@param null       $version

@return float|int|string|array|\DateTime|EntityInterface

@throws \Exception
554760
protected function generateRandomData($typeName, array $typeParams = null, $group = null, $version = null)
    {
        $result = null;

        switch ($typeName) {
            case 'DateTime':
                $result = new \DateTime();
                break;

            case 'integer':
                $result = \rand(0, 100);
                break;

            case 'double':
                $result = \doubleval(\rand(0, 1000) / 1000);
                break;

            case 'string':
                $result = \substr(\md5(\rand()), 0, \rand(2, 10));
                break;

            case 'boolean':
                $result = (0 == \rand(0, 1) % 2);
                break;

            case 'array':
                $numberOfTypeParams = \count($typeParams);

                if (2 == $numberOfTypeParams) {
                    $subtypeName = @$typeParams[0]['name'];
                    $subtypeParams = $typeParams[1]['name'];
                } elseif (1 == $numberOfTypeParams) {
                    $subtypeName = $typeParams[0]['name'];
                    $subtypeParams = null;
                } else {
                    throw new \RuntimeException('Missing JMS type params.');
                }

                $amountOfArrayIndexes = \rand(0, 5);

                $result = [];
                while ($amountOfArrayIndexes-- > 0) {
                    $result[] = $this->generateRandomData($subtypeName, (array) $subtypeParams, $group, $version);
                }

                break;

            default:
                if (\is_string($typeName) && \class_exists($typeName)) {
                    $result = $this->generate($typeName, $group, $version);
                } else {
                    throw new \RuntimeException("Unrecognized type: $typeName");
                }
        }

        return $result;
    }
987297
public function group($typeId, $group = null, $code = null)
    {
        return $this->processor->group($this, $typeId, $group, $code);
    }
915929
public function create(string $className, string $typeName): Type
    {
        $type = new InputObjectType([
            'name' => $typeName,
            'fields' => function () use ($className): array {
                $fields = [
                    [
                        'name' => 'type',
                        'type' => $this->types->get('JoinType'),
                        'defaultValue' => 'innerJoin',
                    ],
                    $this->filterGroupConditionTypeFactory->getField($className),
                ];

                // Only create join type, if there is anything to join on
                if ($this->filterGroupJoinTypeFactory->canCreate($className)) {
                    $fields[] = $this->filterGroupJoinTypeFactory->getField($className);
                }

                return $fields;
            },
        ]);

        return $type;
    }
198568
public function getConstraintsForType($version, $type)
    {
        $cache = & $this->constraintsForTypeCache[$version.$type];

        if ($cache === null) {
            $cache = [];

            foreach ($this->getConstraints($version) as $constraint) {
                if ($constraint->supports($type)) {
                    $cache[] = $constraint;
                }
            }
        }

        return $cache;
    }
878027
protected static function prepareContextForFixtures(Context $context, $group, $version)
    {
        if (!\is_null($version)) {
            $context->setVersion($version);
        }

        if (!\is_null($group)) {
            $context->setGroups([$group, Entity::GROUP_METADATA]);
        }

        return $context;
    }
162961
public function create(string $className, string $typeName): Type
    {
        $description = 'To be used as a filter for objects of type `' . Utils::getTypeName($className) . '`';

        $fieldsGetter = function () use ($className, $typeName): array {
            $configuration = [
                [
                    'name' => 'groups',
                    'type' => Type::listOf(Type::nonNull($this->getGroupType($className, $typeName))),
                ],
            ];

            return $configuration;
        };

        $filterType = new InputObjectType([
            'name' => $typeName,
            'description' => $description,
            'fields' => $fieldsGetter,
        ]);
        $this->types->registerInstance($filterType);

        return $filterType;
    }
106046
public function check($typeName, $value)
    {
        switch ($typeName) {
            case static::SCALAR_STRING:
                return is_string($value);
            case static::SCALAR_INTEGER:
                return is_integer($value);
            case static::SCALAR_FLOAT:
                return is_float($value);
            case static::SCALAR_BOOLEAN:
                return is_bool($value);
            default:
                return false;
        }
    }
595654
public function createDataType($typeName)
    {
        try {
            $cls = "";
            $typelwr = strtolower($typeName);
            foreach ($this->typedefs as $name => $class) {
                if (strtolower($name) === $typelwr) {
                    $cls = StringHelper::unqualify($class);
                    break;
                }
            }

            if ($cls === "") {
                return null;
            }

            if (!class_exists($cls)) {
                throw new BuildException(
                    "Could not instantiate class $cls, even though a class was specified. (Make sure that the specified class file contains a class with the correct name.)"
                );
            }

            $type = new $cls();
            $this->project->log("  +Type: $typeName", Project::MSG_DEBUG);
            if (!($type instanceof DataType)) {
                throw new Exception("$class is not an instance of phing.types.DataType");
            }
            if ($type instanceof ProjectComponent) {
                $type->setProject($this->project);
            }
        } catch (Exception $t) {
            throw new BuildException("Could not create type: $typeName", $t);
        }
        // everything fine return reference
        return $type;
    }
1241936
public function countGroupsForType($typeId, $status)
    {
        try {
            return $this->innerGateway->countGroupsForType($typeId, $status);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
52975
public static function parse($typeName)
    {
        $normalize = array("int" => self::INTEGER_NAME, 
            "bool" => self::BOOLEAN_NAME, 
            "double" => self::FLOAT_NAME,
            "real" => self::FLOAT_NAME,
            "long" => self::INTEGER_NAME);

        if (isset($normalize[$typeName]))
            $typeName = $normalize[$typeName];

        if (self::$cachedTypes === null)
        {
            self::$cachedTypes = array(
                self::INTEGER_NAME => new PrimitiveType(self::INTEGER_NAME),
                self::FLOAT_NAME => new PrimitiveType(self::FLOAT_NAME),
                self::STRING_NAME => new PrimitiveType(self::STRING_NAME),
                self::BOOLEAN_NAME => new PrimitiveType(self::BOOLEAN_NAME),
                self::MIXED_NAME => new PrimitiveType(self::MIXED_NAME),
                self::RESOURCE_NAME => new PrimitiveType(self::RESOURCE_NAME),
                self::OBJECT_NAME => new PrimitiveType(self::OBJECT_NAME),
                self::NULL_NAME => new PrimitiveType(self::NULL_NAME),
                self::CALLABLE_NAME => new PrimitiveType(self::CALLABLE_NAME));
        }

        if (isset(self::$cachedTypes[$typeName]))
            return self::$cachedTypes[$typeName];

        return null;
    }
246125
protected function createType($typeName)
    {
        if (isset($this->typeCache[$typeName])) {
            return clone $this->typeCache[$typeName];
        }


        if (!$this->hasExtension($typeName)) {
            $class = $this->typeToClassName($typeName);
            $this->typeCache[$typeName] = new $class();
            return clone $this->typeCache[$typeName];
        }

        $this->typeCache[$typeName] = $this->callExtension($typeName, [$typeName, $this]);

        return clone $this->typeCache[$typeName]->setName($typeName);
    }
1022323
public function transform($group, array $params = array())
    {
        if (!$group instanceof GroupInterface) {
            throw new TransformerParameterTypeException();
        }
        $nbrGroupsUsers = array_key_exists('nbrGroupsUsers', $params) ? $params['nbrGroupsUsers'] : array();

        $facade = $this->newFacade();

        $facade->id = $group->getId();
        $facade->name = $group->getName();
        $facade->label = $this->multiLanguagesChoiceManager->choose($group->getLabels());
        $facade->nbrUsers = array_key_exists($group->getId(), $nbrGroupsUsers) ? $nbrGroupsUsers[$group->getId()] : 0;

        $facade = $this->addSite($facade, $group);
        $facade = $this->addRoles($facade, $group);
        $facade = $this->addRights($facade, $group, $nbrGroupsUsers);

        return $facade;
    }
1087033
public function setGroupClass(string $classname)
    {
        if (!class_exists($classname) || !is_subclass_of($classname, GroupInterface::class))
            throw new DomainException("Invalid group class: $classname");
        $this->group_class = $classname;
        return $this;
    }
1100248
public function getMigrationVersion($version)
    {
        if ($this->isVersionAvailable($version)) {
            if ($this->isVersionLoaded($version)) {
                $configuration = $this->loadedVersions[$version];
            } else {
                $configuration = $this->loadConfiguration($version);
                $this->loadedVersions[$version] = $configuration;
            }
            return $configuration;
        }
        throw new MigrationException('Specified version is not available.', 1345821746);
    }
282235
public function create(string $className, string $typeName): Type
    {
        $description = $this->getDescription($className);

        $fieldsGetter = function () use ($className): array {
            $factory = new InputFieldsConfigurationFactory($this->types, $this->entityManager);
            $configuration = $factory->create($className);

            return $configuration;
        };

        return new InputObjectType([
            'name' => $typeName,
            'description' => $description,
            'fields' => $fieldsGetter,
        ]);
    }
999070
protected static function matchVersion($version, $type)
    {
        $patchVersion = true;

        if (\in_array($type, array('dev', 'snapshot'), true)) {
            $type = 'dev';
            $patchVersion = false;
        } elseif ('a' === $type) {
            $type = 'alpha';
        } elseif (\in_array($type, array('b', 'pre'), true)) {
            $type = 'beta';
        } elseif (!\in_array($type, array('alpha', 'beta', 'RC'), true)) {
            $type = 'patch';
        }

        $version .= $type;

        return array($version, $patchVersion);
    }
314634
public function setDoctype(string $doctype = 'html', string $version = '5', string $type = 'dtd'): PageHead
    {
        $doc_types = [
            'html'             => [
                '5'    => ['dtd' => '<!DOCTYPE HTML>'],
                '4.01' => [
                    'strict'       => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
                    'transitional' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
                    'frameset'     => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
                ],
                '2.0'  => ['dtd' => '<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">'],
                '3.2'  => ['dtd' => '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">']
            ],
            'xhtml'            => [
                '1.0' => [
                    'dtd'          => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">',
                    'strict'       => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
                    'transitional' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
                    'frameset'     => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'
                ],
                '1.1' => [
                    'dtd'   => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
                    'basic' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">'
                ]
            ],
            'mathml'           => [
                '2.0' => ['dtd' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd">'],
                '1.1' => ['dtd' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">']
            ],
            'xhtml_mathml_svg' => [
                '1.1' => [
                    'basic' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
                    'xhtml' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
                    'svg'   => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">'
                ]
            ],
            'svg'              => [
                '1.1' => [
                    'full'  => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
                    'basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
                    'tiny'  => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">'
                ],
                '1.0' => ['dtd' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">']
            ]
        ];
        if (!isset($doc_types[$doctype], $doc_types[$doctype][$version], $doc_types[$doctype][$version][$type])) {
            throw new RuntimeException('Non-existing doctype requested');
        }

        $this->doctype = $doc_types[$doctype][$version][$type];

        return $this;
    }