@param Composer $composer

@return null|string
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;
    }
322317
protected function findComposer()
    {
        if ($this->files->exists($this->workingPath.'/composer.phar')) {
            return ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false)).' composer.phar';
        }

        return 'composer';
    }
922102
private static function getCustomVendorPathFromComposer($composerConfigurationPath): string
    {
        $composerFile = file_get_contents($composerConfigurationPath);
        $composerJson = json_decode($composerFile, true);
        return $composerJson['config']['vendor-dir'] ?? 'vendor';
    }
1063154
public function activate(Composer $composer, IOInterface $io)
    {
        $package = $composer->getPackage();

        if ($package instanceof CompletePackage) {
            $this->addScriptsTo($package);
        }

        if ($package instanceof RootPackageInterface) {
            $this->addAutoloadTo($package);
        }
    }
634544
private function getFilteredLinks(Composer $composer)
    {
        $links = array_values($composer->getPackage()->getRequires());

        // only pick up packages in our filter, if a filter has been set.
        if ($this->hasFilterForPackages()) {
            $packagesFilter = $this->packagesFilter;
            $links = array_filter($links, function (Link $link) use ($packagesFilter) {
                return in_array($link->getTarget(), $packagesFilter);
            });
        }

        return array_values($links);
    }
615786
public function getPackageKeyFromComposerName($composerName)
    {
        if ($this->composerNameToPackageKeyMap === []) {
            foreach ($this->packageStatesConfiguration['packages'] as $packageStateConfiguration) {
                $this->composerNameToPackageKeyMap[$packageStateConfiguration['composerName']] = $packageStateConfiguration['packageKey'];
            }
        }

        $lowercasedComposerName = strtolower($composerName);
        if (!isset($this->composerNameToPackageKeyMap[$lowercasedComposerName])) {
            throw new Exception\InvalidPackageStateException('Could not find package with composer name "' . $lowercasedComposerName . '" in PackageStates configuration.', 1352320649);
        }

        return $this->composerNameToPackageKeyMap[$lowercasedComposerName];
    }
895656
private static function getRelatedPackage($fileName) {
		$dir = dirname($fileName);
		$rootPath = rtrim(ROOT_PATH, "/\\");
		
		while ($dir && $dir != $rootPath) {
			if (file_exists($dir.'/composer.json')) {
				return $dir.'/composer.json';
			}
			$dir = dirname($dir);
		}
		if (file_exists($dir.'/composer.json')) {
			return $dir.'/composer.json';
		}
		return null;
	}
991840
public function activate(Composer $composer, IOInterface $io)
    {
        $this->config = Config::load($io, $composer->getConfig());
        $this->composer = $composer;
        $this->io = $io;
    }
263620
public function handle(Composer $composer)
    {
        $output = new OperationFileOutput($this->outputFileName);

        $composer->run($output, $this->extensionsNames);
    }
687528
protected function findComposer()
    {
        $composerPhar = $this->workingPath .DS .'composer.phar';

        if ($this->files->exists($composerPhar)) {
            $executable = with(new PhpExecutableFinder)->find(false);

            return ProcessUtils::escapeArgument($executable) .' ' .$composerPhar;
        }

        return 'composer';
    }
471517
private static function _resetComposer()
	{
		self::$composer = null;
		self::$factory = null;
		self::$repositoryManager = null;
		self::$localRepository = null;
		self::$remoteRepositories = null;
		self::$io = null;
		self::$installer = null;
		self::$dispatcher = null;
		return self::_init();
	}
1329671
public function create(Composer $composer): ViolationFilterInterface
    {
        $chain = new ViolationFilterChain(
            ...array_merge(
                $this->getSuggestsFilters($composer),
                $this->getIgnoreFilters($composer)
            )
        );

        return new ViolationFilterChain(
            $chain,
            new PackageRequirementsFilter(
                $composer->getLocker(),
                $chain
            )
        );
    }
162773
public function find(Composer $composer, NpmBridge $bridge): array
    {
        $packages = $composer->getRepositoryManager()->getLocalRepository()
            ->getPackages();

        $dependantPackages = [];

        foreach ($packages as $package) {
            if ($bridge->isDependantPackage($package, false)) {
                $dependantPackages[] = $package;
            }
        }

        return $dependantPackages;
    }
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;
    }
1369767
private function findProjectRoot(string $dir) : ?string
    {
        do {
            $path = $dir . '/composer.json';

            if (file_exists($path)) {
                return $dir;
            }

            $prev = $dir;
            $dir = dirname($dir);
        } while ($dir !== $prev);

        return null;
    }
517232
public static function get(Composer $composer): ?ProjectTypeInterface
    {
        $rootDir = dirname($composer->getConfig()->getConfigSource()->getName());

        $classes = static::getClasses($composer);

        $composerProjectType = $composer->getPackage()->getExtra()['rikudou']['installer']['project-type'] ?? null;
        if ($composerProjectType && isset($classes[$composerProjectType])) {
            $class = $classes[$composerProjectType];

            return new $class;
        }

        foreach ($classes as $class) {
            /** @var ProjectTypeInterface $instance */
            $instance = new $class;
            foreach ($instance->getDirs() as $dir) {
                if (is_array($dir)) {
                    $exists = true;
                    foreach ($dir as $requiredDir) {
                        $exists = $exists && file_exists("{$rootDir}/{$requiredDir}");
                    }
                    if ($exists) {
                        return $instance;
                    }
                } else {
                    if (file_exists("{$rootDir}/{$dir}")) {
                        return $instance;
                    }
                }
            }
        }

        return null;
    }
492706
public function composer()
    {
        if (is_null($this->composer)) {
            $this->composer = app(Composer::class);
        }

        return $this->composer;
    }