Exemplo n.º 1
0
 public function testRun()
 {
     $app = $this->getApp();
     $testPackage = new CompletePackage('test', '1.0.1', '1.0');
     $testPackage->setDescription('An extension');
     $testPackage->setType('bolt-extension');
     $runner = $this->getMockBuilder(PackageManager::class)->setMethods(['showPackage'])->setConstructorArgs([$app])->getMock();
     $runner->expects($this->any())->method('showPackage')->will($this->returnValue(['test' => ['package' => $testPackage]]));
     $app['extend.manager'] = $runner;
     $command = new Extensions($app);
     $tester = new CommandTester($command);
     $tester->execute([]);
     $result = $tester->getDisplay();
     $this->assertRegExp('/Name.*Version/', $result);
     $this->assertRegExp('/test.*1.0/', $result);
 }
Exemplo n.º 2
0
 /**
  * Filter the package to add dist and other meta information.
  */
 function filterPackage(CompletePackage $package)
 {
     list($vendor, $shortName) = explode('/', $package->getName());
     // try to get the plugin info - may return an array or null/false
     try {
         $info = $this->getPluginInfo($shortName);
     } catch (RuntimeException $e) {
         if ($io->isVerbose()) {
             $io->writeError($e->getMessage());
         }
         // this allows us to try again for this plugin
         return;
     }
     if ($info) {
         // set the dist info
         $package->setDistType('zip');
         // strip out "tags", "trunk", slashes, and spaces
         $version = preg_replace('/tags|trunk|[\\/ ]/', '', $package->getSourceReference());
         // if there is a version identifier, prepend with a period
         $version = $version ? ".{$version}" : '';
         // set the dist url
         $package->setDistUrl('https://downloads.wordpress.org/plugin/' . urlencode($shortName . $version) . '.zip');
         // set some additional meta info
         // this is inconsequential to the solver, but it gets stored in composer.lock
         // and appears when running `composer show vendor/package`
         if (isset($info['short_description'])) {
             $package->setDescription($info['short_description']);
         }
         if (!empty($info['contributors'])) {
             $authors = [];
             foreach ($info['contributors'] as $name => $homepage) {
                 $authors[] = ['name' => $name, 'homepage' => $homepage];
             }
             $package->setAuthors($authors);
         }
         if (!empty($info['tags'])) {
             $package->setKeywords($info['tags']);
         }
         // URL-ready slug
         $pluginSlug = urlencode($shortName);
         $package->setSupport(['forum' => "https://wordpress.org/support/plugin/{$pluginSlug}/", 'source' => "http://plugins.trac.wordpress.org/browser/{$pluginSlug}/", 'docs' => "https://wordpress.org/plugins/{$pluginSlug}/"]);
         $package->setHomepage("https://wordpress.org/plugins/{$pluginSlug}/");
     } else {
         // null means the package is no longer active
         $package->setAbandoned(true);
     }
 }
Exemplo n.º 3
0
 public function testRun()
 {
     $app = $this->getApp();
     $testPackage = new CompletePackage('test', '1.0.1', '1.0');
     $testPackage->setDescription('An extension');
     $testPackage->setType('bolt-extension');
     $runner = $this->getMock("Bolt\\Composer\\PackageManager", array('showPackage'), array($app));
     $runner->expects($this->any())->method('showPackage')->will($this->returnValue(array('test' => array('package' => $testPackage))));
     $app['extend.manager'] = $runner;
     $command = new Extensions($app);
     $command->setHelperSet(new HelperSet(array(new TableHelper())));
     $tester = new CommandTester($command);
     $tester->execute(array());
     $result = $tester->getDisplay();
     $this->assertRegexp('/Name.*Version/', $result);
     $this->assertRegexp('/test.*1.0/', $result);
 }
