/*!
Processes the function with all it's children.
556945
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        $params = $functionParameters;
        switch ( $functionName )
        {
            case $this->BlockName:
            {
                $viewMode = "full";
                $name = $currentNamespace;
                // Read ini file
                $toolbarIni = eZINI::instance( "toolbar.ini" );

                if ( isset( $functionParameters["view"] ) )
                {
                    $viewMode = $tpl->elementValue( $functionParameters["view"], $rootNamespace, $currentNamespace, $functionPlacement );
                }

                if ( isset( $functionParameters["name"] ) )
                {
                    reset( $params );
                    $whatParamsShouldBeUnset = array();
                    $whatParamsShouldBeReplaced = array();
                    while ( ( $key = key( $params ) ) !== null )
                    {
                        $item =& $params[$key];
                        switch ( $key )
                        {
                            case "name":
                            case "view":
                                break;

                            default:
                            {
                                if ( !$tpl->hasVariable( $key, $name ) )
                                {
                                    $whatParamsShouldBeUnset[] = $key; // Tpl vars should be removed after including
                                }
                                else
                                {
                                    $whatParamsShouldBeReplaced[$key] = $tpl->variable( $key, $name ); // Tpl vars should be replaced after including
                                }

                                $item_value = $tpl->elementValue( $item, $rootNamespace, $currentNamespace, $functionPlacement );
                                $tpl->setVariable( $key, $item_value, $name );
                            } break;
                        }
                        next( $params );
                    }
                    $toolbarPosition = $tpl->elementValue( $functionParameters["name"], $rootNamespace, $currentNamespace, $functionPlacement );
                    $definedVariables = array();
                    $toolbarName = "Toolbar_" . $toolbarPosition;
                    $toolArray = $toolbarIni->variable( $toolbarName, 'Tool' );

                    if ( !is_array( $toolArray ) )
                        $toolArray = array();

                    $actionParameters = array();
                    foreach ( array_keys( $toolArray ) as $toolKey )
                    {
                        $definedVariables = array();
                        $tool = $toolArray[$toolKey];
                        $placement = $toolKey + 1;
                        if ( $toolbarIni->hasGroup( "Tool_" . $tool ) )
                        {
                            $actionParameters = $toolbarIni->group( "Tool_" . $tool );
                        }
                        if ( $toolbarIni->hasGroup( "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement ) )
                        {
                            $actionParameters = array_merge( $actionParameters, $toolbarIni->group( "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement ) );
                        }
                        foreach ( array_keys( $actionParameters ) as $key )
                        {
                            $itemValue = $actionParameters[$key];
                            $tpl->setVariable( $key, $itemValue, $name );
                            $definedVariables[] = $key;
                        }
                        $toolIDValue =  "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement;
                        $tpl->setVariable( "tool_id", $toolIDValue, $name );
                        $definedVariables[] = "tool_id";
                        $toolOffset = $placement;
                        $tpl->setVariable( "offset", $toolOffset, $name );
                        $definedVariables[] = "offset";
                        $uri = "design:toolbar/$viewMode/$tool.tpl";

                        if ( $placement == 1 )
                        {
                            if ( count( $toolArray ) == 1 )
                            {
                                $tpl->setVariable( "first", true );
                                $tpl->setVariable( "last", true );
                                $tpl->setVariable( "placement", "last" );
                                $definedVariables[] = "first";
                                $definedVariables[] = "last";
                                $definedVariables[] = "placement";
                            }
                            else
                            {
                                $tpl->setVariable( "first", true );
                                $tpl->setVariable( "last", false );
                                $tpl->setVariable( "placement", "first" );
                                $definedVariables[] = "first";
                                $definedVariables[] = "last";
                                $definedVariables[] = "placement";
                            }
                        }
                        else if ( $placement == count( $toolArray ) )
                        {
                            $tpl->setVariable( "first", false );
                            $tpl->setVariable( "last", true );
                            $tpl->setVariable( "placement", "last" );
                            $definedVariables[] = "first";
                            $definedVariables[] = "last";
                            $definedVariables[] = "placement";
                        }
                        else
                        {
                            $tpl->setVariable( "first", false );
                            $tpl->setVariable( "last",  false );
                            $tpl->setVariable( "placement", "" );
                            $definedVariables[] = "placement";
                        }
                        $tpl->processURI( $uri, true, $extraParameters, $textElements, $name, $name );
                        // unset var
                        foreach ( $whatParamsShouldBeUnset as $key )
                        {
                            $tpl->unsetVariable( $key, $name );
                        }
                        // replace var
                        foreach ( $whatParamsShouldBeReplaced as $key => $item_value )
                        {
                            $tpl->setVariable( $key, $item_value, $name );
                        }
                    }
                }
            }
        }
    }
100082
static function processNodeTransformationRoot( $useComments, $php, $tpl, &$node, &$resourceData )
    {
        $nodeType = $node[0];
        if ( $nodeType == eZTemplate::NODE_ROOT )
        {
            $children = $node[1];
            $newNode = array( $nodeType,
                              false );
            if ( $children )
            {
                $newChildren = array();
                foreach ( $children as $childNode )
                {
                    $newChildNode = eZTemplateCompiler::processNodeTransformationChild( $useComments, $php, $tpl, $childNode, $resourceData );
                    if ( !$newChildNode )
                        $newChildren[] = $childNode;
                    else
                        $newChildren = array_merge( $newChildren, $newChildNode );
                }
                if ( count( $newChildren ) > 0 )
                    $newNode[1] = $newChildren;
            }
            return $newNode;
        }
        else
            $tpl->error( 'processNodeTransformation', "Unknown root type $nodeType, should be " . eZTemplate::NODE_ROOT );
        return false;
    }
547943
def process(self):
        
        children = len(self.living_children)
        LOGGER.debug('%i active child%s',
                     children, '' if children == 1 else 'ren')
858421
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        $params = $functionParameters;
        switch ( $functionName )
        {
            case $this->BlockName:
            {
                $name ="";
                $menuIni = eZINI::instance( "menu.ini" );

                if ( isset( $functionParameters["name"] ) )
                {
                    $menuName = $tpl->elementValue( $functionParameters["name"], $rootNamespace, $currentNamespace, $functionPlacement );
                    if ( $menuIni->hasVariable( 'SelectedMenu', $menuName ) )
                    {
                        $menuTemplate = $menuIni->variable( 'SelectedMenu', $menuName );
                        if ( $menuTemplate != null )
                        {
                            $uri = "design:menu/$menuTemplate.tpl";
                            $tpl->processURI( $uri, true, $extraParameters, $textElements, $name, $name );
                        }
                    }
                }
            }
        }
    }
1299165
public void processAllChildren(TObjectProcedure<Cluster<T>> procedure) {
        if (children == null)
            return;
        for (Cluster<T> child : children) {
            procedure.execute(child);
            child.processAllChildren(procedure);
        }
    }
972519
function (theparent) {
            if (this.parent() !== null)
                this.detach();
            var children = theparent.children();
            children.push(this);
            theparent.children(children);
            this.parent(theparent);
        }
78375
function(child) {
            if (arguments.length > 1) {
                for (var i = 0; i < arguments.length; i++) {
                    this.add(arguments[i]);
                }
                return;
            }
            if (child.getParent()) {
                child.moveTo(this);
                return;
            }
            var children = this.children;
            this._validateAdd(child);
            child.index = children.length;
            child.parent = this;
            children.push(child);
            this._fire('add', {
                child: child
            });

            // chainable
            return this;
        }
1125827
function processBySchemaTree( $element )
    {
        $parent = $element->parentNode;

        if ( $parent instanceof DOMElement )
        {
            $schemaCheckResult = $this->XMLSchema->check( $parent, $element );
            if ( !$schemaCheckResult )
            {
                if ( $schemaCheckResult === false )
                {
                    // Remove indenting spaces
                    if ( $element->nodeType == XML_TEXT_NODE && !trim( $element->textContent ) )
                    {
                        $element = $parent->removeChild( $element );
                        return false;
                    }

                    $elementName = $element->nodeType == XML_ELEMENT_NODE ? '&lt;' . $element->nodeName . '&gt;' : $element->nodeName;
                    $this->handleError( self::ERROR_SCHEMA, ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', "%1 is not allowed to be a child of &lt;%2&gt;.",
                                        false, array( $elementName, $parent->nodeName ) ) );
                }
                $this->fixSubtree( $element, $element );
                return false;
            }
        }
        // TODO: break processing of any node that doesn't have parent
        //       and is not a root node.
        elseif ( $element->nodeName != 'section' )
        {
            return false;
        }
        return true;
    }
1054079
public function process_child( $type ) {

		if ( isset( $this->struct[ $type ]['id'] ) ) {
			$this->{$type}( $this->struct[ $type ]['id'], $this->struct[ $type ] );
		} else {
			$this->process_children( $type );
		}

	}
113327
function process(node) {
          var children, i, l, lastContentEditable, hasContentEditableState;

          // Node has a contentEditable value
          if (node.nodeType === 1 && getContentEditable(node)) {
            lastContentEditable = contentEditable;
            contentEditable = getContentEditable(node) === "true";
            hasContentEditableState = true; // We don't want to wrap the container only it's children
          }

          // Grab the children first since the nodelist might be changed
          children = grep(node.childNodes);

          // Process current node
          if (contentEditable && !hasContentEditableState) {
            for (i = 0, l = formatList.length; i < l; i++) {
              if (removeFormat(formatList[i], vars, node, node)) {
                break;
              }
            }
          }

          // Process the children
          if (format.deep) {
            if (children.length) {
              for (i = 0, l = children.length; i < l; i++) {
                process(children[i]);
              }

              if (hasContentEditableState) {
                contentEditable = lastContentEditable; // Restore last contentEditable state from stack
              }
            }
          }
        }
578025
public function process()
        {
            if ($this->_isXhtml === null) {
                $this->_isXhtml = (false !== strpos($this->_html, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML'));
            }

            $this->_replacementHash = 'MINIFYHTML' . md5($_SERVER['REQUEST_TIME']);
            $this->_placeholders = array();

            // replace SCRIPTs (and minify) with placeholders
            $this->_html = preg_replace_callback(
                    '/(\\s*)(<script\\b[^>]*?>)([\\s\\S]*?)<\\/script>(\\s*)/i'
                    , array($this, '_removeScriptCB')
                    , $this->_html);

            // replace STYLEs (and minify) with placeholders
            $this->_html = preg_replace_callback(
                    '/\\s*(<style\\b[^>]*?>)([\\s\\S]*?)<\\/style>\\s*/i'
                    , array($this, '_removeStyleCB')
                    , $this->_html);

            // remove HTML comments (not containing IE conditional comments).
            $this->_html = preg_replace_callback(
                    '/<!--([\\s\\S]*?)-->/'
                    , array($this, '_commentCB')
                    , $this->_html);

            // replace PREs with placeholders
            $this->_html = preg_replace_callback('/\\s*(<pre\\b[^>]*?>[\\s\\S]*?<\\/pre>)\\s*/i'
                    , array($this, '_removePreCB')
                    , $this->_html);

            // replace TEXTAREAs with placeholders
            $this->_html = preg_replace_callback(
                    '/\\s*(<textarea\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/i'
                    , array($this, '_removeTextareaCB')
                    , $this->_html);

            // trim each line.
            // @todo take into account attribute values that span multiple lines.
            $this->_html = preg_replace('/^\\s+|\\s+$/m', '', $this->_html);

            // remove ws around block/undisplayed elements
            $this->_html = preg_replace('/\\s+(<\\/?(?:area|base(?:font)?|blockquote|body'
                    . '|caption|center|cite|col(?:group)?|dd|dir|div|dl|dt|fieldset|form'
                    . '|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta'
                    . '|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)'
                    . '|ul)\\b[^>]*>)/i', '$1', $this->_html);

            // remove ws outside of all elements
            $this->_html = preg_replace_callback(
                    '/>([^<]+)</'
                    , array($this, '_outsideTagCB')
                    , $this->_html);

            // use newlines before 1st attribute in open tags (to limit line lengths)
            $this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);

            // fill placeholders
            $this->_html = str_replace(
                    array_keys($this->_placeholders)
                    , array_values($this->_placeholders)
                    , $this->_html
            );

            return $this->_html;
        }
