{@inheritdoc}

@throws \RuntimeException when fields structure is invalid
552065
public function getRequirements()
    {
        $fields = $this->application->getConfig()->get('table-pr') ?: [];
        $fields['description'] = ['Description', ''];

        if (count($fields) < 2) {
            throw new \RuntimeException(
                'table-pr structure requires at least one row, please check your local .gush.yml'
            );
        }

        foreach ($fields as $name => $rowData) {
            if (!is_string($name)) {
                throw new \RuntimeException(
                    'table-pr table row-name must be a string, please check your local .gush.yml'
                );
            }

            if (!is_array($rowData) || count($rowData) != 2) {
                throw new \RuntimeException(
                    sprintf(
                        'table-pr table row-data "%s" must be an array with at least two values like: '.
                        '[Label, default value].'.PHP_EOL.'please check your local .gush.yml',
                        $name
                    )
                );
            }
        }

        return $fields;
    }
291327
public function updateNonTranslatableField(
        Field $field,
        StorageFieldValue $value,
        $contentId
    ) {
        try {
            return $this->innerGateway->updateNonTranslatableField($field, $value, $contentId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1310411
protected function assignFields($fields)
    {
        foreach ($fields as $field) {
            if (!$field instanceof FieldInterface) {
                throw new ModelException(sprintf('Field must be an instance of FieldInterface, got "%s"', $this->getType($field)));
            }

            $field->table($this->table);
            $this->fields[$field->name()] = $field;
        }
    }
1067706
public function obj()
    {
        if ($this->obj === null) {
            $formGroup = $this->formGroup();
            if ($formGroup instanceof self) {
                $prop = $formGroup->storageProperty();
                $val  = $formGroup->obj()->propertyValue($prop->ident());

                $this->obj = $prop->structureVal($val, [ 'default_data' => true ]);
                if ($this->obj === null) {
                    $this->obj = clone $prop->structureProto();
                }
            } elseif ($this->form() instanceof ObjectContainerInterface) {
                $this->obj = $this->form()->obj();
            }

            if ($this->obj === null) {
                throw new RuntimeException(sprintf(
                    'The [%1$s] widget has no data model.',
                    static::CLASS
                ));
            }
        }

        return $this->obj;
    }
267880
public function setFields($fields): self
    {
        if (!is_iterable($fields)) {
            throw new Exception(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($fields)));
        }

        $this->fields = [];
        foreach ($fields as $field) {
            $this->addField(...$field);
        }

        return $this;
    }
875225
protected function validateEditFieldValue()
    {
        $this->setSubmitted('field_value');
        $this->setSubmitted('update', $this->data_field_value);
        $this->setSubmitted('field_id', $this->data_field['field_id']);

        $this->validateComponent('field_value');

        return !$this->hasErrors();
    }
668815
public function insertEscaped(...$field_values)
    {
        if ($this->is_done) {
            throw new RuntimeException('This batch insert is already done');
        }

        if (count($field_values) == $this->fields_num) {
            $this->rows[] = '(' . implode(', ', $field_values) . ')';

            $this->checkAndInsert();
        } else {
            throw new BadMethodCallException('Number of arguments does not match number of fields');
        }
    }
1278355
public function addField($field)
    {
        if (!$field instanceof Base) {
            throw new \InvalidArgumentException(
                "No valid object passed to Fieldset::addField(). " .
                "Object should be an instance of \\ValidFormBuilder\\Base.",
                E_ERROR
            );
        }

        $this->__fields->addObject($field);

        // Set parent element hard, overwrite if previously set.
        $field->setMeta("parent", $this, true);

        if ($field->isDynamic() && get_class($field) !== "ValidFormBuilder\\MultiField"
            && get_class($field) !== "ValidFormBuilder\\Area"
        ) {
            $objHidden = new Hidden($field->getId() . "_dynamic", ValidForm::VFORM_INTEGER, array(
                "default" => 0,
                "dynamicCounter" => true
            ));

            $this->__fields->addObject($objHidden);

            $field->setDynamicCounter($objHidden);
        }
    }
1074055
public function setIn($keys, $value)
    {
        $lastKey = array_shift($keys);
        if (count($keys) > 0 && !isset($this->$lastKey->{$keys[0]})) {
            throw new \RuntimeException(sprintf("Key '%s->%s' does not exist.", $lastKey, $keys[0]));
        }
        if (count($keys) > 0 && $this->$lastKey instanceof Map) {
            return $this->merge(new self(array($lastKey => $this->$lastKey->setIn($keys, $value))));
        }
        return $this->merge(new self(array($lastKey => $value)));
    }
976020
public function validate($mInput, $oField)
    {
        $mInput = parent::validate($mInput, $oField);

        if (!is_numeric($mInput)) {
            throw new FieldTypeException('This field should be numeric.', 1);
        }

        return $mInput;
    }
259798
protected function validate()
    {
        /** @var Parameter[] $missingItems */
        $missingItems = \array_filter($this->_options + $this->_arguments, function ($item) {
            /* @var Parameter $item */
            return $item->required() && \in_array($this->_values[$item->attributeName()], [null, []]);
        });

        foreach ($missingItems as $item) {
            list($name, $label) = [$item->name(), 'Argument'];
            if ($item instanceof Option) {
                list($name, $label) = [$item->long(), 'Option'];
            }

            throw new RuntimeException(
                \sprintf('%s "%s" is required', $label, $name)
            );
        }
    }
901866
public function filterFields(FieldBag $fields)
    {
        $allFields = $this->getModule()->getOption('model_fields');

        $filteredFields = new FieldBag();
        foreach ($fields as $name => $field) {
            if (!$allFields->has($name)) {
                throw new \RuntimeException(sprintf('The field "%s" does not exist.', $name));
            }

            $filteredField = clone $field;
            foreach ($allFields->get($name)->getOptions() as $optionName => $optionValue) {
                if (!$filteredField->hasOption($optionName)) {
                    $filteredField->setOption($optionName, $optionValue);
                }
            }

            $filteredFields->set($name, $filteredField);
        }

        return $filteredFields;
    }
1345187
protected function _resolveFields($fields)
    {
        if (is_string($fields)) {
            $fields = [$fields];
        }

        if (!is_array($fields)) {
            throw new Exception('Invalid "fields" configuration.');
        }

        $types = array_keys(Type::map());

        foreach ($fields as $field => $type) {
            if (is_numeric($field) && is_string($type)) {
                unset($fields[$field]);
                $field = $type;
                $type = self::DEFAULT_TYPE;
                $fields[$field] = $type;
            }

            if (!in_array($type, $types)) {
                throw new Exception(sprintf('The field "%s" mapped type "%s" was not found.', $field, $type));
            }
        }

        return $fields;
    }
868574
public function Unserialize($Fields = array('Attributes', 'Data')) {
      $Result =& $this->Result();
      $First = TRUE;
      
      foreach ($Result as $Row) {
         if ($First) {
            // Check which fields are in the dataset.
            foreach ($Fields as $Index => $Field) {
               if (GetValue($Field, $Row, FALSE) === FALSE) {
                  unset($Fields[$Index]);
               }
            }
            $First = FALSE;
         }
         
         foreach ($Fields as $Field) {
            if (is_object($Row)) {
               if (is_string($Row->$Field))
                  $Row->$Field = @unserialize($Row->$Field);
            } else {
               if (is_string($Row[$Field]))
                  $Row[$Field] = @unserialize($Row[$Field]);
            }
         }
      }
   }
25806
private function bindFields()
    {
        foreach ($this->fields as $key => $value) {
            $this->statement->bindValue(':' . $key, $value);
        }
    }
609513
public function setFields($table, $fields = array("*")){

		//put this in try...catch block for better error handling
		try{

			//check if from is empty
			if ( empty($table)) 
			{
				//throw new exception
				throw new MySQLException("Invalid argument passed for table name", 1);

			}

		}

		//diplay error message
		catch(MySQLException $MySQLExceptionObject){

			//display error message
			$MySQLExceptionObject->errorShow();

		}		

		//check if fields is sset and set the fields param
		$this->froms = $table;
		$this->fields[$table] = $fields;
	}
818923
protected function getFields(): array {
    if (!$this->fields) {
      // Search the pattern for named subpatterns and get their names.
      // @link https://stackoverflow.com/a/47753964/3260408
      preg_match_all("~(?<!\\\\)(?:\\\\{2})*\(\?(?|P?<([_A-Za-z]\w{0,31})>|'([_A-Za-z]\w{0,31})')~", $this->getPattern(), $matches);
      $this->fields = $matches[1];

      if (!$this->fields) {
        throw new \RuntimeException('Pattern must contain named subpatterns.');
      }
      if (count(array_unique($this->fields)) != count($this->fields)) {
        throw new \RuntimeException('Subpattern names must be unique.');
      }
    }

    return $this->fields;
  }