Parses a file and creates a Descriptor for it in the project.

@param ProjectDescriptorBuilder $builder
@param string                   $filename

@return void
17550
protected function parseFileIntoDescriptor(ProjectDescriptorBuilder $builder, $filename)
    {
        $parser = new File($this);
        $parser->parse($filename, $builder);
    }
934629
@Override
    public void parse(ClassInfo.Builder builder) throws InvalidClassFileFormatException {
        parse((ClassNameAndSuperclassInfo.Builder) builder);

        final List<FieldDescriptor> fieldDescriptorList = new LinkedList<>();
        final List<MethodDescriptor> methodDescriptorList = new LinkedList<>();
        final TreeSet<ClassDescriptor> referencedClassSet = new TreeSet<>();
        javaClass.accept(new AnnotationVisitor() {
            @Override
            public void visit(Method obj) {
                methodDescriptorList.add(parseMethod(obj));
            }

            @Override
            public void visit(Field obj) {
                fieldDescriptorList.add(parseField(obj));
            }

            @Override
            public void visit(ConstantClass obj) {
                @SlashedClassName
                String className = obj.getBytes(javaClass.getConstantPool());
                if (className.indexOf('[') >= 0) {
                    ClassParser.extractReferencedClassesFromSignature(referencedClassSet, className);
                } else if (ClassName.isValidClassName(className)) {
                    referencedClassSet.add(DescriptorFactory.instance().getClassDescriptor(className));
                }
            }

            @Override
            public void visit(ConstantNameAndType obj) {
                String signature = obj.getSignature(javaClass.getConstantPool());
                ClassParser.extractReferencedClassesFromSignature(referencedClassSet, signature);
            }
        });

    }
726038
public static function create( ConfigurationBuilder $builder  )
	{
		// TODO Currently only supports PHP files, need to add optional json and yaml support.

		$configPath = Framework::fw()->buildPath( '__config' );
		$configFile = $configPath . __ . $builder->key() . ".php";

		if ( file_put_contents( $configFile, $builder->toPhp( true ) ) === false || !is_array( $data = include( $configFile ) ) )
		{
			@unlink( $configFile );

			throw new FrameworkException( "Configuration error, either failed to write config file to [" . $configFile . "] or returned data is not an array." );
		}

		Framework::config()->set( $builder->key(), $data );
	}
963924
public function defineFormBuilder(FormBuilderInterface $formBuilder)
    {
        /** @var AbstractAdmin $admin */
        $admin = $this;

        $mapper = new \Compo\Sonata\AdminBundle\Form\FormMapper($admin->getFormContractor(), $formBuilder, $admin);

        $this->configureFormFields($mapper);

        foreach ($admin->getExtensions() as $extension) {
            $extension->configureFormFields($mapper);
        }

        $this->attachInlineValidator();
    }
668799
public function analyze(ProjectDescriptor $projectDescriptor)
    {
        $this->unresolvedParentClassesCount = 0;

        $elementCounter = array();
        foreach ($this->findAllElements($projectDescriptor) as $element) {
            $elementCounter = $this->addElementToCounter($elementCounter, $element);
            $this->incrementUnresolvedParentCounter($element);
        }

        $this->descriptorCountByType  = $elementCounter;
        $this->fileCount              = count($projectDescriptor->getFiles());
        $this->topLevelNamespaceCount = count($projectDescriptor->getNamespace()->getChildren());
    }
802039
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $this->buildValuesForm($builder, $options);
        $this->buildDataForm($builder, $options);

        $builder->addEventListener(
            FormEvents::POST_SUBMIT,
            function (FormEvent $event) {
                $data = $event->getData();
                if ($data instanceof DataInterface) {
                    $data->setUpdatedAt(new \DateTime());
                }
            }
        );
    }
59169
protected function mapReflectorPropertiesOntoDescriptor(Function_ $reflector, FunctionDescriptor $descriptor): void
    {
        $packages = new Collection();
        $package = $this->extractPackageFromDocBlock($reflector->getDocBlock());
        //TODO: this looks like a potential bug. Have to investigate this!
        if ($package) {
            $tag = new TagDescriptor('package');
            $tag->setDescription($package);
            $packages->add($tag);
        }

        $descriptor->getTags()->set('package', $packages);

        $descriptor->setFullyQualifiedStructuralElementName($reflector->getFqsen());
        $descriptor->setName($reflector->getName());
        $descriptor->setLine($reflector->getLocation()->getLineNumber());
        $descriptor->setNamespace('\\' . trim(substr(
            (string) $reflector->getFqsen(),
            0,
            -strlen($reflector->getName()) - 2
        ), '\\'));
        $descriptor->setReturnType($reflector->getReturnType());
    }
953349
public function populate(ProjectDescriptor $projectDescriptor)
    {
        /** @var IteratorInterface $iteratorInterface */
        $iteratorInterface = $this->getCache()->getIterator();

        // load the settings object
        try {
            $settings = $this->getCache()->getItem(self::KEY_SETTINGS);
        } catch (\Exception $e) {
            $settings = $this->igBinaryCompatibleCacheClear(self::KEY_SETTINGS, $e);
        }

        if ($settings) {
            $projectDescriptor->setSettings($settings);
        }

        // FIXME: Workaround for: https://github.com/zendframework/zf2/pull/4154
        if ($iteratorInterface->valid()) {
            foreach ($this->getCache() as $key) {
                try {
                    $item = $this->getCache()->getItem($key);
                } catch (\Exception $e) {
                    $this->igBinaryCompatibleCacheClear($key, $e);
                }

                if ($item instanceof FileDescriptor) {
                    $projectDescriptor->getFiles()->set($item->getPath(), $item);
                }
            }
        }
    }
