Check data type foreach Column
Check data type for each column and returns the most commonly.

Requires PHP >= 5.5

@uses   DatatypeEnum::getValidTypeFromSample

@return array|bool
166133
public function getDatatypes() {
        if (empty($this->data)) {
            $this->data = $this->parse_string();
        }
        if (!is_array($this->data)) {
            throw new \UnexpectedValueException('No data set yet.');
        }

        $result = [];
        foreach ($this->titles as $cName) {
            $column = array_column($this->data, $cName);
            $cDatatypes = array_map(DatatypeEnum::class . '::getValidTypeFromSample', $column);

            $result[$cName] = $this->getMostFrequentDatatypeForColumn($cDatatypes);
        }

        $this->data_types = $result;

        return !empty($this->data_types) ? $this->data_types : [];
    }
545675
public function isValid()
	{
		$isValid = true;

		$form = $this->getForm();

		foreach($this->recordColumnsGet() as $column => $value)
		{
			$element = $form->getElement($column);
			if($element && !$element->isValid($value))
			{
				$isValid = false;
				$this->_validationErrors[$element->getId()] = $element->getErrors();
			}
		}

		return $isValid;
	}
155300
public static function getValidTypeFromSample($value) {
        $value = trim((string) $value);

        if (empty($value)) {
            return false;
        }

        foreach (self::$validators as $type => $validator) {
            if ($validator === null) {
                continue;
            }

            if (method_exists(__CLASS__, $validator) && self::$validator($value)) {
                return $type;
            }
        }

        return self::__DEFAULT;
    }
802222
public function getDataValidation()
    {
        if (!isset($this->parent)) {
            throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet');
        }

        return $this->getWorksheet()->getDataValidation($this->getCoordinate());
    }
192676
public static function dataTypeSelectOptions()
    {
        return [
            Property::DATA_TYPE_STRING => Module::t('app', 'String'),
            Property::DATA_TYPE_TEXT => Module::t('app', 'Text'),
            Property::DATA_TYPE_INTEGER => Module::t('app', 'Integer'),
            Property::DATA_TYPE_FLOAT => Module::t('app', 'Float'),
            Property::DATA_TYPE_BOOLEAN => Module::t('app', 'Boolean'),
            Property::DATA_TYPE_PACKED_JSON => Module::t('app', 'Packed JSON'),
            Property::DATA_TYPE_INVARIANT_STRING => Module::t('app', 'Untranslatable String'),
        ];
    }
345341
protected function getColumnsToExport()
    {
        if (is_array($this->columnsToExport)) {
            return $this->columnsToExport;
        }

        $columnsToExport = [];
        foreach ($this->getColumns() as $column) {
            /* @var $column \ZfcDatagrid\Column\AbstractColumn */

            if (! $column instanceof Column\Action &&
                $column->isHidden() === false &&
                in_array(get_class($column->getType()), $this->allowedColumnTypes)
            ) {
                $columnsToExport[] = $column;
            }
        }
        if (empty($columnsToExport)) {
            throw new \Exception('No columns to export available');
        }

        $this->columnsToExport = $columnsToExport;

        return $this->columnsToExport;
    }
701542
public function getTypeQuery()
    {

        switch( true ) {

            case $this->name === 'timestamp':
            case $this->name === 'bool':

                return $this->name;

            case $this->isEnum(): // enum's behave like strings

                return $this->name;

            case $this->name === 'bpchar': // "blank-padded char", the internal name of the 'character' data type
            case $this->name === 'text':

                return 'text';

            case $this->name === 'int2':
            case $this->name === 'int4':
            case $this->name === 'int8':

                return 'int';

            default:

                return $this->name;
                throw new \UnexpectedValueException( "type::pgTypeToQueryValidateType doesnt know about type `{$type}`" );

        }

    }
664489
public function isLob()
    {
        return ($this->type == PropelColumnTypes::BLOB || $this->type == PropelColumnTypes::VARBINARY || $this->type == PropelColumnTypes::LONGVARBINARY);
    }
1228544
public function isText()
    {
        return ($this->type == PropelColumnTypes::VARCHAR || $this->type == PropelColumnTypes::LONGVARCHAR || $this->type == PropelColumnTypes::CHAR);
    }
225261
public function hasStringTypeColumn(): bool
    {
        $hasStringType = false;
        foreach ($this->columnMetadataList as $columnMetadata) {
            $hasStringType = $hasStringType || $columnMetadata->isStringType();
        }
        return $hasStringType;
    }
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)
            )
        );
    }
