returns all fields with a specified type.

@param array $types
@param null $intersectArray only return fields that are defined in this array

@return array
765867
public function getFieldsWitTypes(array $types, $intersectArray = null)
    {
        $result = [];
        foreach ($this->getClassMetadata()->getFieldNames() as $field) {
            $type = $this->getClassMetadata()->getTypeOfField($field);
            if (in_array($type, $types)) {
                $result[] = $field;
            }
        }
        // calculate intersection
        if (!is_null($intersectArray)) {
            $result = array_intersect($result, $intersectArray);
        }

        return $result;
    }
832719
static Field[] getAllFields(Class<?> type) {
        List<Field> fields = new ArrayList<Field>();
        for (Class<?> clazz = type; clazz != null; clazz = clazz.getSuperclass()) {
            if (clazz == MPBase.class ||
                    clazz == Object.class) {
                break;
            }
            fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
        }
        Field[] fieldsArray = new Field[fields.size()];
        return fields.toArray(fieldsArray);
    }
988788
public static function negateTypes(array $all_types)
    {
        return array_map(
            /**
             * @param  array<int, array<int, string>> $anded_types
             *
             * @return  array<int, array<int, string>>
             */
            function (array $anded_types) {
                if (count($anded_types) > 1) {
                    $new_anded_types = [];

                    foreach ($anded_types as $orred_types) {
                        if (count($orred_types) > 1) {
                            return [];
                        }

                        $new_anded_types[] = self::negateType($orred_types[0]);
                    }

                    return [$new_anded_types];
                }

                $new_orred_types = [];

                foreach ($anded_types[0] as $orred_type) {
                    $new_orred_types[] = [self::negateType($orred_type)];
                }

                return $new_orred_types;
            },
            $all_types
        );
    }
259872
private static function getFieldTypeArray($fields)
    {
        if (count($fields) === 0) {
            return;
        }

        $types = array();

        foreach ($fields as &$field) {
            $types[] = $field->type;
        }

        return $types;
    }
1107069
private function customFieldsArrayType(): array
    {
        $collectionKeyType = new Type(Type::BUILTIN_TYPE_STRING);
        $collectionValueType = new Type('object', false, CustomFieldInterface::class);

        return [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, $collectionKeyType, $collectionValueType)];
    }
764587
public static function types(array $types)
    {
        $defined = array('boolean', 'integer', 'string', 'double');
        $diff    = array_diff($types, $defined);

        if (empty($diff))
        {
            return TRUE;
        }
        throw new LazerException('Wrong types: "' . implode(', ', $diff) . '". Available "boolean, integer, string, double"');
    }
1218209
public function getItems(...$types)
    {
        // If particular item types should be filtered
        if (count($types)) {
            return array_filter(
                $this->items,
                function (ItemInterface $item) use ($types) {
                    return $item->isOfType(...$types);
                }
            );
        }

        return $this->items;
    }
1004720
public static function getArrayType(string $type): ?string
    {
        if (substr($type, -2) !== '[]' || strlen($type) === 2) {
            return null;
        }

        return substr($type, 0, -2);
    }
408550
protected function filterFields(array $fields)
    {
        if ($requested = $this->getOwnFields()) {
            $fields = array_intersect_key($fields, array_flip($requested));
        }

        return $fields;
    }
1220832
public static function hydrateCollection(array $types)
    {
        $hydrated = [];

        foreach ($types as $type) {
            $hydrated[] = self::hydrate($type);
        }

        return $hydrated;
    }
873602
public function getBestResponseType(array $types)
    {
        if (empty($types))
            return "";

        $this->sortTypes($types);
        $type = reset($types);
        return $this->accepts($type) ? current($types) : null;
    }
562849
public static function isTypesOf(array $array, array $types) : bool
    {
        if (!self::isTypeOf($types, 'string')) {
            return false;
        }

        $types = array_map(function ($type) {
            return DataTypes::guessFromAlias($type);
        }, $types);

        if (array_diff($types, DataTypes::TYPES)) {
            return false;
        }

        foreach ($array as $item) {
            if (!in_array(gettype($item), $types, true)) {
                return false;
            }
        }

        return true;
    }
803475
public static function namesByType(array $types)
    {
        $names = array();

        foreach ($types as $type) {
            $names[] = self::nameByType($type);
        }

        return $names;
    }
1031110
protected function extractTypeValues(array $data, array $types)
    {
        $typeValues = array();

        foreach ($data as $k => $_) {
            $typeValues[] = isset($types[$k])
                ? $types[$k]
                : \PDO::PARAM_STR;
        }

        return $typeValues;
    }
1232652
private function doClear(array $types)
    {
        $cleared = [];
        $this->mf->enableCache(false);

        foreach ($types as $type) {
            $metadata = $this->mf->getMetadataForType($type);
            $this->mf->getCache()->evictMetadataFromCache($metadata);
            $cleared[] = $type;
        }

        $this->mf->enableCache(true);
        $this->mf->clearMemory();
        return $cleared;
    }
719103
protected function checkType($value, $types): ?string
    {
        $type = gettype($value);

        return in_array($type, $types) ? $type : null;
    }
860992
public function search(array $types, array $query, array $queryStringParams = [])
    {
        $params = [];
        $params['index'] = $this->getIndexName();
        
        $resolvedTypes = [];
        foreach ($types as $type) {
            $resolvedTypes[] = $this->resolveTypeName($type);
        }
        
        if (!empty($resolvedTypes)) {
            $params['type'] = implode(',', $resolvedTypes);
        }
        
        $params['body'] = $query;

        if (!empty($queryStringParams)) {
            $params = array_merge($queryStringParams, $params);
        }

        $this->stopwatch('start', 'search');
        $result = $this->client->search($params);
        $this->stopwatch('stop', 'search');

        return $result;
    }