You are here

protected function ExtraPackage::readPackageJson in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php \Wikimedia\Composer\Merge\ExtraPackage::readPackageJson()

Read the contents of a composer.json style file into an array.

The package contents are fixed up to be usable to create a Package object by providing dummy "name" and "version" values if they have not been provided in the file. This is consistent with the default root package loading behavior of Composer.

Parameters

string $path:

Return value

array

1 call to ExtraPackage::readPackageJson()
ExtraPackage::__construct in vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php

File

vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php, line 108

Class

ExtraPackage
Processing for a composer.json file that will be merged into a RootPackageInterface

Namespace

Wikimedia\Composer\Merge

Code

protected function readPackageJson($path) {
  $file = new JsonFile($path);
  $json = $file
    ->read();
  if (!isset($json['name'])) {
    $json['name'] = 'merge-plugin/' . strtr($path, DIRECTORY_SEPARATOR, '-');
  }
  if (!isset($json['version'])) {
    $json['version'] = '1.0.0';
  }
  return $json;
}