Exemplo n.º 4
0
 /**
  * Filter the package to add dist and other meta information.
  */
 function filterPackage(CompletePackage $package)
 {
     list($vendor, $shortName) = explode('/', $package->getName());
     if (($themeInfo = $this->getThemeInfo()) && isset($themeInfo[$shortName])) {
         $info = $themeInfo[$shortName];
         // set the dist info
         $package->setDistType('zip');
         $package->setDistUrl($info['download_uri']);
         // additional meta info
         $package->setDescription($info['description']);
         $package->setAuthors([['name' => $info['author'], 'homepage' => $info['author_uri']]]);
         $package->setHomepage($info['theme_uri']);
         // is this theme retired?
         if (in_array($shortName, $this->getRetiredThemes())) {
             $package->setAbandoned(true);
         }
     }
 }
Exemplo n.º 5
0
 static function filterPackage(CompletePackage $package)
 {
     // strip out "tags", slashes, and spaces
     $version = preg_replace('/tags|[\\/ ]/', '', $package->getSourceReference());
     // trunk does not have a dist version
     if ($version !== 'trunk') {
         // set the dist info
         $package->setDistType('zip');
         // if there is a version identifier, prepend with a period
         $version = "-{$version}";
         // set the dist url
         $package->setDistUrl('https://wordpress.org/wordpress' . urlencode($version) . '.zip');
     }
     // set some additional meta info
     // this is inconsequential to the solver, but it gets stored in composer.lock
     // and appears when running `composer show vendor/package`
     $package->setDescription('WordPress is web software you can use to create a beautiful website, blog, or app.');
     $package->setSupport(['forum' => 'https://wordpress.org/support/', 'source' => 'https://core.trac.wordpress.org/browser/' . $package->getSourceReference(), 'docs' => 'https://codex.wordpress.org/Main_Page']);
     $package->setHomepage('https://wordpress.org/');
 }
 public function testShouldCreatePackages()
 {
     $reader = $this->getMockBuilder('\\Composer\\Repository\\PearRepository')->disableOriginalConstructor()->getMock();
     $ref = new \ReflectionMethod($reader, 'buildComposerPackages');
     $ref->setAccessible(true);
     $channelInfo = new ChannelInfo('test.loc', 'test', array(new PackageInfo('test.loc', 'sample', 'license', 'shortDescription', 'description', array('1.0.0.1' => new ReleaseInfo('stable', new DependencyInfo(array(new DependencyConstraint('required', '> 5.2.0.0', 'php', ''), new DependencyConstraint('conflicts', '== 2.5.6.0', 'pear.php.net', 'broken')), array('*' => array(new DependencyConstraint('optional', '*', 'ext', 'xml')))))))));
     $packages = $ref->invoke($reader, $channelInfo, new VersionParser());
     $expectedPackage = new CompletePackage('pear-test.loc/sample', '1.0.0.1', '1.0.0.1');
     $expectedPackage->setType('pear-library');
     $expectedPackage->setDistType('file');
     $expectedPackage->setDescription('description');
     $expectedPackage->setDistUrl("http://test.loc/get/sample-1.0.0.1.tgz");
     $expectedPackage->setAutoload(array('classmap' => array('')));
     $expectedPackage->setIncludePaths(array('/'));
     $expectedPackage->setRequires(array(new Link('pear-test.loc/sample', 'php', $this->createConstraint('>', '5.2.0.0'), 'required', '> 5.2.0.0')));
     $expectedPackage->setConflicts(array(new Link('pear-test.loc/sample', 'pear-pear.php.net/broken', $this->createConstraint('==', '2.5.6.0'), 'conflicts', '== 2.5.6.0')));
     $expectedPackage->setSuggests(array('*-ext-xml' => '*'));
     $expectedPackage->setReplaces(array(new Link('pear-test.loc/sample', 'pear-test/sample', new VersionConstraint('==', '1.0.0.1'), 'replaces', '== 1.0.0.1')));
     $this->assertCount(1, $packages);
     $this->assertEquals($expectedPackage, $packages[0], 0, 1);
 }
