Creates a new instance of NodeFactory with default Parser ands Traverser.

@param int $kind One of ParserFactory::PREFER_PHP7,
ParserFactory::PREFER_PHP5, ParserFactory::ONLY_PHP7 or ParserFactory::ONLY_PHP5
@return static
488549
public static function createInstance($kind = ParserFactory::PREFER_PHP7): self
    {
        $parser = (new ParserFactory())->create($kind);
        $traverser = new NodeTraverser();
        $traverser->addVisitor(new NameResolver());
        $traverser->addVisitor(new ElementNameResolver());
        return new static($parser, $traverser);
    }
670719
public function CloneInstance()
	{
		$result = new SpecialDescendantNodeIterator();
		$result->AssignFrom( $this );
		$result->kind = $this->kind;
		return $result;
	}
500443
public function getConfigTreeBuilder()
    {
        // Solves Symfony 4.2 TreeBuilder deprecation
        if (method_exists(TreeBuilder::class, 'getRootNode')) {
            $treeBuilder = new TreeBuilder('knp_gaufrette');
            $rootNode    = $treeBuilder->getRootNode();
        } else {
            $treeBuilder = new TreeBuilder();
            $rootNode    = $treeBuilder->root('knp_gaufrette');
        }

        $this->addAdaptersSection($rootNode, $this->factories);
        $this->addFilesystemsSection($rootNode);
        $this->addStreamWrapperSection($rootNode);

        $rootNode
            // add a faux-entry for factories, so that no validation error is thrown
            ->fixXmlConfig('factory', 'factories')
            ->children()
                ->arrayNode('factories')->ignoreExtraKeys()->end()
            ->end()
        ;

        return $treeBuilder;
    }
783166
public static function fromSymbolKind(int $kind): int
    {
        switch ($kind) {
            case SymbolKind::PROPERTY:
            case SymbolKind::FIELD:
                return self::PROPERTY;
            case SymbolKind::METHOD:
                return self::METHOD;
            case SymbolKind::CLASS_:
                return self::CLASS_;
            case SymbolKind::INTERFACE:
                return self::INTERFACE;
            case SymbolKind::FUNCTION:
                return self::FUNCTION;
            case SymbolKind::NAMESPACE:
            case SymbolKind::MODULE:
            case SymbolKind::PACKAGE:
                return self::MODULE;
            case SymbolKind::FILE:
                return self::FILE;
            case SymbolKind::STRING:
                return self::TEXT;
            case SymbolKind::NUMBER:
            case SymbolKind::BOOLEAN:
            case SymbolKind::ARRAY:
                return self::VALUE;
            case SymbolKind::ENUM:
                return self::ENUM;
            case SymbolKind::CONSTRUCTOR:
                return self::CONSTRUCTOR;
            case SymbolKind::VARIABLE:
            case SymbolKind::CONSTANT:
                return self::VARIABLE;
        }
    }
873266
public static function newWithType($locale, $type)
    {
        $nodeSource = new static();

        $sourceModel = $nodeSource->getNewSourceModel($type);

        // We temporarily cache the model since Eloquent does not
        // have a way to attach hasOne relations without saving them.
        // So we are providing a customized way to emulate that.
        // We will always access the source model through getSource() method.
        $nodeSource->setTemporarySource($sourceModel);

        // We first fill special attributes.
        // These have to be done after we have added the temporary source
        // since the setAttribute will look at the temporary source as well.
        $nodeSource->setAttribute('locale', $locale);
        $nodeSource->setAttribute('source_type', $type);

        return $nodeSource;
    }
586496
public function getSearchFactory(): SearchFactory
    {
        $extensions = $this->extensions;

        if (\count($this->types) > 0 || \count($this->typeExtensions) > 0) {
            $extensions[] = new PreloadedExtension($this->types, $this->typeExtensions);
        }

        $resolvedTypeFactory = $this->resolvedTypeFactory ?? new GenericResolvedFieldTypeFactory();
        $registry = new GenericTypeRegistry($extensions, $resolvedTypeFactory);

        return new GenericSearchFactory($registry, $this->fieldSetRegistry ?? LazyFieldSetRegistry::create());
    }
