original_string: public function getProjectVersionsAction($vendor, $project)
      {
          $this->checkUninstalled();
  
          $url     = sprintf('https://packagist.org/packages/%s/%s.json', $vendor, $project);
          $rfs     = new RemoteFilesystem($this->getInputOutput());
          $results = $rfs->getContents($url, $url);
          $data    = new JsonArray($results);
  
          $versions = [];
  
          foreach ($data->get('package/versions') as $information) {
              $version = [
                  'name'               => $information['name'],
                  'version'            => $information['version'],
                  'version_normalized' => $information['version_normalized'],
              ];
  
              $normalized = $information['version'];
              if ('dev-' === substr($normalized, 0, 4)) {
                  if (isset($information['extra']['branch-alias'][$normalized])) {
                      $version['version_normalized'] = $information['extra']['branch-alias'][$normalized];
                  }
              }
  
              if (isset($information['source']['reference'])) {
                  $version['reference'] = $information['source']['reference'];
              } elseif (isset($information['dist']['reference'])) {
                  $version['reference'] = $information['dist']['reference'];
              }
  
              $versions[] = $version;
          }
  
          return new JsonResponse(
              [
                  'status' => 'OK',
                  'versions' => $versions
              ]
          );
      }
code: public function getProjectVersionsAction($vendor, $project)
      {
          $this->checkUninstalled();
  
          $url     = sprintf('https://packagist.org/packages/%s/%s.json', $vendor, $project);
          $rfs     = new RemoteFilesystem($this->getInputOutput());
          $results = $rfs->getContents($url, $url);
          $data    = new JsonArray($results);
  
          $versions = [];
  
          foreach ($data->get('package/versions') as $information) {
              $version = [
                  'name'               => $information['name'],
                  'version'            => $information['version'],
                  'version_normalized' => $information['version_normalized'],
              ];
  
              $normalized = $information['version'];
              if ('dev-' === substr($normalized, 0, 4)) {
                  if (isset($information['extra']['branch-alias'][$normalized])) {
                      $version['version_normalized'] = $information['extra']['branch-alias'][$normalized];
                  }
              }
  
              if (isset($information['source']['reference'])) {
                  $version['reference'] = $information['source']['reference'];
              } elseif (isset($information['dist']['reference'])) {
                  $version['reference'] = $information['dist']['reference'];
              }
  
              $versions[] = $version;
          }
  
          return new JsonResponse(
              [
                  'status' => 'OK',
                  'versions' => $versions
              ]
          );
      }
code_tokens: public function getProjectVersionsAction ( $ vendor , $ project ) { $ this -> checkUninstalled ( ) ; $ url = sprintf ( 'https://packagist.org/packages/%s/%s.json' , $ vendor , $ project ) ; $ rfs = new RemoteFilesystem ( $ this -> getInputOutput ( ) ) ; $ results = $ rfs -> getContents ( $ url , $ url ) ; $ data = new JsonArray ( $ results ) ; $ versions = [ ] ; foreach ( $ data -> get ( 'package/versions' ) as $ information ) { $ version = [ 'name' => $ information [ 'name' ] , 'version' => $ information [ 'version' ] , 'version_normalized' => $ information [ 'version_normalized' ] , ] ; $ normalized = $ information [ 'version' ] ; if ( 'dev-' === substr ( $ normalized , 0 , 4 ) ) { if ( isset ( $ information [ 'extra' ] [ 'branch-alias' ] [ $ normalized ] ) ) { $ version [ 'version_normalized' ] = $ information [ 'extra' ] [ 'branch-alias' ] [ $ normalized ] ; } } if ( isset ( $ information [ 'source' ] [ 'reference' ] ) ) { $ version [ 'reference' ] = $ information [ 'source' ] [ 'reference' ] ; } elseif ( isset ( $ information [ 'dist' ] [ 'reference' ] ) ) { $ version [ 'reference' ] = $ information [ 'dist' ] [ 'reference' ] ; } $ versions [ ] = $ version ; } return new JsonResponse ( [ 'status' => 'OK' , 'versions' => $ versions ] ) ; }
docstring: Retrieve the available versions of a package.
  
  NOTE: This method will become inaccessible as soon as the installation is complete.
  
  @param string $vendor  The vendor name of the package.
  
  @param string $project The name of the package.
  
  @return JsonResponse
  
  @ApiDoc(
  section="install",
  statusCodes = {
  201 = "When everything worked out ok",
  406 = "When the installation is already complete"
  },
  )
  @ApiDescription(
  response={
  "versions" = {
  "actualType" = "collection",
  "subType" = "object",
  "description" = "The list of versions",
  "children" = {
  "name" = {
  "dataType" = "string",
  "description" = "The name of the package"
  },
  "version" = {
  "dataType" = "string",
  "description" = "The version of the package"
  },
  "version_normalized" = {
  "dataType" = "string",
  "description" = "The normalized version of the package"
  },
  "reference" = {
  "dataType" = "string",
  "description" = "The optional reference"
  }
  }
  }
  }
  )
docstring_tokens: Retrieve the available versions of a package .