Exemplo n.º 7
0
 /**
  * Builds CompletePackages from PEAR package definition data.
  *
  * @param  ChannelInfo     $channelInfo
  * @param  VersionParser   $versionParser
  * @return CompletePackage
  */
 private function buildComposerPackages(ChannelInfo $channelInfo, VersionParser $versionParser)
 {
     $result = array();
     foreach ($channelInfo->getPackages() as $packageDefinition) {
         foreach ($packageDefinition->getReleases() as $version => $releaseInfo) {
             try {
                 $normalizedVersion = $versionParser->normalize($version);
             } catch (\UnexpectedValueException $e) {
                 if ($this->io->isVerbose()) {
                     $this->io->writeError('Could not load ' . $packageDefinition->getPackageName() . ' ' . $version . ': ' . $e->getMessage());
                 }
                 continue;
             }
             $composerPackageName = $this->buildComposerPackageName($packageDefinition->getChannelName(), $packageDefinition->getPackageName());
             // distribution url must be read from /r/{packageName}/{version}.xml::/r/g:text()
             // but this location is 'de-facto' standard
             $urlBits = parse_url($this->url);
             $scheme = isset($urlBits['scheme']) && 'https' === $urlBits['scheme'] && extension_loaded('openssl') ? 'https' : 'http';
             $distUrl = "{$scheme}://{$packageDefinition->getChannelName()}/get/{$packageDefinition->getPackageName()}-{$version}.tgz";
             $requires = array();
             $suggests = array();
             $conflicts = array();
             $replaces = array();
             // alias package only when its channel matches repository channel,
             // cause we've know only repository channel alias
             if ($channelInfo->getName() == $packageDefinition->getChannelName()) {
                 $composerPackageAlias = $this->buildComposerPackageName($channelInfo->getAlias(), $packageDefinition->getPackageName());
                 $aliasConstraint = new VersionConstraint('==', $normalizedVersion);
                 $replaces[] = new Link($composerPackageName, $composerPackageAlias, $aliasConstraint, 'replaces', (string) $aliasConstraint);
             }
             // alias package with user-specified prefix. it makes private pear channels looks like composer's.
             if (!empty($this->vendorAlias) && ($this->vendorAlias != 'pear-' . $channelInfo->getAlias() || $channelInfo->getName() != $packageDefinition->getChannelName())) {
                 $composerPackageAlias = "{$this->vendorAlias}/{$packageDefinition->getPackageName()}";
                 $aliasConstraint = new VersionConstraint('==', $normalizedVersion);
                 $replaces[] = new Link($composerPackageName, $composerPackageAlias, $aliasConstraint, 'replaces', (string) $aliasConstraint);
             }
             foreach ($releaseInfo->getDependencyInfo()->getRequires() as $dependencyConstraint) {
                 $dependencyPackageName = $this->buildComposerPackageName($dependencyConstraint->getChannelName(), $dependencyConstraint->getPackageName());
                 $constraint = $versionParser->parseConstraints($dependencyConstraint->getConstraint());
                 $link = new Link($composerPackageName, $dependencyPackageName, $constraint, $dependencyConstraint->getType(), $dependencyConstraint->getConstraint());
                 switch ($dependencyConstraint->getType()) {
                     case 'required':
                         $requires[] = $link;
                         break;
                     case 'conflicts':
                         $conflicts[] = $link;
                         break;
                     case 'replaces':
                         $replaces[] = $link;
                         break;
                 }
             }
             foreach ($releaseInfo->getDependencyInfo()->getOptionals() as $group => $dependencyConstraints) {
                 foreach ($dependencyConstraints as $dependencyConstraint) {
                     $dependencyPackageName = $this->buildComposerPackageName($dependencyConstraint->getChannelName(), $dependencyConstraint->getPackageName());
                     $suggests[$group . '-' . $dependencyPackageName] = $dependencyConstraint->getConstraint();
                 }
             }
             $package = new CompletePackage($composerPackageName, $normalizedVersion, $version);
             $package->setType('pear-library');
             $package->setDescription($packageDefinition->getDescription());
             $package->setLicense(array($packageDefinition->getLicense()));
             $package->setDistType('file');
             $package->setDistUrl($distUrl);
             $package->setAutoload(array('classmap' => array('')));
             $package->setIncludePaths(array('/'));
             $package->setRequires($requires);
             $package->setConflicts($conflicts);
             $package->setSuggests($suggests);
             $package->setReplaces($replaces);
             $result[] = $package;
         }
     }
     return $result;
 }