309085
private function createClientsNode() : ArrayNodeDefinition
    {
        $builder = new TreeBuilder('clients');

        /** @var \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node */
        if (method_exists($builder, 'getRootNode')) {
            $node = $builder->getRootNode();
        } else {
            // BC layer for symfony/config 4.1 and older
            $node = $builder->root('clients');
        }

        /** @var \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeChildren */
        $nodeChildren = $node->useAttributeAsKey('name')
            ->prototype('array')
                ->children();

        $nodeChildren->scalarNode('class')->defaultValue('%eight_points_guzzle.http_client.class%')->end()
                    ->scalarNode('base_url')
                        ->defaultValue(null)
                        ->validate()
                            ->ifTrue(function ($v) {
                                return !is_string($v);
                            })
                            ->thenInvalid('base_url can be: string')
                        ->end()
                    ->end()
                    ->booleanNode('lazy')->defaultValue(false)->end()
                    ->scalarNode('handler')
                        ->defaultValue(null)
                        ->validate()
                            ->ifTrue(function ($v) {
                                return $v !== null && (!is_string($v) || !class_exists($v));
                            })
                            ->thenInvalid('handler must be a valid FQCN for a loaded class')
                        ->end()
                    ->end()
                    ->arrayNode('options')
                        ->validate()
                            ->ifTrue(function ($options) {
                                return count($options['form_params']) && count($options['multipart']);
                            })
                            ->thenInvalid('You cannot use form_params and multipart at the same time.')
                        ->end()
                        ->children()
                            ->arrayNode('headers')
                                ->useAttributeAsKey('name')
                                ->normalizeKeys(false)
                                ->prototype('scalar')->end()
                            ->end()
                            ->variableNode('allow_redirects')
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_array($v) && !is_bool($v);
                                    })
                                    ->thenInvalid('allow_redirects can be: bool or array')
                                ->end()
                            ->end()
                            ->variableNode('auth')
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_array($v) && !is_string($v);
                                    })
                                    ->thenInvalid('auth can be: string or array')
                                ->end()
                            ->end()
                            ->variableNode('query')
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_string($v) && !is_array($v);
                                    })
                                    ->thenInvalid('query can be: string or array')
                                ->end()
                            ->end()
                            ->arrayNode('curl')
                                ->beforeNormalization()
                                    ->ifArray()
                                        ->then(function (array $curlOptions) {
                                            $result = [];

                                            foreach ($curlOptions as $key => $value) {
                                                $optionName = 'CURLOPT_' . strtoupper($key);

                                                if (!defined($optionName)) {
                                                    throw new InvalidConfigurationException(sprintf(
                                                        'Invalid curl option in eight_points_guzzle: %s. ' .
                                                        'Ex: use sslversion for CURLOPT_SSLVERSION option. ' . PHP_EOL .
                                                        'See all available options: http://php.net/manual/en/function.curl-setopt.php',
                                                        $key
                                                    ));
                                                }

                                                $result[constant($optionName)] = $value;
                                            }

                                            return $result;
                                        })
                                    ->end()
                                    ->prototype('scalar')
                                ->end()
                            ->end()
                            ->variableNode('cert')
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_string($v) && (!is_array($v) || count($v) !== 2);
                                    })
                                    ->thenInvalid('cert can be: string or array with two entries (path and password)')
                                ->end()
                            ->end()
                            ->scalarNode('connect_timeout')
                                ->beforeNormalization()
                                    ->always(function ($v) {
                                        return is_numeric($v) ? (float) $v : $v;
                                    })
                                ->end()
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0);
                                    })
                                    ->thenInvalid('connect_timeout can be: float')
                                ->end()
                            ->end()
                            ->booleanNode('debug')->end()
                            ->variableNode('decode_content')
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_string($v) && !is_bool($v);
                                    })
                                    ->thenInvalid('decode_content can be: bool or string (gzip, compress, deflate, etc...)')
                                ->end()
                            ->end()
                            ->floatNode('delay')->end()
                            ->arrayNode('form_params')
                                ->useAttributeAsKey('name')
                                ->prototype('variable')->end()
                            ->end()
                            ->arrayNode('multipart')
                                ->prototype('variable')->end()
                            ->end()
                            ->scalarNode('sink')
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_string($v);
                                    })
                                    ->thenInvalid('sink can be: string')
                                ->end()
                            ->end()
                            ->booleanNode('http_errors')->end()
                            ->variableNode('expect')
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_bool($v) && !is_int($v);
                                    })
                                    ->thenInvalid('expect can be: bool or int')
                                ->end()
                            ->end()
                            ->variableNode('ssl_key')
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_string($v) && (!is_array($v) || count($v) !== 2);
                                    })
                                    ->thenInvalid('ssl_key can be: string or array with two entries (path and password)')
                                ->end()
                            ->end()
                            ->booleanNode('stream')->end()
                            ->booleanNode('synchronous')->end()
                            ->scalarNode('read_timeout')
                                ->beforeNormalization()
                                    ->always(function ($v) {
                                        return is_numeric($v) ? (float) $v : $v;
                                    })
                                ->end()
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0);
                                    })
                                    ->thenInvalid('read_timeout can be: float')
                                ->end()
                            ->end()
                            ->scalarNode('timeout')
                                ->beforeNormalization()
                                    ->always(function ($v) {
                                        return is_numeric($v) ? (float) $v : $v;
                                    })
                                ->end()
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0);
                                    })
                                    ->thenInvalid('timeout can be: float')
                                ->end()
                            ->end()
                            ->variableNode('verify')
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_bool($v) && !is_string($v);
                                    })
                                    ->thenInvalid('verify can be: bool or string')
                                ->end()
                            ->end()
                            ->booleanNode('cookies')->end()
                            ->arrayNode('proxy')
                                ->beforeNormalization()
                                ->ifString()
                                    ->then(function($v) { return ['http'=> $v]; })
                                ->end()
                                ->validate()
                                    ->always(function($v) {
                                        if (empty($v['no'])) {
                                            unset($v['no']);
                                        }
                                        return $v;
                                    })
                                ->end()
                                ->children()
                                    ->scalarNode('http')->end()
                                    ->scalarNode('https')->end()
                                    ->arrayNode('no')
                                        ->prototype('scalar')->end()
                                    ->end()
                                ->end()
                            ->end()
                            ->scalarNode('version')
                                ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_string($v) && !is_float($v);
                                    })
                                    ->thenInvalid('version can be: string or float')
                                ->end()
                            ->end()
                        ->end()
                    ->end();

        $pluginsNode = $nodeChildren->arrayNode('plugin')->addDefaultsIfNotSet();

        foreach ($this->plugins as $plugin) {
            $pluginNode = new ArrayNodeDefinition($plugin->getPluginName());

            $plugin->addConfiguration($pluginNode);

            $pluginsNode->children()->append($pluginNode);
        }

        return $node;
    }
