/*!
Adds an enumeration
503575
function addEntry( $contentClassAttributeID, $contentClassID = false )
    {
        if ( !isset( $contentClassAttributeID ) )
        {
            return;
        }
        if ( !$contentClassID )
        {
            $contentClassAttribute = eZContentClassAttribute::fetch( $contentClassAttributeID );
            $contentClassID = $contentClassAttribute->attribute( 'contentclass_id' );
        }
        // Checking if $contentClassAttributeID and $contentClassID already exist (in Entries)
        foreach ( $this->Entries as $entrie )
        {
            if ( $entrie->attribute( 'contentclass_attribute_id' ) == $contentClassAttributeID and
                 $entrie->attribute( 'contentclass_id' ) == $contentClassID )
                return;
        }
        $waitUntilDateValue = eZWaitUntilDateValue::create( $this->WorkflowEventID, $this->WorkflowEventVersion, $contentClassAttributeID, $contentClassID );
        $waitUntilDateValue->store();
        $this->Entries = eZWaitUntilDateValue::fetchAllElements( $this->WorkflowEventID, $this->WorkflowEventVersion );
    }
365308
protected function lexEnumTypeExtension(): EnumTypeExtensionNode
    {
        $start = $this->lexer->getToken();

        $this->expectKeyword(KeywordEnum::EXTEND);
        $this->expectKeyword(KeywordEnum::ENUM);

        $name       = $this->lexName();
        $directives = $this->lexDirectives();
        $values     = $this->lexEnumValuesDefinition();

        if (empty($directives) && empty($values)) {
            throw $this->unexpected();
        }

        return new EnumTypeExtensionNode($name, $directives, $values, $this->createLocation($start));
    }
861984
private void enumerative( EnumDeclarationDescrBuilder declare ) {
        EnumLiteralDescrBuilder literal = null;
        String lit = null;
        try {
            Token enumLit = match( input,
                    DRL5Lexer.ID,
                    null,
                    null,
                    DroolsEditorType.IDENTIFIER );
            lit = enumLit.getText();
            if ( state.failed ) return;
        } catch ( RecognitionException re ) {
            reportError( re );
        }

        try {
            literal = helper.start( declare,
                    EnumLiteralDescrBuilder.class,
                    lit );

            if ( input.LA( 1 ) == DRL5Lexer.LEFT_PAREN ) {

                match( input,
                        DRL5Lexer.LEFT_PAREN,
                        null,
                        null,
                        DroolsEditorType.SYMBOL );
                if ( state.failed ) return;

                boolean more;
                
                do {
                    int first = input.index();
                    exprParser.conditionalExpression();
                    if ( state.failed ) return;
                    if ( state.backtracking == 0 && input.index() > first ) {
                        // expression consumed something
                        String arg = input.toString( first,
                                input.LT( -1 ).getTokenIndex() );
                        literal.constructorArg( arg );
                    }
                    more = input.LA( 1 ) == DRL5Lexer.COMMA;
                    if ( more ) {
                        match( input,
                                DRL5Lexer.COMMA,
                                null,
                                null,
                                DroolsEditorType.SYMBOL );

                    }
                    
                } while ( more );

                match( input,
                        DRL5Lexer.RIGHT_PAREN,
                        null,
                        null,
                        DroolsEditorType.SYMBOL );
                if ( state.failed ) return;


            }


        } catch ( RecognitionException re ) {
            reportError( re );
        } finally {
            helper.end( FieldDescrBuilder.class,
                    literal );
        }
    }
899938
function Enum(keys) {
  if (!(keys instanceof Array)) {
    throw new Error('Expected keys to be an array!');
  }

  const map = {};
  keys.forEach(key => {
    map[key] = key;
  });

  // ------------------------------------------------
  // Install an iterator that iterates over the
  // enum keys

  map[Symbol.iterator] = function() {
    let nextIndex = 0;

    const members = Object.values(map);

    return {
      next: function() {
        return nextIndex < keys.length ? {value: members[nextIndex++], done: false} : {done: true};
      },
    };
  };

  function testProperty(map, property) {
    if (!map[property]) {
      throw new Error(`Member '${property}' not found on the Enum.`);
    }
    return map[property];
  }

  const functions = {
    // ------------------------------------------------
    // Return an array of enums
    toArray: function() {
      return Object.values(map);
    },

    // ------------------------------------------------
    // Check if an enum key is valid
    isValid: function(key) {
      return map.hasOwnProperty(key);
    },

    // ------------------------------------------------
    // Enum to string
    toString: function() {
      return 'Enum{' + functions.toArray().join(', ') + '}';
    },
  };

  // ------------------------------------------------
  // Restrict reads and writes of properties to this
  // Enum object
  return new Proxy(map, {
    get: (target, property) => {
      if (functions[property]) {
        return functions[property];
      }
      return testProperty(map, property);
    },
    set: (target, property, value) => {
      throw new Error('Enum members may not be added.');
    },
  });
}
1191444
function addElement( $elementArray )
    {
        // Check if we're inside a list or table
        if ( $this->CurrentStackNumber == 0 )
        {
            $this->DocumentArray[] = $elementArray;
        }
        else
        {
            if ( $this->DocumentStack[$this->CurrentStackNumber]['Type'] == 'list' )
            {
                // Add the paragraph inside a list
                $currentChild = $this->DocumentStack[$this->CurrentStackNumber]['CurrentChild'];
                $this->DocumentStack[$this->CurrentStackNumber]['ChildArray'][$currentChild][] = $elementArray;
            }
            else
            {
                // Add the paragraph inside a table cell
                $currentRow = $this->DocumentStack[$this->CurrentStackNumber]['CurrentRow'];
                $currentCell = $this->DocumentStack[$this->CurrentStackNumber]['CurrentCell'];
                // Alex 2008-06-03 - Added isset()
                if ( isset( $this->DocumentStack[$this->CurrentStackNumber]['CurrentColSpan'] )
                     && is_numeric( $this->DocumentStack[$this->CurrentStackNumber]['CurrentColSpan'] ) )
                    $elementArray = array_merge( $elementArray, array( "ColSpan" => $this->DocumentStack[$this->CurrentStackNumber]['CurrentColSpan'] ) );
                $this->DocumentStack[$this->CurrentStackNumber]['ChildArray'][$currentRow][$currentCell][] = $elementArray;

            }
        }
    }
856257
function add_to_map($methodname, $in, $out)
    {
        $this->operations[$methodname] = ['name' => $methodname, 'in' => $in, 'out' => $out];
    }
1287177
function addArray($arr, &$n, $name=""){
		foreach ($arr as $key => $val){
			if (is_int($key)){
				if (strlen($name)>1){
					$newKey = blib_grammar::singular($name); //substr($name, 0, strlen($name)-1);
				}else{
					$newKey="item";
				}
			}else{
				$newKey = $key;
			}

			$node = $this->doc->createElement($newKey);
			if (is_array($val)){
				$this->addArray($arr[$key], $node, $key);
			}else{
				$nodeText = $this->doc->createTextNode($val);
				$node->appendChild($nodeText);
			}
			$n->appendChild($node);
		}
	}
958234
public function addValue($value)
    {
        if ($this->getValue($value) === null) {
            // issue #177, rare case: a struct and an enum has the same name and the enum is not detected by the SoapClient,
            // then we need to create the enumeration struct in order to deduplicate the two structs
            // this is why enumerations has to be parsed before any other elements by the WSDL parsers
            if (0 < $this->countOwnAttributes()) {
                $enum = new static($this->getGenerator(), $this->getName(), true, true);
                $enum
                    ->setInheritance(self::DEFAULT_ENUM_TYPE)
                    ->getValues()->add(new StructValue($enum->getGenerator(), $value, $enum->getValues()->count(), $enum));
                $this->getGenerator()->getStructs()->add($enum);
                return $enum;
            } else {
                $this
                    ->setStruct(true)
                    ->setRestriction(true)
                    ->values->add(new StructValue($this->getGenerator(), $value, $this->getValues()->count(), $this));
            }
        }
        return $this;
    }
1303931
function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode )
    {
        if ( $attributeNode->hasChildNodes() )
        {
            $contentObjectAttributeID = $objectAttribute->attribute( 'id' );
            $contentObjectAttributeVersion = $objectAttribute->attribute( 'version' );

            $enumNodes = $attributeNode->childNodes;
            foreach ( $enumNodes as $enumNode )
            {
                $eID      = $enumNode->getAttribute( 'id' );
                $eValue   = $enumNode->getAttribute( 'value' );
                $eElement = $enumNode->getAttribute( 'element' );

                eZEnum::storeObjectEnumeration( $contentObjectAttributeID,
                                                $contentObjectAttributeVersion,
                                                $eID,
                                                $eElement,
                                                $eValue );
            }
        }
        else
        {
            eZDebug::writeError( "Can't find attributes for enumeration", __METHOD__ );
        }
    }
65531
public function set($key, $value)
    {
        if (!is_null($key)
            && is_scalar($key)
        ) {
            return $this->_items[$key] = $value;
        } else {
            // given index name is not valid
            throw new EnumeratorException('Element could not be added to list. Index is not valid.', E_NOTICE);
        }
    }
244761
function enum_ (options) {
  options.hash.kind = 'member'
  options.hash.isEnum = true
  var result = _identifier(options)
  return result ? options.fn(result) : 'ERROR, Cannot find enum.'
}
11825
function addFilterRangeNumeric($form_field, $label, $db_field = null) {
        if(!$db_field) {
            $db_field = $form_field;
        }
        $gr = $this->form->putTbGroup($form_field)
            ->setLabel($label);
        $gr->putTbInt('from')
            ->setLabel('С')
            ->setWrapClass('col-md-6');
        $gr->putTbInt('to')
            ->setLabel('по')
            ->setWrapClass('col-md-6');
        $from = (float) \Input::get($form_field . '.from');
        $to   = (float) \Input::get($form_field . '.to');
        if($from) {
            $this->model->where(function ($query) use ($db_field, $from) {
                $query->where($db_field, '>=', $from);
            });
        }
        if($to) {
            $this->model->where(function ($query) use ($db_field, $to) {
                $query->where($db_field, '<=', $to);
            });
        }
    }
315415
public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
    {
        if (!is_array($data) || empty($data) || is_null($data['value'])) {
            return;
        }

        $list = new XMLElement($this->get('element_name'));

        if (!is_array($data['handle']) && !is_array($data['value'])) {
            $data = array(
                'handle'    => array($data['handle']),
                'value'     => array($data['value'])
            );
        }

        foreach ($data['value'] as $index => $value) {
            $list->appendChild(new XMLElement('item', General::sanitize($value), array(
                'handle' => $data['handle'][$index]
            )));
        }

        $wrapper->appendChild($list);
    }
342335
public static <T> void addAll(Collection<T> col, Enumeration<T> e) {
		while (e.hasMoreElements())
			col.add(e.nextElement());
	}
352410
function processChildren( &$textElements,
                              &$children, $key, &$item, &$index, &$isFirstRun,
                              &$delimiterStructure, &$sequenceStructure, &$filterStructure,
                              $tpl, $rootNamespace, $name, $functionPlacement,
                              &$variableIterator, $noLastValue,
                              &$iteratorData )
    {
        if ( $variableIterator !== null )
        {
            unset( $last );
            if ( !$noLastValue and $iteratorData['iterator'] !== false )
            {
                $last =& $iteratorData['iterator'];
            }
            else
            {
                $last = false;
            }
            unset( $iteratorData['iterator'] );
            $iteratorData['iterator'] = new eZTemplateSectionIterator();
            $iteratorData['iterator']->setIteratorValues( $item, $key, $index, $index + 1, false, $last );
            unset( $last );

            $iteratorObject =& $iteratorData['iterator'];
            $tpl->setVariable( $variableIterator, $iteratorObject, $name );
        }
        else
        {
            $tpl->setVariable( "key", $key, $name );
            $tpl->setVariable( "item", $item, $name );
            $tpl->setVariable( "index", $index, $name );
            $tpl->setVariable( "number", $index + 1, $name );
        }
        if ( count( $filterStructure ) > 0 )
        {
            $filterCount = count( $filterStructure );
            $includeElement = true;
            for ( $i = 0; $i < $filterCount; ++$i )
            {
                $filterElement =& $filterStructure[$i];
                $filterParameters =& $filterElement[3];
                $filterName = $filterElement[2];
                $filterMatch = null;
                if ( isset( $filterParameters["match"] ) )
                {
                    $filterMatch = $tpl->elementValue( $filterParameters["match"], $rootNamespace, $name, $functionPlacement );
                    if ( $filterMatch )
                        $includeElement = $filterName == "section-exclude" ? false : true;
                }
                else
                    $tpl->missingParameter( "section:$filterName", "match" );
            }
            if ( !$includeElement )
                return false;
        }
        if ( $delimiterStructure !== null and !$isFirstRun )
        {
            $delimiterParameters = $delimiterStructure[3];
            $delimiterMatch = true;
            if ( isset( $delimiterParameters["modulo"] ) )
            {
                $delimiterModulo = $delimiterParameters["modulo"];
                $modulo = $tpl->elementValue( $delimiterModulo, $rootNamespace, $name, $functionPlacement );
                $modulo = trim( $modulo );
                if ( is_numeric( $modulo ) )
                    $delimiterMatch = ( $index % $modulo ) == 0;
            }
            if ( isset( $delimiterParameters["match"] ) )
            {
                $delimiterMatchParameter = $delimiterParameters["match"];
                $delimiterMatch = $tpl->elementValue( $delimiterMatchParameter, $rootNamespace, $name, $functionPlacement );
            }
            if ( $delimiterMatch )
            {
                $delimiterChildren =& $delimiterStructure[1];
                if ( is_array( $delimiterChildren ) )
                {
                    foreach ( array_keys( $delimiterChildren ) as $delimiterChildKey )
                    {
                        $delimiterChild =& $delimiterChildren[$delimiterChildKey];
                        $tpl->processNode( $delimiterChild, $textElements, $rootNamespace, $name );
                    }
                }
            }
        }
        $isFirstRun = false;
        if ( $sequenceStructure !== null and is_array( $sequenceStructure ) )
        {
            $sequenceValue = array_shift( $sequenceStructure );
            if ( $variableIterator !== null )
            {
                $iteratorData['iterator']->setSequence( $sequenceValue );
            }
            else
            {
                $tpl->setVariable( "sequence", $sequenceValue, $name );
            }
            $sequenceStructure[] = $sequenceValue;
        }
        foreach ( array_keys( $children ) as $childKey )
        {
            $child =& $children[$childKey];
            $tpl->processNode( $child, $textElements, $rootNamespace, $name );
        }
        ++$index;
        return true;
    }
62582
protected function addEnumMethods(&$script)
    {
        foreach ($this->getTable()->getColumns() as $col) {
            /* @var $col Column */
            if ($col->isEnumType()) {
                $script .= "
    /**
     * Gets the SQL value for " . $col->getPhpName() . " ENUM value
     *
     * @param  string \$enumVal ENUM value to get SQL value for
     * @return int SQL value
     */
    public static function get{$col->getPhpName()}SqlValue(\$enumVal)
    {
        return {$this->getPeerClassname()}::getSqlValueForEnum({$this->getColumnConstant($col)}, \$enumVal);
    }
";
            }
        }
    }
284637
public static function addEnum(EnumId $enumId, EnumDescriptor $enum)
    {
        self::$enums[$enumId->toString()] = $enum;
        ksort(self::$enums);
    }