853518
protected function _processChildren($method, $childField, $row, $postData)
    {
        if ($method == 'load') return true;
        if ($this->_checkboxHiddenField && $childField !== $this->_checkboxHiddenField) {
            $n = $this->_checkboxHiddenField->getFieldName();
            if (isset($postData[$n]) && $postData[$n]) {
                return true;
            } else {
                return false;
            }
        }
        return true;
    }
1001006
function flattenChildren(children) {
  if (children == null) {
    return children;
  }
  var result = {};
  traverseAllChildren(children, flattenSingleChildIntoContext, result);
  return result;
}
888436
function doFunction( $name, $func_obj, $nspace, $current_nspace )
    {
        $func = $this->Functions[$name];
        if ( is_array( $func ) )
        {
            $this->loadAndRegisterFunctions( $this->Functions[$name] );
            $func = $this->Functions[$name];
        }
        if ( isset( $func ) and
             is_object( $func ) )
        {
            return $func->process( $this, $name, $func_obj, $nspace, $current_nspace );
        }
        else
        {
            $this->warning( "", "Function \"$name\" is not registered" );
            return false;
        }
    }
299402
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        if ( count( $functionParameters ) == 0 )
        {
            eZDebug::writeError( "Not enough arguments passed to 'while' function." );
            return;
        }

        $loop = new eZTemplateLoop( eZTemplateWhileFunction::FUNCTION_NAME,
                                    $functionParameters, $functionChildren, $functionPlacement,
                                    $tpl, $textElements, $rootNamespace, $currentNamespace );

        if ( !$loop->initialized() )
            return;

        while ( $tpl->elementValue( $functionParameters['condition'], $rootNamespace, $currentNamespace, $functionPlacement ) )
        {
            $loop->setSequenceVar(); // set sequence variable (if specified)
            $loop->processDelimiter();
            $loop->resetIteration();

            if ( $loop->processChildren() )
                break;

            $loop->incrementSequence();
        }

        $loop->cleanup();
    }
