Skip to content

Commit 01eddb5

Browse files
committed
Refactor JSON I/O to use Composer's JSONFile class.
Also - bump PHPUnit.
1 parent efcc16c commit 01eddb5

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

.travis.yml

-9
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ php:
2323
- 8.0
2424
- nightly
2525

26-
jobs:
27-
include:
28-
# Test PHP 8.0+ only with composer v2 while ignoring platform reqs
29-
# so conflicting dependencies like Symfony polyfills are not installed.
30-
- php: 8.0
31-
env: COMPOSER_VERSION="2"
32-
- php: nightly
33-
env: COMPOSER_VERSION="2"
34-
3526
matrix:
3627
allow_failures:
3728
- php: nightly

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"require-dev": {
1818
"composer/composer": "^2.0",
19-
"phpunit/phpunit": "~5.7",
19+
"phpunit/phpunit": "~5.7 | ~6.0 | ~7.0",
2020
"symfony/process": "^3"
2121
},
2222
"autoload": {

src/PackageApplicationRepository.php

+5-15
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ public function getPackageApplication(PackageInterface $targetPackage)
101101
throw new \RuntimeException('Cannot Loaded applied patches data file "%s"', $dataFile);
102102
}
103103

104-
$data = json_decode(file_get_contents($dataFile), true);
104+
$applicationJson = new JsonFile($dataFile);
105105

106-
return $this->createPackagePatchApplication($targetPackage, $data);
106+
return $this->createPackagePatchApplication($targetPackage, $applicationJson->read());
107107
}
108108

109109
/**
@@ -122,19 +122,9 @@ public function savePackageApplication(PackagePatchApplication $packagePatchAppl
122122
throw new \RuntimeException(sprintf('Package directory is not writable "%s"', dirname($dataFile)));
123123
}
124124

125-
file_put_contents($dataFile,
126-
$this->encodeData($this->transformPackagePatchApplicationToArray($packagePatchApplication))
127-
);
128-
}
129-
130-
/**
131-
* @param array $data
132-
* @return string
133-
*/
134-
private function encodeData(array $data)
135-
{
136-
return json_encode($data,
137-
JSON_PRETTY_PRINT + JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE
125+
$applicationFile = new JsonFile($dataFile);
126+
$applicationFile->write(
127+
$this->transformPackagePatchApplicationToArray($packagePatchApplication)
138128
);
139129
}
140130

0 commit comments

Comments
 (0)