@param mixed $fieldsMap

@throws \InvalidArgumentException
5615
private function checkFieldsMapType($fieldsMap)
    {
        if (!is_array($fieldsMap) && !$fieldsMap instanceof \ArrayAccess) {
            throw new \InvalidArgumentException(sprintf(
                'Parameter fieldsMap passed to %s should be an array or \ArrayAccess.'
                .' Given: %s',
                __CLASS__,
                is_object($fieldsMap) ? get_class($fieldsMap) : gettype($fieldsMap)
            ));
        }
    }
292284
protected function setTimestamp($field, $timestamp, $now = false)
    {
        if ($timestamp === null && $now) {
            $this->{$field} = zipkin_timestamp();
            return null;
        }

        if (!is_zipkin_timestamp($timestamp)) {
            throw new \InvalidArgumentException($field . ' must be generated by zipkin_timestamp()');
        }

        $this->{$field} = $timestamp;
        return null;
    }
89220
public static function updateRecord($primaryKey, $fieldValues)
    {
        if (!is_scalar($primaryKey)) {
            throw new InvalidArgumentException(['`:value` is not a valid primary key value', 'value' => $primaryKey]);
        }

        $instance = new static();
        return static::query()->whereEq($instance->getPrimaryKey(), $primaryKey)->update($fieldValues);
    }
658839
public function relatedToOne(
        string $otherClass,
        array $fieldsMap,
        bool $applySetters = false
    ) {
        //@TODO remove duplicated code

        $thisValues = array_intersect_key($this->data, $fieldsMap);

        $filterFn = function (Query $query) use (&$thisValues, &$fieldsMap) {
            $query->where(function (WhereClause $where) use (&$query, &$thisValues, &$fieldsMap) {
                foreach ($fieldsMap as $thisKey => $thatKey) {
                    $where->and($thatKey, '=', '?');
                    $query->bind($thisValues[$thisKey]);
                }
            });

            $query->limit(1);
        };

        /* @var $otherClass Model */
        $search = $otherClass::find($filterFn, $applySetters);

        return !(empty($search)) ? $search[0] : null;
    }
905471
protected function validateFieldsExist(string $method, string $fieldName, string $otherFieldName)
    {
        foreach ([$fieldName, $otherFieldName] as $name) {
            if (!isset($this->fields[$fieldName])) {
                throw InvalidArgumentException::format(
                        "Invalid call to %s: field with name \'%s\' has not currently been defined in the form", $method, $name);
            }
        }
    }
458769
public static function setSimpleDatetimeFields(
        array $fields,
        ClassMetadataBuilder $builder,
        $default = null
    ): void {
        if (null !== $default) {
            throw new \InvalidArgumentException('DateTime currently only support null as a default value');
        }
        foreach ($fields as $field) {
            $fieldBuilder = new FieldBuilder(
                $builder,
                [
                    'fieldName' => $field,
                    'type'      => Type::DATETIME_IMMUTABLE,
                    'default'   => $default,
                ]
            );
            $fieldBuilder
                ->columnName(self::getColumnNameForField($field))
                ->nullable(null === $default)
                ->build();
        }
    }
922804
public function __setSerialisablePropertyMap($propertyMap, $ignoreNoneWritableProperties = false)
    {


        // Always ignore any unknown properties in parent as we need to capture these for dynamic purposes
        $dynamicProperties = parent::__setSerialisablePropertyMap($propertyMap, true);

        // If none strict, simply merge all properties in the property map into the dynamic property map.
        if (!$this->__strictMode) {
            $this->__dynamicPropertyMap = array_merge($this->__dynamicPropertyMap, $dynamicProperties);
        } else {

            foreach ($dynamicProperties as $propertyName => $propertyValue) {
                try {
                    $this->__set($propertyName, $propertyValue);
                } catch (PropertyNotWritableException $e) {
                    if (!$ignoreNoneWritableProperties)
                        throw $e;
                }
            }

        }

    }
1182355
public static function setSimpleBooleanFields(
        array $fields,
        ClassMetadataBuilder $builder,
        $default = null
    ): void {
        if (null !== $default && !\is_bool($default)) {
            throw new \InvalidArgumentException(
                'Invalid default value ' . $default
                . ' with type ' . self::getType($default)
            );
        }
        foreach ($fields as $field) {
            $fieldBuilder = new FieldBuilder(
                $builder,
                [
                    'fieldName' => $field,
                    'type'      => Type::BOOLEAN,
                    'default'   => $default,
                ]
            );
            $fieldBuilder
                ->columnName(self::getColumnNameForField($field))
                ->nullable(null === $default)
                ->build();
        }
    }