446110
protected function createNodeByValueAndType($value, $type)
    {
        /*
         * URI
         */
        if ('uri' == $type) {
            return $this->nodeFactory->createNamedNode($value);

        /*
         * Any Pattern
         */
        } elseif ('var' == $type) {
            return $this->nodeFactory->createAnyPattern();

        /*
         * Typed Literal or Literal
         */
        } elseif ('typed-literal' == $type || 'literal' == $type) {
            return $this->nodeFactory->createLiteral($value);

        /*
         * Unknown type
         */
        } else {
            throw new \Exception('Unknown type given: '.$type);
        }
    }
630394
public static function fromParser(MoreInfoParser $parser): self
    {
        $instance = new self();
        $instance->moreInfo = $parser->getMoreInfo();

        return $instance;
    }
121102
private function getViewFactory(): Factory
    {
        if ($this->factory) {
            return $this->factory;
        }

        $resolver = new EngineResolver();
        $resolver->register("blade", function () {
            $blade = $this->getCompiler();
            return new CompilerEngine($blade);
        });

        $this->factory = new Factory($resolver, $this->getViewFinder(), new Dispatcher());

        return $this->factory;
    }
1199176
public function create()
    {
        $type = NodeType::getByHandle('file');
        if (!is_object($type)) {
            NodeType::add('file');
        }
        $type = NodeType::getByHandle('file_folder');
        if (!is_object($type)) {
            NodeType::add('file_folder');
        }
        $type = NodeType::getByHandle('search_preset');
        if (!is_object($type)) {
            NodeType::add('search_preset');
        }
        $type = TreeType::getByHandle('file_manager');
        if (!is_object($type)) {
            TreeType::add('file_manager');
        }

        $manager = FileManager::get();
        if (!is_object($manager)) {
            $manager = FileManager::add();
        }

        return $manager;
    }
