|
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 / composer / composer / src / Composer / Package / Dumper / |
Filename | /home/dev2.destoffenstraat.com/vendor/composer/composer/src/Composer/Package/Dumper/ArrayDumper.php |
Size | 4.61 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 17-Aug-2025 10:26 |
Last modified | 29-Sep-2023 10:50 |
Last accessed | 23-Aug-2025 03:56 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Package\Dumper;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface;
use Composer\Package\CompletePackageInterface;
use Composer\Package\RootPackageInterface;
/**
* @author Konstantin Kudryashiv <ever.zet@gmail.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class ArrayDumper
{
public function dump(PackageInterface $package)
{
$keys = array(
'binaries' => 'bin',
'type',
'extra',
'installationSource' => 'installation-source',
'autoload',
'devAutoload' => 'autoload-dev',
'notificationUrl' => 'notification-url',
'includePaths' => 'include-path',
);
$data = array();
$data['name'] = $package->getPrettyName();
$data['version'] = $package->getPrettyVersion();
$data['version_normalized'] = $package->getVersion();
if ($package->getTargetDir()) {
$data['target-dir'] = $package->getTargetDir();
}
if ($package->getSourceType()) {
$data['source']['type'] = $package->getSourceType();
$data['source']['url'] = $package->getSourceUrl();
if (null !== ($value = $package->getSourceReference())) {
$data['source']['reference'] = $value;
}
if ($mirrors = $package->getSourceMirrors()) {
$data['source']['mirrors'] = $mirrors;
}
}
if ($package->getDistType()) {
$data['dist']['type'] = $package->getDistType();
$data['dist']['url'] = $package->getDistUrl();
if (null !== ($value = $package->getDistReference())) {
$data['dist']['reference'] = $value;
}
if (null !== ($value = $package->getDistSha1Checksum())) {
$data['dist']['shasum'] = $value;
}
if ($mirrors = $package->getDistMirrors()) {
$data['dist']['mirrors'] = $mirrors;
}
}
if ($package->getArchiveExcludes()) {
$data['archive']['exclude'] = $package->getArchiveExcludes();
}
foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
foreach ($links as $link) {
$data[$type][$link->getTarget()] = $link->getPrettyConstraint();
}
ksort($data[$type]);
}
}
if ($packages = $package->getSuggests()) {
ksort($packages);
$data['suggest'] = $packages;
}
if ($package->getReleaseDate()) {
$data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
}
$data = $this->dumpValues($package, $keys, $data);
if ($package instanceof CompletePackageInterface) {
$keys = array(
'scripts',
'license',
'authors',
'description',
'homepage',
'keywords',
'repositories',
'support',
'funding',
);
$data = $this->dumpValues($package, $keys, $data);
if (isset($data['keywords']) && is_array($data['keywords'])) {
sort($data['keywords']);
}
if ($package->isAbandoned()) {
$data['abandoned'] = $package->getReplacementPackage() ?: true;
}
}
if ($package instanceof RootPackageInterface) {
$minimumStability = $package->getMinimumStability();
if ($minimumStability) {
$data['minimum-stability'] = $minimumStability;
}
}
if (count($package->getTransportOptions()) > 0) {
$data['transport-options'] = $package->getTransportOptions();
}
return $data;
}
private function dumpValues(PackageInterface $package, array $keys, array $data)
{
foreach ($keys as $method => $key) {
if (is_numeric($method)) {
$method = $key;
}
$getter = 'get'.ucfirst($method);
$value = $package->$getter();
if (null !== $value && !(is_array($value) && 0 === count($value))) {
$data[$key] = $value;
}
}
return $data;
}
}
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Package\Dumper;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface;
use Composer\Package\CompletePackageInterface;
use Composer\Package\RootPackageInterface;
/**
* @author Konstantin Kudryashiv <ever.zet@gmail.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class ArrayDumper
{
public function dump(PackageInterface $package)
{
$keys = array(
'binaries' => 'bin',
'type',
'extra',
'installationSource' => 'installation-source',
'autoload',
'devAutoload' => 'autoload-dev',
'notificationUrl' => 'notification-url',
'includePaths' => 'include-path',
);
$data = array();
$data['name'] = $package->getPrettyName();
$data['version'] = $package->getPrettyVersion();
$data['version_normalized'] = $package->getVersion();
if ($package->getTargetDir()) {
$data['target-dir'] = $package->getTargetDir();
}
if ($package->getSourceType()) {
$data['source']['type'] = $package->getSourceType();
$data['source']['url'] = $package->getSourceUrl();
if (null !== ($value = $package->getSourceReference())) {
$data['source']['reference'] = $value;
}
if ($mirrors = $package->getSourceMirrors()) {
$data['source']['mirrors'] = $mirrors;
}
}
if ($package->getDistType()) {
$data['dist']['type'] = $package->getDistType();
$data['dist']['url'] = $package->getDistUrl();
if (null !== ($value = $package->getDistReference())) {
$data['dist']['reference'] = $value;
}
if (null !== ($value = $package->getDistSha1Checksum())) {
$data['dist']['shasum'] = $value;
}
if ($mirrors = $package->getDistMirrors()) {
$data['dist']['mirrors'] = $mirrors;
}
}
if ($package->getArchiveExcludes()) {
$data['archive']['exclude'] = $package->getArchiveExcludes();
}
foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
foreach ($links as $link) {
$data[$type][$link->getTarget()] = $link->getPrettyConstraint();
}
ksort($data[$type]);
}
}
if ($packages = $package->getSuggests()) {
ksort($packages);
$data['suggest'] = $packages;
}
if ($package->getReleaseDate()) {
$data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
}
$data = $this->dumpValues($package, $keys, $data);
if ($package instanceof CompletePackageInterface) {
$keys = array(
'scripts',
'license',
'authors',
'description',
'homepage',
'keywords',
'repositories',
'support',
'funding',
);
$data = $this->dumpValues($package, $keys, $data);
if (isset($data['keywords']) && is_array($data['keywords'])) {
sort($data['keywords']);
}
if ($package->isAbandoned()) {
$data['abandoned'] = $package->getReplacementPackage() ?: true;
}
}
if ($package instanceof RootPackageInterface) {
$minimumStability = $package->getMinimumStability();
if ($minimumStability) {
$data['minimum-stability'] = $minimumStability;
}
}
if (count($package->getTransportOptions()) > 0) {
$data['transport-options'] = $package->getTransportOptions();
}
return $data;
}
private function dumpValues(PackageInterface $package, array $keys, array $data)
{
foreach ($keys as $method => $key) {
if (is_numeric($method)) {
$method = $key;
}
$getter = 'get'.ucfirst($method);
$value = $package->$getter();
if (null !== $value && !(is_array($value) && 0 === count($value))) {
$data[$key] = $value;
}
}
return $data;
}
}