<commit_before>const external = require('../helpers').external

module.exports.composerurl = composerurl
function composerurl (moduleName) {
  if (moduleName.split('/').length === 1) {
    // composer packages are like `user-or-project/package`.
    // but sometimes there seems to be a random `php` required on composer.json.
    return Promise.reject()
  }

  return external('composer', moduleName)
    .catch(() => ({
      url: `https://packagist.org/packages/${moduleName}`,
      kind: 'maybe'
    }))<commit_msg>Support for parsing PHP extensions<commit_after>const external = require('../helpers').external

module.exports.composerurl = composerurl
function composerurl (moduleName) {
  if (moduleName === 'php') {
    // package requires specific PHP version
    // ignore this when parsing
    return Promise.reject()
  }

  if (moduleName.startsWith('ext-') && moduleName.split('/').length === 1) {
    // package require specific PHP extension
    // link it to PHP documentation website
    let ext = moduleName.split('-')[1].toLowerCase()
    return Promise.resolve({
      url: `https://www.php.net/manual/en/book.${ext}.php`,
      kind: 'stdlib'
    })
  }

  // package require normal Composer package
  // link it to Packagist
  return external('composer', moduleName)
    .catch(() => ({
      url: `https://packagist.org/packages/${moduleName}`,
      kind: 'maybe'
    }))
{'fraction_non_alphanumeric': 0.15340501792114694, 'fraction_numerical': 0.002150537634408602, 'mean_word_length': 3.2822085889570554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2079826', 'n_tokens_mistral': 404, 'n_tokens_neox': 399, 'n_words': 105}