Extract violation candidates from the given Composer instance and symbols.

@param Composer                $composer
@param SymbolIteratorInterface $symbols

@return iterable|CandidateInterface[]
179297
public function extract(
        Composer $composer,
        SymbolIteratorInterface $symbols
    ): iterable {
        $repository = $composer->getRepositoryManager()->getLocalRepository();
        $vendorPath = str_replace('\\', '/', $composer->getConfig()->get('vendor-dir', 0));

        $packages = [];

        foreach ($symbols as $symbol) {
            $package = $this->extractPackage($vendorPath, $symbol);

            if ($package === null) {
                continue;
            }

            if (!array_key_exists($package, $packages)) {
                $packages[$package] = [];
            }

            $packages[$package][] = $symbol;
        }

        $installed = $repository->getPackages();

        $candidates = [];

        foreach ($packages as $name => $symbols) {
            $package = $this->getPackageByName($installed, $name);

            if ($package === null) {
                continue;
            }

            $candidates[] = new Candidate(
                $package,
                new SymbolIterator(...$symbols)
            );
        }

        return $candidates;
    }
282056
public static function configure(IOInterface $io, Composer $composer)
    {
        if (true === $composer->isUndefined()) {
            $answer = $io->ask(HookQuestions::COMPOSER_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
            $composer = $composer
                ->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
        }

        return $composer;
    }
280161
private function getIgnoreFilters(Composer $composer): array
    {
        $extra = $composer->getPackage()->getExtra();

        return array_map(
            function (string $rule) : ViolationFilterInterface {
                $filters = [
                    new ExactPackageFilter($rule),
                    new PatternPackageFilter($rule)
                ];

                if (preg_match('#/$#', $rule)) {
                    $filters[] = new VendorFilter($rule);
                }

                return new ViolationFilterChain(...$filters);
            },
            $extra['dependency-guard']['ignore'] ?? []
        );
    }
1303917
private function determineUnusedCodeViolations(
        Composer $composer,
        CandidateInterface ...$candidates
    ): array {
        $repository = $composer->getRepositoryManager()->getLocalRepository();
        $package    = $composer->getPackage();

        $violations   = [];
        $installed    = [];
        $requirements = array_keys($package->getRequires());
        $packages     = array_map(
            function (CandidateInterface $candidate) : string {
                return $candidate->getPackage()->getName();
            },
            $candidates
        );

        foreach ($repository->getPackages() as $package) {
            $installed[$package->getName()] = $package;
        }

        foreach ($requirements as $requirement) {
            // Platform requirements aren't part of this test.
            if (strpos($requirement, '/') === false) {
                continue;
            }

            // The package is never installed.
            if (!array_key_exists($requirement, $installed)) {
                continue;
            }

            /** @var PackageInterface $package */
            $package = $installed[$requirement];

            // A meta package would not introduce code symbols.
            if ($package->getType() === 'metapackage') {
                continue;
            }

            if (!in_array($requirement, $packages, true)) {
                $violations[] = new Violation(
                    sprintf(
                        'Package "%s" is installed, but never used.',
                        $requirement
                    ),
                    new Candidate($package, new SymbolIterator())
                );
            }
        }

        return $violations;
    }
1058320
protected function filterSpecialCharacters(array $characters)
    {
        foreach ($characters as $str) {
            if (1 != strlen($str)) {
                throw new InvalidArgumentException(sprintf('The submitted string %s must be a single character', $str));
            }
        }
        return $characters;
    }
667206
public static function readComposerLock(): array
    {
        if (self::$composerLockCache !== null) {
            return self::$composerLockCache;
        }

        if (!file_exists(FLOW_PATH_ROOT . 'composer.lock')) {
            return [];
        }

        $json = file_get_contents(FLOW_PATH_ROOT . 'composer.lock');
        $composerLock = json_decode($json, true);
        $composerPackageVersions = isset($composerLock['packages']) ? $composerLock['packages'] : [];
        $composerPackageDevVersions = isset($composerLock['packages-dev']) ? $composerLock['packages-dev'] : [];
        self::$composerLockCache = array_merge($composerPackageVersions, $composerPackageDevVersions);

        return self::$composerLockCache;
    }
874391
private static function getComposerHome(Composer $composer)
    {
        return null !== $composer->getConfig() && $composer->getConfig()->has('home')
            ? $composer->getConfig()->get('home')
            : '';
    }
1219626
public function getViolations($ignoredVioltations=null)
    {
        if (!$this->isValidated())
            throw new StoreException("You must call validate() method before.",
                StoreException::STORE_002);

        if (!is_array($ignoredVioltations)) {
            return $this->violations;
        }

        /**
         * Ignore violation by property path
         */
        $violations = array();
        foreach ($this->getViolations() as $violation) {
            if (!in_array($violation->getPropertyPath(), $ignoredVioltations)) {
                $violations[] = $violation;
            }
        }

        return $violations;
    }
426604
public function getOperator(string $operatorString) : \Dms\Core\Table\IColumnComponentOperator
    {
        if (!isset($this->validOperators[$operatorString])) {
            throw InvalidArgumentException::format(
                    'Invalid operator string for column component type for \'%s\': expecting one of (%s), %s given',
                    $this->phpType->asTypeString(), Debug::formatValues(array_keys($this->validOperators)), $operatorString
            );
        }

        return $this->validOperators[$operatorString];
    }
189633
protected function getCommandsCacheFilePath(Composer $composer): ?string
    {
        $extra             = $composer->getPackage()->getExtra();
        $keyApp            = CommandConstants::COMPOSER_JSON__EXTRA__APPLICATION;
        $keyCacheFile      = CommandConstants::COMPOSER_JSON__EXTRA__APPLICATION__COMMANDS_CACHE;
        $commandsCacheFile = $extra[$keyApp][$keyCacheFile] ?? null;
        if ($commandsCacheFile !== null) {
            $appRootPath       = $composer->getConfig()->get('vendor-dir') . DIRECTORY_SEPARATOR . '..';
            $commandsCacheFile = realpath($appRootPath) . DIRECTORY_SEPARATOR . $commandsCacheFile;
        }

        return $commandsCacheFile;
    }
1130745
public function activate(Composer $composer, IOInterface $io) {
    $this->composer = $composer;
    $this->io = $io;
    $this->eventDispatcher = $composer->getEventDispatcher();
    ProcessExecutor::setTimeout(3600);
    $this->executor = new ProcessExecutor($this->io);
  }
979811
public function getCharacterContracts(Collection $character_ids) : Builder
    {

        return DB::table(DB::raw('contract_details as a'))
            ->select(DB::raw(
                '
                --
                -- All Columns
                --
                *,

                --
                -- Start Location Lookup
                --
                CASE
                when a.start_location_id BETWEEN 66015148 AND 66015151 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.start_location_id-6000000)
                when a.start_location_id BETWEEN 66000000 AND 66014933 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.start_location_id-6000001)
                when a.start_location_id BETWEEN 66014934 AND 67999999 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id = a.start_location_id-6000000)
                when a.start_location_id BETWEEN 60014861 AND 60014928 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id = a.start_location_id)
                when a.start_location_id BETWEEN 60000000 AND 61000000 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.start_location_id)
                when a.start_location_id >= 61000000 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id = a.start_location_id)
                else (SELECT m.itemName FROM mapDenormalize AS m
                    WHERE m.itemID = a.start_location_id) end
                AS startlocation,

                --
                -- End Location Lookup
                --
                CASE
                when a.end_location_id BETWEEN 66015148 AND 66015151 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.end_location_id-6000000)
                when a.end_location_id BETWEEN 66000000 AND 66014933 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.end_location_id-6000001)
                when a.end_location_id BETWEEN 66014934 AND 67999999 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id = a.end_location_id-6000000)
                when a.end_location_id BETWEEN 60014861 AND 60014928 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id = a.end_location_id)
                when a.end_location_id BETWEEN 60000000 AND 61000000 then
                    (SELECT s.stationName FROM staStations AS s
                      WHERE s.stationID = a.end_location_id)
                when a.end_location_id >= 61000000 then
                    (SELECT d.name FROM `sovereignty_structures` AS c
                      JOIN universe_stations d ON c.structure_id = d.station_id
                      WHERE c.structure_id = a.end_location_id)
                else (SELECT m.itemName FROM mapDenormalize AS m
                    WHERE m.itemID = a.end_location_id) end
                AS endlocation '))
            ->join('character_contracts', 'character_contracts.contract_id', '=', 'a.contract_id')
            ->whereIn('character_contracts.character_id', $character_ids->toArray());

    }
