* @author Jordi Boggiano */ class ArrayDumper { /** * @return array */ public function dump(PackageInterface $package): array { $keys = [ 'binaries' => 'bin', 'type', 'extra', 'installationSource' => 'installation-source', 'autoload', 'devAutoload' => 'autoload-dev', 'notificationUrl' => 'notification-url', 'includePaths' => 'include-path', ]; $data = []; $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; } } 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() instanceof \DateTimeInterface) { $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339); } if ($package->isDefaultBranch()) { $data['default-branch'] = true; } $data = $this->dumpValues($package, $keys, $data); if ($package instanceof CompletePackageInterface) { if ($package->getArchiveName()) { $data['archive']['name'] = $package->getArchiveName(); } if ($package->getArchiveExcludes()) { $data['archive']['exclude'] = $package->getArchiveExcludes(); } $keys = [ '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; } /** * @param array $keys * @param array $data * * @return array */ private function dumpValues(PackageInterface $package, array $keys, array $data): array { 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; } } __halt_compiler();----SIGNATURE:----tYD5UnFnqV3sPFMILUtxksDzmctscy0i/owHuChHFkUa16Gbf4j/PxRu48G4xZ76bSlvxzz+tuTPUYrFh/35kceWuWoP6NhYFCo4mtoGeu/bLKKCo2c5TLwJjl4g4mB4V+WuCkY/kpDNxJdzLoorRKiVdX9hcWa9iOTZpos38J9SqrbhR/bmH/W9w76a0HnpkyI1vTy0M0G8biGtNK3sMJZNAZodCgvuCHAxutDcF8mFGckajyJdOYmq20SOTq3HRFOfMO8tNecbkGaHgN3JIEDGPzP0ikBEQuE+HU3fLovur+r1UwEJDEgQElNzd+Eof+bVC9hCYb75DN/86vvvSR3FL+4s4L2y5ZlhO3AssrcQRBmgVH2VFIL5nOGJLo9378xg1dKExwmLXtTRblf6iQIb9f30SC7jfTFJgX+PsdJeSGGzb9j37kMT6IN7QtK/Yy54AneZQFdHHi5UtQpDaOo9vB0p58opK1iyEUqCHwNd0LiYf4Mf8xkgrYooxSbLNGGsVh0Melb723gDidVUfGbozvlLcDowXi72qPpfX+Rt8FPNopKTSPc6WAdtQyL8ZhhDxy373LxIjIHD/epxP3rHaFdR4sAZN87KVAFgbpVwOL3fT3JvjtYKParSFvR6GRDCRAHgk15O5qwKCs09gr4KNLeXOk5vWIoxECFDku8=----ATTACHMENT:----MTg1NjM5NzUxOTA5MzQ1IDE5MDQ3OTE3Nzc2MDcwMDUgNzg4NDk2NzI4NDkyNzY0