2244
protected function getSortColumn()
    {
        if (!$this->isSortable()) {
            return false;
        }

        if ($this->sortColumn !== null) {
            return $this->sortColumn;
        }

        /*
         * User preference
         */
        if ($this->showSorting && ($sortOptions = $this->getSession('sort'))) {
            $this->sortColumn = $sortOptions['column'];
            $this->sortDirection = $sortOptions['direction'];
        }

        /*
         * Supplied default
         */
        else {
            if (is_string($this->defaultSort)) {
                $this->sortColumn = $this->defaultSort;
                $this->sortDirection = 'desc';
            }
            elseif (is_array($this->defaultSort) && isset($this->defaultSort['column'])) {
                $this->sortColumn = $this->defaultSort['column'];
                $this->sortDirection = $this->defaultSort['direction'] ?? 'desc';
            }
        }

        /*
         * First available column
         */
        if ($this->sortColumn === null || !$this->isSortable($this->sortColumn)) {
            $columns = $this->visibleColumns ?: $this->getVisibleColumns();
            $columns = array_filter($columns, function ($column) { return $column->sortable; });
            $this->sortColumn = key($columns);
            $this->sortDirection = 'desc';
        }

        return $this->sortColumn;
    }
746014
function GetFlexType()
	{
		$rt = $this->Type;
		switch ($this->Type)
		{
			case "int":
				$rt = "int";
				break;
			case "smallint":
				$rt = "int";
				break;
			case "tinyint":
				$rt = $this->MaxSize > 1 ? "int" : "Boolean";
				break;
			case "varchar":
				$rt = "String";
				break;
			case "text":
				$rt = "String";
				break;
			case "tinytext":
				$rt = "String";
				break;
			case "datetime":
				$rt = "Date";
				break;
			case "mediumint":
				$rt = "int";
				break;
			case "bigint":
				$rt = "int";
				break;
			case "decimal":
				$rt = "Number";
				break;
			case "float":
				$rt = "Number";
				break;
			default;
				break;
		}

		return $rt;
	}
1216341
public function validate() : bool
    {
        $table = $this->getConfig()->getTable();
        foreach ([$this->config->getField(), $this->config->getDisplayField()] as $field) {
            if ($table->getSchema()->hasColumn($field)) {
                continue;
            }

            $this->errors[] = sprintf('Unknown column "%s" for table "%s"', $field, $table->getAlias());
        }

        return empty($this->errors);
    }
227993
public function getValueElementType()
    {
        $valueElementType = 'text';

        if ($this->getAttribute() == 'attribute_set_id') {
            $valueElementType = 'select';
        } elseif (is_object($this->getAttributeObject())) {
            $frontendInput = $this->getAttributeObject()->getFrontendInput();

            if ($frontendInput === 'boolean') {
                $valueElementType = 'select';
            } elseif ($frontendInput === 'date') {
                $valueElementType = 'date';
            } elseif (in_array($frontendInput, ['select', 'multiselect'])) {
                $valueElementType = 'multiselect';
            }
        } elseif (in_array($this->getAttribute(), array_keys($this->specialAttributesProvider->getList()))) {
            $specialAttribute = $this->specialAttributesProvider->getAttribute($this->getAttribute());
            $valueElementType = $specialAttribute->getValueElementType();
        }

        return $valueElementType;
    }
752681
static function fetchIDListContainingDatatype( $dataTypeString )
    {
        $db = eZDB::instance();

        $version = self::VERSION_STATUS_DEFINED;
        $escapedDataTypeString = $db->escapeString( $dataTypeString );

        $sql = "SELECT DISTINCT contentclass_id
                FROM ezcontentclass_attribute
                WHERE version=$version
                AND data_type_string='$escapedDataTypeString'";

        $classIDArray = $db->arrayQuery( $sql, array( 'column' => 'contentclass_id' ) );
        return $classIDArray;
    }
1040358
protected function validateTypeCollection()
    {
        $field = 'type';

        if ($this->isExcluded($field) || $this->isUpdating()) {
            return null; // Do not check type on update - it cannot be changed and will be ignored
        }

        $value = $this->getSubmitted($field);
        $label = $this->translation->text('Type');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        $types = $this->collection->getTypes();

        if (!isset($types[$value])) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        return true;
    }