Exemplo n.º 8
0
 protected function initialize()
 {
     parent::initialize();
     $versionParser = new VersionParser();
     $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
     $version = $versionParser->normalize($prettyVersion);
     $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
     $composerPluginApi->setDescription('The Composer Plugin API');
     parent::addPackage($composerPluginApi);
     try {
         $prettyVersion = PHP_VERSION;
         $version = $versionParser->normalize($prettyVersion);
     } catch (\UnexpectedValueException $e) {
         $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', PHP_VERSION);
         $version = $versionParser->normalize($prettyVersion);
     }
     $php = new CompletePackage('php', $version, $prettyVersion);
     $php->setDescription('The PHP interpreter');
     parent::addPackage($php);
     if (PHP_INT_SIZE === 8) {
         $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
         $php64->setDescription('The PHP interpreter (64bit)');
         parent::addPackage($php64);
     }
     $loadedExtensions = get_loaded_extensions();
     foreach ($loadedExtensions as $name) {
         if (in_array($name, array('standard', 'Core'))) {
             continue;
         }
         $reflExt = new \ReflectionExtension($name);
         try {
             $prettyVersion = $reflExt->getVersion();
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = '0';
             $version = $versionParser->normalize($prettyVersion);
         }
         $packageName = $this->buildPackageName($name);
         $ext = new CompletePackage($packageName, $version, $prettyVersion);
         $ext->setDescription('The ' . $name . ' PHP extension');
         parent::addPackage($ext);
     }
     foreach ($loadedExtensions as $name) {
         $prettyVersion = null;
         switch ($name) {
             case 'curl':
                 $curlVersion = curl_version();
                 $prettyVersion = $curlVersion['version'];
                 break;
             case 'iconv':
                 $prettyVersion = ICONV_VERSION;
                 break;
             case 'intl':
                 $name = 'ICU';
                 if (defined('INTL_ICU_VERSION')) {
                     $prettyVersion = INTL_ICU_VERSION;
                 } else {
                     $reflector = new \ReflectionExtension('intl');
                     ob_start();
                     $reflector->info();
                     $output = ob_get_clean();
                     preg_match('/^ICU version => (.*)$/m', $output, $matches);
                     $prettyVersion = $matches[1];
                 }
                 break;
             case 'libxml':
                 $prettyVersion = LIBXML_DOTTED_VERSION;
                 break;
             case 'openssl':
                 $prettyVersion = preg_replace_callback('{^(?:OpenSSL\\s*)?([0-9.]+)([a-z]?).*}', function ($match) {
                     return $match[1] . (empty($match[2]) ? '' : '.' . (ord($match[2]) - 96));
                 }, OPENSSL_VERSION_TEXT);
                 break;
             case 'pcre':
                 $prettyVersion = preg_replace('{^(\\S+).*}', '$1', PCRE_VERSION);
                 break;
             case 'uuid':
                 $prettyVersion = phpversion('uuid');
                 break;
             case 'xsl':
                 $prettyVersion = LIBXSLT_DOTTED_VERSION;
                 break;
             default:
                 continue 2;
         }
         try {
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             continue;
         }
         $lib = new CompletePackage('lib-' . $name, $version, $prettyVersion);
         $lib->setDescription('The ' . $name . ' PHP library');
         parent::addPackage($lib);
     }
     if (defined('HHVM_VERSION')) {
         try {
             $prettyVersion = HHVM_VERSION;
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', HHVM_VERSION);
             $version = $versionParser->normalize($prettyVersion);
         }
         $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
         $hhvm->setDescription('The HHVM Runtime (64bit)');
         parent::addPackage($hhvm);
     }
 }