512235
private function loadFilesystemFeatureLocator(ContainerBuilder $container)
    {
        $definition = new Definition('Behat\Behat\Gherkin\Specification\Locator\FilesystemFeatureLocator', array(
            new Reference(self::MANAGER_ID),
            '%paths.base%'
        ));
        $definition->addTag(SpecificationExtension::LOCATOR_TAG, array('priority' => 60));
        $container->setDefinition(SpecificationExtension::LOCATOR_TAG . '.filesystem_feature', $definition);
    }
1292515
protected function addTodoMarkerToFile(FileDescriptor $fileDescriptor, TagDescriptor $todo, int $lineNumber): void
    {
        $fileDescriptor->getMarkers()->add(
            [
                'type' => 'TODO',
                'message' => $todo->getDescription(),
                'line' => $lineNumber,
            ]
        );
    }
733112
public function build(PageDocumentDescriptor $descriptor)
    {
        if (IndexibleVoterInterface::VOTE_DENY === $this->indexibleVoter->isIndexible($descriptor)) {
            return null;
        }

        $document = $this->createDocument();

        $this->mapper->mapDocument($document, $descriptor);

        $event = new MapDocumentEvent($document, $descriptor);
        $this->dispatcher->dispatch(IndexerPageEvents::MAP_DOCUMENT, $event);

        return $document;
    }
943665
public function parse(ProjectDescriptorBuilder $builder, Collection $files)
    {
        $this->startTimingTheParsePhase();

        $this->forceRebuildIfSettingsHaveModified($builder);

        $paths = $this->getFilenames($files);

        $this->log('  Project root is:  ' . $files->getProjectRoot());
        $this->log('  Ignore paths are: ' . implode(', ', $files->getIgnorePatterns()->getArrayCopy()));

        $memory = 0;
        foreach ($paths as $filename) {
            $this->parseFileIntoDescriptor($builder, $filename);
            $memory = $this->logAfterParsingAFile($memory);
        }

        $this->logAfterParsingAllFiles();

        return $builder->getProjectDescriptor();
    }
568963
private void readConfiguration(String fileName, IChemObjectBuilder builder) {
        logger.info("Reading config file from ", fileName);

        InputStream ins;
        {
            //try to see if this is a resource
            ins = this.getClass().getClassLoader().getResourceAsStream(fileName);
            if (ins == null) {
                // try to see if this configFile is an actual file
                File file = new File(fileName);
                if (file.exists()) {
                    logger.debug("configFile is a File");
                    // what's next?
                    try {
                        ins = new FileInputStream(file);
                    } catch (Exception exception) {
                        logger.error(exception.getMessage());
                        logger.debug(exception);
                    }
                } else {
                    logger.error("no stream and no file");
                }
            }
        }

        String format = XML_EXTENSION;
        if (fileName.endsWith(TXT_EXTENSION)) {
            format = TXT_EXTENSION;
        } else if (fileName.endsWith(XML_EXTENSION)) {
            format = XML_EXTENSION;
        } else if (fileName.endsWith(OWL_EXTENSION)) {
            format = OWL_EXTENSION;
        }
        readConfiguration(ins, format, builder);
    }
1366709
private function readFiles(Project $p)
    {
        if (!empty($this->includesFileList)) {
            foreach ($this->includesFileList as $ne) {
                $fileName = (string) $ne->evalName($p);
                if ($fileName !== null) {
                    $inclFile = $p->resolveFile($fileName);
                    if (!$inclFile->exists()) {
                        throw new BuildException("Includesfile " . $inclFile->getAbsolutePath() . " not found.");
                    }
                    $this->readPatterns($inclFile, $this->includeList, $p);
                }
            }
            $this->includesFileList = [];
        }

        if (!empty($this->excludesFileList)) {
            foreach ($this->excludesFileList as $ne) {
                $fileName = (string) $ne->evalName($p);
                if ($fileName !== null) {
                    $exclFile = $p->resolveFile($fileName);
                    if (!$exclFile->exists()) {
                        throw new BuildException("Excludesfile " . $exclFile->getAbsolutePath() . " not found.");
                    }
                    $this->readPatterns($exclFile, $this->excludeList, $p);
                }
            }
            $this->excludesFileList = [];
        }
    }
287856
final protected function addFilesToMultipartBuilder(Builder $builder, array $files = []): void
    {
        foreach ($files as $key => $file) {
            if (! \is_null($file)) {
                $builder->addResource($key, fopen($file, 'r'));
            }
        }
    }
237989
protected function handleConfig(Builder $builder, $buildPath)
    {
        $build_config = null;

        // Try getting the project build config from the database:
        if (empty($build_config)) {
            $build_config = $this->getProject()->getBuildConfig();
        }

        // Try .phpci.yml
        if (is_file($buildPath . '/.phpci.yml')) {
            $build_config = file_get_contents($buildPath . '/.phpci.yml');
        }

        // Try phpci.yml first:
        if (empty($build_config) && is_file($buildPath . '/phpci.yml')) {
            $build_config = file_get_contents($buildPath . '/phpci.yml');
        }

        // Fall back to zero config plugins:
        if (empty($build_config)) {
            $build_config = $this->getZeroConfigPlugins($builder);
        }

        if (is_string($build_config)) {
            $yamlParser = new YamlParser();
            $build_config = $yamlParser->parse($build_config);
        }

        $builder->setConfigArray($build_config);
        return true;
    }
417500
public function build(ContainerBuilder $container)
    {
        parent::build($container);

        $container->addCompilerPass(new ViewReferenceBuilderCompilerPass());
        $container->addCompilerPass(new ViewReferenceTransformerCompilerPass());
        $container->addCompilerPass(new ViewReferenceConnectorCompilerPass());
    }