596801
public function extend_fieldmap($map)
    {
        if (is_array($map)) {
            self::$fieldmap = array_merge($map, self::$fieldmap);
        }
    }
1276750
public function returns(array $callMap): ClassProxy
    {
        foreach (array_keys($callMap) as $method) {
            if (!isset($this->_allowedMethods[$method]) || isset($this->_voidMethods[$method])) {
                throw new \InvalidArgumentException(
                        $this->canNot('map', $method)
                );
            }
        }

        $this->callMap = new CallMap($callMap);
        return $this;
    }
1004441
public static function copyArray($srcArray,&$destArray,$fieldMap=[])
    {
        if(empty($fieldMap)){
            $destArray=$srcArray;
            return true;
        }else{
            $dim=count($fieldMap)==count($fieldMap,1);
            foreach ($fieldMap as $srcKey=>$destKey){
                if($dim){
                    $srcKey=$destKey;
                }
                $destArray[$destKey]=$srcArray[$srcKey];
            }
            return true;
        }
    }
947191
public function columns(array $columnsPropertyMap)
    {
        $this->verifyClassDefined(__METHOD__);
        $this->verifyMapperDefined(__METHOD__);

        $table         = $this->definition->getTable();
        $emptyFunction = function () {
        };

        foreach ($columnsPropertyMap as $column => $property) {
            if (!$table->hasColumn($column)) {
                throw InvalidArgumentException::format(
                    'Invalid column supplied to %s: \'%s\' does not exist on table \'%s\'',
                    __METHOD__, $column, $table->getName()
                );
            }

            if (is_string($property)) {
                $this->readDefinition
                    ->property($property)
                    ->to($column)
                    ->asType($table->findColumn($column)->getType());
            } else {
                $this->readDefinition
                    ->accessor($emptyFunction, $property)
                    ->to($column)
                    ->asType($table->findColumn($column)->getType());
            }
        }
    }
581417
protected function setFromTypes(array $params)
    {
        if (count($params) != count($this->valueMap)) {
            $numParams = count($params);
            $expectedParams = count($this->valueMap);
            throw new \InvalidArgumentException("Expected {$expectedParams} parameters, got {$numParams}");
        }
        
        foreach ($params as $key => $value) {
            if (is_object($value)) {
                if (!$value instanceof $this->valueMap[$key]['class']) {
                    $c = get_class($value);
                    throw new \InvalidArgumentException("Invalid Type ({$c}) at position {$key}");
                }
                $this->value[$this->valueMap[$key]['name']] = clone $value;
                continue;
            }
            $t = gettype($value);
            if ($t != $this->valueMap[$key]['class']) {
                throw new \InvalidArgumentException("Invalid Type ({$t}) at position {$key}");
            }
            $this->value[$this->valueMap[$key]['name']] = $value;
        }
    }
130092
public function post( $url, $postFields = null, $headers = array() ) {
		$this->assertString( 'url', $url );

		if ( !is_string( $postFields ) && !is_array( $postFields ) && !is_null( $postFields ) ) {
			throw new \InvalidArgumentException( '$postFields must be a string, array or null' );
		}

		if ( !isset( $this->conn ) ) {
			$this->connect();
		}

		$this->setCurlPostOpts( $url, $postFields, $headers );

		return $this->request();
	}
1231438
public function preparePrototype(FormField $field)
    {
        if (!$field->getOption('is_prototype')) {
            throw new \InvalidArgumentException(
                'Field ['.$field->getRealName().'] is not a valid prototype object.'
            );
        }

        $this->children = [];
        $this->children[] = $field;
    }
604711
public function mapColumns($columnMap)
    {
        if ($columnMap) {
            $lowerColumnMap = array();

            foreach ($columnMap as $k => $v) {
                $lowerColumnMap[strtolower($k)] = $v;
            }

            $this->columnMap = array_merge($this->columnMap, $lowerColumnMap);
        }
    }
113602
public function fields($fields) {
        if (!is_array($fields)) {
            $fields = func_get_args();
        }

        $this->_fields = $fields;

        return $this;
    }