Exemplo n.º 9
0
 protected function initialize()
 {
     parent::initialize();
     $versionParser = new VersionParser();
     // Add each of the override versions as options.
     // Later we might even replace the extensions instead.
     foreach ($this->overrides as $override) {
         // Check that it's a platform package.
         if (!preg_match(self::PLATFORM_PACKAGE_REGEX, $override['name'])) {
             throw new \InvalidArgumentException('Invalid platform package name in config.platform: ' . $override['name']);
         }
         $version = $versionParser->normalize($override['version']);
         $package = new CompletePackage($override['name'], $version, $override['version']);
         $package->setDescription('Package overridden via config.platform');
         $package->setExtra(array('config.platform' => true));
         parent::addPackage($package);
     }
     $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
     $version = $versionParser->normalize($prettyVersion);
     $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
     $composerPluginApi->setDescription('The Composer Plugin API');
     $this->addPackage($composerPluginApi);
     try {
         $prettyVersion = PHP_VERSION;
         $version = $versionParser->normalize($prettyVersion);
     } catch (\UnexpectedValueException $e) {
         $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', PHP_VERSION);
         $version = $versionParser->normalize($prettyVersion);
     }
     $php = new CompletePackage('php', $version, $prettyVersion);
     $php->setDescription('The PHP interpreter');
     $this->addPackage($php);
     if (PHP_INT_SIZE === 8) {
         $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
         $php64->setDescription('The PHP interpreter, 64bit');
         $this->addPackage($php64);
     }
     $loadedExtensions = get_loaded_extensions();
     // Extensions scanning
     foreach ($loadedExtensions as $name) {
         if (in_array($name, array('standard', 'Core'))) {
             continue;
         }
         $reflExt = new \ReflectionExtension($name);
         try {
             $prettyVersion = $reflExt->getVersion();
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = '0';
             $version = $versionParser->normalize($prettyVersion);
         }
         $packageName = $this->buildPackageName($name);
         $ext = new CompletePackage($packageName, $version, $prettyVersion);
         $ext->setDescription('The ' . $name . ' PHP extension');
         $this->addPackage($ext);
     }
     // Another quick loop, just for possible libraries
     // Doing it this way to know that functions or constants exist before
     // relying on them.
     foreach ($loadedExtensions as $name) {
         $prettyVersion = null;
         $description = 'The ' . $name . ' PHP library';
         switch ($name) {
             case 'curl':
                 $curlVersion = curl_version();
                 $prettyVersion = $curlVersion['version'];
                 break;
             case 'iconv':
                 $prettyVersion = ICONV_VERSION;
                 break;
             case 'intl':
                 $name = 'ICU';
                 if (defined('INTL_ICU_VERSION')) {
                     $prettyVersion = INTL_ICU_VERSION;
                 } else {
                     $reflector = new \ReflectionExtension('intl');
                     ob_start();
                     $reflector->info();
                     $output = ob_get_clean();
                     preg_match('/^ICU version => (.*)$/m', $output, $matches);
                     $prettyVersion = $matches[1];
                 }
                 break;
             case 'libxml':
                 $prettyVersion = LIBXML_DOTTED_VERSION;
                 break;
             case 'openssl':
                 $prettyVersion = preg_replace_callback('{^(?:OpenSSL\\s*)?([0-9.]+)([a-z]*).*}', function ($match) {
                     if (empty($match[2])) {
                         return $match[1];
                     }
                     // OpenSSL versions add another letter when they reach Z.
                     // e.g. OpenSSL 0.9.8zh 3 Dec 2015
                     if (!preg_match('{^z*[a-z]$}', $match[2])) {
                         // 0.9.8abc is garbage
                         return 0;
                     }
                     $len = strlen($match[2]);
                     $patchVersion = ($len - 1) * 26;
                     // All Z
                     $patchVersion += ord($match[2][$len - 1]) - 96;
                     return $match[1] . '.' . $patchVersion;
                 }, OPENSSL_VERSION_TEXT);
                 $description = OPENSSL_VERSION_TEXT;
                 break;
             case 'pcre':
                 $prettyVersion = preg_replace('{^(\\S+).*}', '$1', PCRE_VERSION);
                 break;
             case 'uuid':
                 $prettyVersion = phpversion('uuid');
                 break;
             case 'xsl':
                 $prettyVersion = LIBXSLT_DOTTED_VERSION;
                 break;
             default:
                 // None handled extensions have no special cases, skip
                 continue 2;
         }
         try {
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             continue;
         }
         $lib = new CompletePackage('lib-' . $name, $version, $prettyVersion);
         $lib->setDescription($description);
         $this->addPackage($lib);
     }
     if (defined('HHVM_VERSION')) {
         try {
             $prettyVersion = HHVM_VERSION;
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', HHVM_VERSION);
             $version = $versionParser->normalize($prettyVersion);
         }
         $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
         $hhvm->setDescription('The HHVM Runtime (64bit)');
         $this->addPackage($hhvm);
     }
 }
