Get possible types based on a (numeric) array value

@param array $value
@return array
359703
protected function getPossibleArrayTypes(array $value): array
    {
        $noSubTypes = in_array('array', $this->types);

        $types = array_filter($this->types, function($type) use($noSubTypes) {
            return $type === 'array'
                || (!$noSubTypes && substr($type, -2) === '[]')
                || (class_exists($type) && is_a(Traversable::class, $type, true));
        });

        return $noSubTypes ? $types : $this->removeImpossibleArraySubtypes($types, $value);
    }
131330
public function generate($value): array
    {
        $schema = [];
        switch (gettype($value)) {
            case 'NULL':
                $schema['type'] = 'null';
                break;
            case 'boolean':
                $schema['type'] = 'boolean';
                break;
            case 'integer':
                $schema['type'] = 'integer';
                break;
            case 'double':
                $schema['type'] = 'number';
                break;
            case 'string':
                $schema = $this->generateStringSchema($value);
                break;
            case 'array':
                $isDictionary = array_keys($value) !== range(0, count($value) - 1);
                if ($isDictionary) {
                    $schema = $this->generateDictionarySchema($value);
                } else {
                    $schema = $this->generateArraySchema($value);
                }
                break;
        }
        return $schema;
    }
267191
private function getValueType($value)
    {
        if (is_string($value))
            return 'string';
        if (is_bool($value))
            return 'bool';
        if (is_float($value))
            return 'float';
        if (is_numeric($value))
            return 'int';
        if (is_array($value))
            return 'array';
        return 'mixed';
    }
742568
private function getType($value): string
    {
        if (is_array($value)) {
            if ($value !== array_values($value)) {
                return self::DATATYPE_OBJECT;
            }

            return self::DATATYPE_ARRAY;
        }

        if (is_bool($value)) {
            return self::DATATYPE_BOOLEAN;
        }

        if (is_string($value)) {
            return self::DATATYPE_STRING;
        }

        if (is_int($value) || is_float($value)) {
            return self::DATATYPE_NUMBER;
        }

        if (null === $value) {
            return self::DATATYPE_NULL;
        }

        throw new \InvalidArgumentException(
            sprintf(
                'Value needs to be of type array|bool|string|int|float|null, %s given',
                is_object($value) ? get_class($value) : gettype($value)
            )
        );
    }
32136
protected function checkType($value)
    {
        if ($value === null) {
            return $value;
        }

        Type::force($value, 'numeric', true);
        return $value === null ? $value : (float)$value;
    }
564333
private function objectParam($value)
    {
        if ($value instanceof \stdClass) {
            throw new \InvalidArgumentException(
                'Values of type `\stdClass` are interpreted as structs and must define their types.'
            );
        }

        if ($value instanceof ValueInterface) {
            return [
                $this->typeObject($value->type()),
                $value->formatAsString()
            ];
        }

        if ($value instanceof Int64) {
            return [
                $this->typeObject(self::TYPE_INT64),
                $value->get()
            ];
        }

        throw new \InvalidArgumentException(sprintf(
            'Unrecognized value type %s. ' .
            'Please ensure you are using the latest version of google/cloud or google/cloud-spanner.',
            get_class($value)
        ));
    }
117615
public static function arrayize($value)
    {
        $forbidden = [];
        if ($value instanceof Model) {
            $forbidden = $value->getHidden();
        }

        $array = [];
        foreach ($value as $key => $item) {
            if (!in_array(trim($key), $forbidden)) {
                switch (gettype($item)) {
                    case 'object':
                    case 'array':
                        $buffer = self::arrayize($item);
                        if (!empty($buffer)) {
                            $array[trim($key)] = $buffer;
                        }

                        break;
                    default:
                        if (isset($item)) {
                            $array[trim($key)] = $item;
                        }
                }
            }
        }

        return $array;
    }
575733
protected function parseStringsToNativeTypes($value)
    {
        if (is_array($value)) {
            return array_map([$this, 'parseStringsToNativeTypes'], $value);
        }

        if (! is_string($value)) {
            return $value;
        }

        $parsedValue = json_decode($value, true);

        if (json_last_error() === JSON_ERROR_NONE) {
            return $parsedValue;
        }

        return $value;
    }
572865
public function geetParamTypeByValue($value)
	{
		switch(gettype($value))
		{
			case 'boolean':
				return PDO::PARAM_BOOL;
				break;
			case 'integer':
				return PDO::PARAM_INT;
				break;
			case 'NULL':
				return PDO::PARAM_NULL;
				break;
			default:
				return PDO::PARAM_STR;
				break;
		}
	}
376820
public static final function cast($value): array {
		if (is_array($value)){
			return $value;
		}

		if (is_object($value) && method_exists($value, 'toArray')){
			return $value->toArray();
		}

		if ($value instanceof \Generator){
			return iterator_to_array($value);
		}

		return [$value];
	}
306022
protected function inArray($value)
    {
        if ($this->strict) {
            $isIn = in_array($value, $this->range, true);
        } else {
            $isIn = false;
            foreach ($this->range as $r) {
                $isIn = (strcmp($r, $value) === 0);
                if ($isIn) break;
            }
        }
        return $isIn;
    }
1291720
private function inferType($value)
    {
        if (is_integer($value)) {
            return \PDO::PARAM_INT;
        }

        if (is_bool($value)) {
            return \PDO::PARAM_BOOL;
        }

        if (is_array($value)) {
            return is_integer(current($value))
                ? Connection::PARAM_INT_ARRAY
                : Connection::PARAM_STR_ARRAY;
        }

        return \PDO::PARAM_STR;
    }
1010626
public function extract($value)
    {
        if (!$value instanceof TaxedPrice) {
            throw new \InvalidArgumentException(sprintf(
                '$value expected type SCL\Currency\TaxedPrice, got "%s"',
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        return [
            'amount' => $value->getAmount()->getValue(),
            'tax'    => $value->getTax()->getValue(),
        ];
    }
763716
public static function checkValueTypes(array $types, $value)
	{
		foreach ($types as $type)
		{
			$type = strtolower($type);
			if (array_key_exists($type, self::$hints) && call_user_func(self::$hints[$type], $value)) return true;
			if (is_object($value) && @is_a($value, $type)) return true;
			if ($type === 'mixed') return true;
		}
		return false;
	}
613719
public function getTypeFromValue($value = null)
    {
        $value = ($value == null ? $this->value : $value);
        return array_search($value, self::$codeList);
    }
239392
public function getTypeFromValue($value = null)
    {
        $value = ($value == null ? $this->value : $value);
        return array_search($this->value, self::$statusList);
    }
100398
protected function determineType($type, $value)
    {
        foreach ((array) $type as $t) {
            if ($t == 'string' && (is_string($value) || (is_object($value) && method_exists($value, '__toString')))) {
                return 'string';
            } elseif ($t == 'object' && (is_array($value) || is_object($value))) {
                return 'object';
            } elseif ($t == 'array' && is_array($value)) {
                return 'array';
            } elseif ($t == 'integer' && is_integer($value)) {
                return 'integer';
            } elseif ($t == 'boolean' && is_bool($value)) {
                return 'boolean';
            } elseif ($t == 'number' && is_numeric($value)) {
                return 'number';
            } elseif ($t == 'numeric' && is_numeric($value)) {
                return 'numeric';
            } elseif ($t == 'null' && !$value) {
                return 'null';
            } elseif ($t == 'any') {
                return 'any';
            }
        }

        return false;
    }