1
0
Fork 0

Store dev mode in installed.json, fixes #3008

pull/7999/head
Jordi Boggiano 2019-02-21 12:27:02 +01:00
parent 8fe2b9ec69
commit 60df892517
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
7 changed files with 21 additions and 13 deletions

View File

@ -62,7 +62,7 @@ script:
- ls -d tests/Composer/Test/* | grep -v TestCase.php | parallel --gnu --keep-order 'echo "Running {} tests"; ./vendor/bin/phpunit -c tests/complete.phpunit.xml --colors=always {} || (echo -e "\e[41mFAILED\e[0m {}" && exit 1);'
# Run PHPStan
- if [[ $PHPSTAN == "1" ]]; then
composer require --dev phpstan/phpstan-shim:^0.11 --ignore-platform-reqs &&
bin/composer require --dev phpstan/phpstan-shim:^0.11 --ignore-platform-reqs &&
vendor/bin/phpstan.phar analyse src tests --configuration=phpstan/config.neon --autoload-file=phpstan/autoload.php;
fi

View File

@ -616,7 +616,7 @@ class Installer
}
if ($this->executeOperations || $this->writeLock) {
$localRepo->write();
$localRepo->write($this->devMode);
}
$event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($jobType);
@ -628,7 +628,7 @@ class Installer
if ($this->executeOperations) {
// force source/dist urls to be updated for all packages
$this->processPackageUrls($pool, $policy, $localRepo, $repositories);
$localRepo->write();
$localRepo->write($this->devMode);
}
return array(0, $devPackages);

View File

@ -49,7 +49,12 @@ class FilesystemRepository extends WritableArrayRepository
}
try {
$packages = $this->file->read();
$data = $this->file->read();
if (isset($data['packages'])) {
$packages = $data['packages'];
} else {
$packages = $data;
}
if (!is_array($packages)) {
throw new \UnexpectedValueException('Could not parse package list from the repository');
@ -74,16 +79,16 @@ class FilesystemRepository extends WritableArrayRepository
/**
* Writes writable repository.
*/
public function write()
public function write($devMode)
{
$data = array();
$data = array('packages' => array(), 'dev' => $devMode);
$dumper = new ArrayDumper();
foreach ($this->getCanonicalPackages() as $package) {
$data[] = $dumper->dump($package);
$data['packages'][] = $dumper->dump($package);
}
usort($data, function ($a, $b) {
usort($data['packages'], function ($a, $b) {
return strcmp($a['name'], $b['name']);
});

View File

@ -24,7 +24,7 @@ class WritableArrayRepository extends ArrayRepository implements WritableReposit
/**
* {@inheritDoc}
*/
public function write()
public function write($devMode)
{
}

View File

@ -23,8 +23,10 @@ interface WritableRepositoryInterface extends RepositoryInterface
{
/**
* Writes repository (f.e. to the disc).
*
* @param bool $devMode Whether dev requirements were included or not in this installation
*/
public function write();
public function write($devMode);
/**
* Adds package to the repository.

View File

@ -20,7 +20,7 @@ class InstalledFilesystemRepositoryMock extends InstalledFilesystemRepository
{
}
public function write()
public function write($devMode)
{
}
}

View File

@ -95,11 +95,12 @@ class FilesystemRepositoryTest extends TestCase
->expects($this->once())
->method('write')
->with(array(
array('name' => 'mypkg', 'type' => 'library', 'version' => '0.1.10', 'version_normalized' => '0.1.10.0'),
'packages' => array(array('name' => 'mypkg', 'type' => 'library', 'version' => '0.1.10', 'version_normalized' => '0.1.10.0')),
'dev' => true,
));
$repository->addPackage($this->getPackage('mypkg', '0.1.10'));
$repository->write();
$repository->write(true);
}
private function createJsonFileMock()