Exemplo n.º 10
0
 protected function initialize()
 {
     parent::initialize();
     $versionParser = new VersionParser();
     try {
         $prettyVersion = PHP_VERSION;
         $version = $versionParser->normalize($prettyVersion);
     } catch (\UnexpectedValueException $e) {
         $prettyVersion = preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION);
         $version = $versionParser->normalize($prettyVersion);
     }
     $php = new CompletePackage('php', $version, $prettyVersion);
     $php->setDescription('The PHP interpreter');
     parent::addPackage($php);
     $loadedExtensions = get_loaded_extensions();
     // Extensions scanning
     foreach ($loadedExtensions as $name) {
         if (in_array($name, array('standard', 'Core'))) {
             continue;
         }
         $reflExt = new \ReflectionExtension($name);
         try {
             $prettyVersion = $reflExt->getVersion();
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = '0';
             $version = $versionParser->normalize($prettyVersion);
         }
         $ext = new CompletePackage('ext-' . $name, $version, $prettyVersion);
         $ext->setDescription('The ' . $name . ' PHP extension');
         parent::addPackage($ext);
     }
     // Another quick loop, just for possible libraries
     // Doing it this way to know that functions or constants exist before
     // relying on them.
     foreach ($loadedExtensions as $name) {
         switch ($name) {
             case 'curl':
                 $curlVersion = curl_version();
                 $prettyVersion = $curlVersion['version'];
                 break;
             case 'iconv':
                 $prettyVersion = ICONV_VERSION;
                 break;
             case 'libxml':
                 $prettyVersion = LIBXML_DOTTED_VERSION;
                 break;
             case 'openssl':
                 $prettyVersion = preg_replace_callback('{^(?:OpenSSL\\s*)?([0-9.]+)([a-z]?).*}', function ($match) {
                     return $match[1] . (empty($match[2]) ? '' : '.' . (ord($match[2]) - 96));
                 }, OPENSSL_VERSION_TEXT);
                 break;
             case 'pcre':
                 $prettyVersion = preg_replace('{^(\\S+).*}', '$1', PCRE_VERSION);
                 break;
             case 'uuid':
                 $prettyVersion = phpversion('uuid');
                 break;
             case 'xsl':
                 $prettyVersion = LIBXSLT_DOTTED_VERSION;
                 break;
             default:
                 // None handled extensions have no special cases, skip
                 continue 2;
         }
         try {
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             continue;
         }
         $lib = new CompletePackage('lib-' . $name, $version, $prettyVersion);
         $lib->setDescription('The ' . $name . ' PHP library');
         parent::addPackage($lib);
     }
 }