1131737
private function extractPackage(
        string $vendorPath,
        SymbolInterface $symbol
    ): ?string {
        static $packagesPerSymbol = [];

        $name = $symbol->getName();

        if (!array_key_exists($name, $packagesPerSymbol)) {
            $reflection = $this->getClassReflection($name);
            $file       = str_replace('\\', '/', $reflection->getFileName());

            // This happens for symbols in the current package.
            if (strpos($file, $vendorPath) !== 0) {
                return null;
            }

            $structure = explode(
                '/',
                preg_replace(
                    sprintf(
                        '/^%s/',
                        preg_quote($vendorPath . '/', '/')
                    ),
                    '',
                    $file
                ),
                3
            );

            // This happens when other code extends Composer root code, like:
            // composer/ClassLoader.php
            if (count($structure) < 3) {
                $packagesPerSymbol[$name] = null;
            }

            [$vendor, $package] = $structure;

            $packagesPerSymbol[$name] = sprintf('%s/%s', $vendor, $package);
        }

        return $packagesPerSymbol[$name] ?? null;
    }
347053
public function collect(Map $map, array $symbols = [])
    {
        foreach ($this->markerCollector->collect($map) as $marker) {
            if ($marker->hasSymbol()) {
                $symbols = $this->collectValue($marker->getSymbol(), $symbols);
            }
        }

        foreach ($this->iconSequenceCollector->collect($map) as $icon) {
            $symbols = $this->collectValue($icon->getSymbol(), $symbols);
        }

        return $symbols;
    }
