b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / vendor / magento / framework / Composer /
Filename/home/dev2.destoffenstraat.com/vendor/magento/framework/Composer/DependencyChecker.php
Size2.78 kb
Permissionrw-r--r--
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified07-Jan-2021 21:08
Last accessed23-Aug-2025 03:56
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Composer;

use Composer\Console\Application;
use Magento\Framework\App\Filesystem\DirectoryList;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;

/**
* A class to check if there are any dependency to package(s) that exists in the codebase, regardless of package type
*/
class DependencyChecker
{
/**
* @var Application
*/
private $composerApp;

/**
* @var DirectoryList
*/
private $directoryList;

/**
* Constructor
*
* @param Application $composerApp
* @param DirectoryList $directoryList
*/
public function __construct(Application $composerApp, DirectoryList $directoryList)
{
$this->composerApp = $composerApp;
$this->directoryList = $directoryList;
}

/**
* Checks dependencies to package(s), returns array of dependencies in the format of
* 'package A' => [array of package names depending on package A]
* If $excludeSelf is set to true, items in $packages will be excluded in all
* "array of package names depending on package A"
*
* @param string[] $packages
* @param bool $excludeSelf
* @return string[]
*/
public function checkDependencies(array $packages, $excludeSelf = false)
{
$this->composerApp->setAutoExit(false);
$dependencies = [];
foreach ($packages as $package) {
$buffer = new BufferedOutput();
$this->composerApp->resetComposer();
$this->composerApp->run(
new ArrayInput(
['command' => 'depends', '--working-dir' => $this->directoryList->getRoot(), 'package' => $package]
),
$buffer
);
$dependingPackages = $this->parseComposerOutput($buffer->fetch());
if ($excludeSelf === true) {
$dependingPackages = array_values(array_diff($dependingPackages, $packages));
}
$dependencies[$package] = $dependingPackages;
}
return $dependencies;
}

/**
* Parse output from running composer remove command into an array of depending packages
*
* @param string $output
* @return string[]
*/
private function parseComposerOutput($output)
{
$rawLines = explode(PHP_EOL, $output);
$packages = [];
foreach ($rawLines as $rawLine) {
$parts = explode(' ', $rawLine);
if (count(explode('/', $parts[0])) == 2) {
if (strpos($parts[0], 'magento/project-') === false) {
$packages[] = $parts[0];
}
}
}
return $packages;
}
}