Exemplo n.º 11
0
 private function buildComposerPackages(ChannelInfo $channelInfo, VersionParser $versionParser)
 {
     $result = array();
     foreach ($channelInfo->getPackages() as $packageDefinition) {
         foreach ($packageDefinition->getReleases() as $version => $releaseInfo) {
             try {
                 $normalizedVersion = $versionParser->normalize($version);
             } catch (\UnexpectedValueException $e) {
                 if ($this->io->isVerbose()) {
                     $this->io->write('Could not load ' . $packageDefinition->getPackageName() . ' ' . $version . ': ' . $e->getMessage());
                 }
                 continue;
             }
             $composerPackageName = $this->buildComposerPackageName($packageDefinition->getChannelName(), $packageDefinition->getPackageName());
             $urlBits = parse_url($this->url);
             $scheme = isset($urlBits['scheme']) && 'https' === $urlBits['scheme'] && extension_loaded('openssl') ? 'https' : 'http';
             $distUrl = "{$scheme}://{$packageDefinition->getChannelName()}/get/{$packageDefinition->getPackageName()}-{$version}.tgz";
             $requires = array();
             $suggests = array();
             $conflicts = array();
             $replaces = array();
             if ($channelInfo->getName() == $packageDefinition->getChannelName()) {
                 $composerPackageAlias = $this->buildComposerPackageName($channelInfo->getAlias(), $packageDefinition->getPackageName());
                 $aliasConstraint = new VersionConstraint('==', $normalizedVersion);
                 $replaces[] = new Link($composerPackageName, $composerPackageAlias, $aliasConstraint, 'replaces', (string) $aliasConstraint);
             }
             if (!empty($this->vendorAlias) && ($this->vendorAlias != 'pear-' . $channelInfo->getAlias() || $channelInfo->getName() != $packageDefinition->getChannelName())) {
                 $composerPackageAlias = "{$this->vendorAlias}/{$packageDefinition->getPackageName()}";
                 $aliasConstraint = new VersionConstraint('==', $normalizedVersion);
                 $replaces[] = new Link($composerPackageName, $composerPackageAlias, $aliasConstraint, 'replaces', (string) $aliasConstraint);
             }
             foreach ($releaseInfo->getDependencyInfo()->getRequires() as $dependencyConstraint) {
                 $dependencyPackageName = $this->buildComposerPackageName($dependencyConstraint->getChannelName(), $dependencyConstraint->getPackageName());
                 $constraint = $versionParser->parseConstraints($dependencyConstraint->getConstraint());
                 $link = new Link($composerPackageName, $dependencyPackageName, $constraint, $dependencyConstraint->getType(), $dependencyConstraint->getConstraint());
                 switch ($dependencyConstraint->getType()) {
                     case 'required':
                         $requires[] = $link;
                         break;
                     case 'conflicts':
                         $conflicts[] = $link;
                         break;
                     case 'replaces':
                         $replaces[] = $link;
                         break;
                 }
             }
             foreach ($releaseInfo->getDependencyInfo()->getOptionals() as $group => $dependencyConstraints) {
                 foreach ($dependencyConstraints as $dependencyConstraint) {
                     $dependencyPackageName = $this->buildComposerPackageName($dependencyConstraint->getChannelName(), $dependencyConstraint->getPackageName());
                     $suggests[$group . '-' . $dependencyPackageName] = $dependencyConstraint->getConstraint();
                 }
             }
             $package = new CompletePackage($composerPackageName, $normalizedVersion, $version);
             $package->setType('pear-library');
             $package->setDescription($packageDefinition->getDescription());
             $package->setDistType('file');
             $package->setDistUrl($distUrl);
             $package->setAutoload(array('classmap' => array('')));
             $package->setIncludePaths(array('/'));
             $package->setRequires($requires);
             $package->setConflicts($conflicts);
             $package->setSuggests($suggests);
             $package->setReplaces($replaces);
             $result[] = $package;
         }
     }
     return $result;
 }
Exemplo n.º 12
0
 static function filterPackage(CompletePackage $package)
 {
     $package->setHomepage('https://wordpress.org/');
     $package->setDescription('WordPress develop repo offering source files, unit tests, and i18n tools.');
 }