/** * {@inheritdoc} */ public function serializePackageFile(PackageFile $packageFile) { $this->assertVersionSupported($packageFile->getVersion()); $jsonData = (object) array('version' => $this->targetVersion); $this->packageFileToJson($packageFile, $jsonData); // Sort according to key order $jsonArray = (array) $jsonData; $orderedKeys = array_intersect_key(array_flip(self::$keyOrder), $jsonArray); $jsonData = (object) array_replace($orderedKeys, $jsonArray); $this->migrationManager->migrate($jsonData, $packageFile->getVersion()); return $this->encode($jsonData, $packageFile->getPath()); }