1040852
public function factory($type, $level = 0)
    {
        $result = null;

        if (!array_key_exists('type_extended_' . $type, $this->types)) {
            throw new InvalidTypeException;
        }

        /** @var $result ExtendedTypeInterface */
        $result = clone($this->types['type_extended_' . $type]);
        $result->setLevel($level);

        return $result;
    }
456536
public static function create(string $contents)
    {
        $contextInst = new ContextFactory();

        $context = function (string $namespace) use ($contents, $contextInst) {
            return $contextInst->createForNamespace($namespace, $contents);
        };

        $phpdocInst = DocBlockFactory::createInstance();

        $phpdoc = function (string $doc, Context $context) use ($phpdocInst) {
            return $phpdocInst->create($doc, $context);
        };

        return new self($context, $phpdoc);
    }
810420
static function create($lazy = FALSE) {
    return $lazy
      ? new self(PtkParser_ClassBodyLazy::create())
      : new self(PtkParser_ClassBody::create());
  }
256953
public function createVariantForContext($context): NodeInterface
    {
        $autoCreatedChildNodes = [];
        $nodeType = $this->getNodeType();
        foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) {
            $childNode = $this->getNode($childNodeName);
            if ($childNode !== null) {
                $autoCreatedChildNodes[$childNodeName] = $childNode;
            }
        }

        $nodeData = new NodeData($this->nodeData->getPath(), $context->getWorkspace(), $this->nodeData->getIdentifier(), $context->getTargetDimensionValues());
        $nodeData->similarize($this->nodeData);

        if ($this->context !== $context) {
            $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
        } else {
            $this->setNodeData($nodeData);
            $node = $this;
        }

        $this->context->getFirstLevelNodeCache()->flush();
        $this->emitNodeAdded($node);

        /**
         * @var $autoCreatedChildNode NodeInterface
         */
        foreach ($autoCreatedChildNodes as $autoCreatedChildNode) {
            $existingChildNode = $node->getNode($autoCreatedChildNode->getName());
            if ($existingChildNode === null || !$existingChildNode->dimensionsAreMatchingTargetDimensionValues()) {
                // only if needed, see https://github.com/neos/neos-development-collection/issues/782
                $autoCreatedChildNode->createVariantForContext($context);
            }
        }

        return $node;
    }
808140
protected function newBaseQueryBuilder()
    {
        $conn = $this->getConnection();

        $grammar = $conn->getQueryGrammar();

        $builder = new Builder($conn, $grammar, $conn->getPostProcessor());

        if (isset($this->rememberFor)) {
            $builder->remember($this->rememberFor);
        }

        if (isset($this->rememberCacheTag)) {
            $builder->cacheTags($this->rememberCacheTag);
        }

        if (isset($this->rememberCachePrefix)) {
            $builder->prefix($this->rememberCachePrefix);
        }

        if (isset($this->rememberCacheDriver)) {
            $builder->cacheDriver($this->rememberCacheDriver);
        }

        return $builder;
    }
1277108
public function build(): QuerySelectorAllRequest
	{
		$instance = new QuerySelectorAllRequest();
		if ($this->nodeId === null) {
			throw new BuilderException('Property [nodeId] is required.');
		}
		$instance->nodeId = $this->nodeId;
		if ($this->selector === null) {
			throw new BuilderException('Property [selector] is required.');
		}
		$instance->selector = $this->selector;
		return $instance;
	}