247908
public function findSymbol($symbolName)
    {
        /** @var $symbol Symbol */
        foreach ($this->symbols as $symbol) {
            if ($symbol->symbol() === $symbolName) {
                return $symbol;
            }
        }

        return;
    }
1374243
private function checkSymbol($symbol)
    {
        if (!in_array($symbol, [self::NONE, self::X, self::O])) {
            throw new Exception\UnknownSymbolException($symbol);
        }
    }
1193918
protected function getRequiredZedBundleCodeGenerators($bundle)
    {
        return [
            $this->createZedDependencyProviderCodeGenerator($bundle),
            $this->createZedConfigCodeGenerator($bundle),
            $this->createFacadeInterfaceCodeGenerator($bundle),
            $this->createFacadeCodeGenerator($bundle),
            $this->createBusinessFactoryCodeGenerator($bundle),
            $this->createCommunicationFactoryCodeGenerator($bundle),
            $this->createGatewayControllerCodeGenerator($bundle),
            $this->createIndexControllerCodeGenerator($bundle),
            $this->createIndexIndexTemplateCodeGenerator($bundle),
            $this->createConsoleCodeGenerator($bundle),
            $this->createPersistenceFactoryCodeGenerator($bundle),
            $this->createQueryContainerCodeGenerator($bundle),
            $this->createQueryContainerInterfaceCodeGenerator($bundle),
            $this->createSchemaXmlCodeGenerator($bundle),
            $this->createNavigationXmlCodeGenerator($bundle),
        ];
    }