1045924
private function _processFunctionStatement() {
		// Increment the number of functions
		$this->_ncssTotalFunctions ++;
		$this->_ncssFileFunctions ++;

		// Reset the default values
		$this->funcArgString = "";
		$this->_nbFunctionParameters = 0;
		$this->_functionParameters = array();
		$this->_inFunctionStatement = true;
		$this->_functionReturns = false;
		$this->_functionThrows = false;
		$this->_inControlStatement = false;
		$this->_currentStatement = false;
		$this->_inClassStatement = false;
		$this->_inInterfaceStatement = false;
		$this->_functionVisibility = 'PUBLIC';
		$this->_functionStatic = false;

		// Detect the visibility (on the token just before the current one).
		$previousToken = $this->tokenizer->peekPrvsValidToken();
		$this->_detectVisibility($previousToken);
		if ($previousToken->position > 1) {
			$prepreviousToken = $this->tokenizer->peekPrvsValidToken($previousToken->position - 1);
			$this->_detectVisibility($prepreviousToken);
		}

		// Find the function name
		$currentToken = $this->tokenizer->getCurrentToken();
		$curlyOpeningDetected = $this->tokenizer->checkNextToken(T_PARENTHESIS_OPEN);
		$nameDetected = null;
		while ($currentToken !== null && !$curlyOpeningDetected) {
			// Skip the token
			$this->tokenizer->getNextToken();
			$currentToken = $this->tokenizer->getCurrentToken();

			if ($currentToken->id === T_STRING) {
				$nameDetected = $currentToken->text;
			}
			$curlyOpeningDetected = $this->tokenizer->checkNextValidToken(T_PARENTHESIS_OPEN);
		}

		// currentToken should end up being the function name token

		// Tracking the function's name.
		if ($nameDetected !== null && trim($nameDetected) !== "") {
			$functionName = $currentToken->text;

			// Check the PHPDoc presence
			$this->_checkDocExists(T_FUNCTION);
		} else {
			// We have an anonymous function or closure.
			$functionName = 'anonymous';
			$this->_functionVisibility = 'ANONYMOUS';

			// We don't check the PHPDoc for anonymous functions
		}
		$this->_currentFunctionName = $functionName;

		// If the function is private we add it to the list of function to use (and store the line number)
		if ($this->_functionVisibility === 'PRIVATE') {
			$this->_privateFunctions[$functionName] = $functionName;
			$this->_privateFunctionsStartLines[$functionName] = $currentToken->line;
		}

		// Function is a constructor
		$constructorNamingStyle = $this->_config->getTestProperty('constructorNaming', 'naming');
		$useOldConstructorNamingStyle = ($constructorNamingStyle === 'old');
		$useNewConstructorNamingStyle = ($constructorNamingStyle === 'new');
		if (strtolower($functionName) === "__construct" && $this->_isActive('constructorNaming') && $useOldConstructorNamingStyle) {
			$msg = $this->_getMessage('CONSTRUCTOR_NAMING', $this->_currentClassname);

			$this->_writeError('constructorNaming', $msg);
		}

		// Special functions are not checked
		if (!in_array($functionName, $this->_specialFunctions)) {

			// Constructors
			if ($functionName === $this->_currentClassname) {

				// Function is a constructor
				if ($this->_isActive('constructorNaming') && $useNewConstructorNamingStyle) {
					$msg = $this->_getMessage('CONSTRUCTOR_NAMING', '__construct()');
					$this->_writeError('constructorNaming', $msg);
				}
			} else {

				// Other function
				if ($this->_functionVisibility === 'PRIVATE') {
					$this->_checkPrivateFunctionNaming($this->_currentFunctionName);
				} else if ($this->_functionVisibility === 'PROTECTED') {
					$this->_checkProtectedFunctionNaming($this->_currentFunctionName);
				} else {
					$this->_checkFunctionNaming($this->_currentFunctionName);
				}
			}
		}

		// List the arguments of the currently analyzed function.
		// Check the order of the parameters of the function.
		// The parameters having a default value should be in last position.
		$foundDefaultValues = false;
		$functionTokenPosition = $this->tokenizer->getCurrentPosition();

		$functionParamsStart = $this->tokenizer->findNextStringPosition('(', $functionTokenPosition);
		$functionParamsStop = $this->tokenizer->findClosingParenthesisPosition($functionTokenPosition);

		for ($i = $functionParamsStart; $i < $functionParamsStop; $i ++) {
			$functionToken = $this->tokenizer->peekTokenAt($i);

			// Current token is a parameter
			if ($this->tokenizer->checkToken($functionToken, T_VARIABLE)) {
				$this->_nbFunctionParameters ++;
				$parameterName = $functionToken->text;
				$this->_functionParameters[$parameterName] = "unused"; // We flag the parameter as unused

				// Check is this parameter as a default value
				$nextTokenInfo = $this->tokenizer->peekNextValidToken($i + 1);
				$hasDefaultValue = $this->tokenizer->checkToken($nextTokenInfo, T_EQUAL);
				if ($hasDefaultValue) {
					$foundDefaultValues = true;
				}

				// Check if the parameter has a default value
				if ($this->_isActive('defaultValuesOrder')) {
					if ($foundDefaultValues && !$hasDefaultValue) {
						$this->_writeError('defaultValuesOrder', $this->_getMessage('FUNC_DEFAULTVALUE_ORDER'));
						break;
					}
				}
			}
		}

		// Test for the max number of parameters
		if ($this->_isActive('functionMaxParameters')) {
			$paramCount = $this->_nbFunctionParameters;
			$maxParams = $this->_config->getTestProperty('functionMaxParameters', 'maxParameters');
			if ($paramCount > $maxParams) {
				$msg = $this->_getMessage('MAX_PARAMETERS', $this->_currentFunctionName, $paramCount, $maxParams);
				$this->_writeError('functionMaxParameters', $msg);
			}
		}
	}
693003
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        $undef = ( $functionName == eZTemplateDefFunction::UNDEF_FUNCTION_NAME ) ? true : false;

        if ( $undef && !count( $functionParameters ) ) // if {undef} called w/o arguments
        {
            // destroy all variables defined in the current template using {def}
            $tpl->unsetLocalVariables();
        }

        foreach ( array_keys( $functionParameters ) as $key )
        {
            $varName  = $key;
            $param    = $functionParameters[$varName];
            $varValue = $tpl->elementValue( $param, $rootNamespace, $currentNamespace, $functionPlacement );


            if ( $undef ) // {undef}
            {
                if ( !$tpl->hasLocalVariable( $varName, $rootNamespace ) )
                    $tpl->warning( eZTemplateDefFunction::UNDEF_FUNCTION_NAME, "Variable '$varName' is not defined with {def}.", $functionPlacement );
                else
                    $tpl->unsetLocalVariable( $varName, $rootNamespace );

            }
            else // {def}
            {
                if ( $tpl->hasVariable( $varName, $rootNamespace ) ) // if the variable already exists
                {
                    // we don't create new variable but just assign value to the existing one.
                    $tpl->warning( eZTemplateDefFunction::DEF_FUNCTION_NAME, "Variable '$varName' is already defined.", $functionPlacement );
                    $tpl->setVariable( $varName, $varValue, $rootNamespace );
                }
                else
                    // create a new local variable and assign a value to it.
                    $tpl->setLocalVariable( $varName, $varValue, $rootNamespace );

            }
        }
    }