*/ class Zip { /** * Gets content of the root composer.json inside a ZIP archive. */ public static function getComposerJson(string $pathToZip): ?string { if (!extension_loaded('zip')) { throw new \RuntimeException('The Zip Util requires PHP\'s zip extension'); } $zip = new \ZipArchive(); if ($zip->open($pathToZip) !== true) { return null; } if (0 === $zip->numFiles) { $zip->close(); return null; } $foundFileIndex = self::locateFile($zip, 'composer.json'); $content = null; $configurationFileName = $zip->getNameIndex($foundFileIndex); $stream = $zip->getStream($configurationFileName); if (false !== $stream) { $content = stream_get_contents($stream); } $zip->close(); return $content; } /** * Find a file by name, returning the one that has the shortest path. * * @throws \RuntimeException */ private static function locateFile(\ZipArchive $zip, string $filename): int { // return root composer.json if it is there and is a file if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) { return $index; } $topLevelPaths = []; for ($i = 0; $i < $zip->numFiles; $i++) { $name = $zip->getNameIndex($i); $dirname = dirname($name); // ignore OSX specific resource fork folder if (strpos($name, '__MACOSX') !== false) { continue; } // handle archives with proper TOC if ($dirname === '.') { $topLevelPaths[$name] = true; if (\count($topLevelPaths) > 1) { throw new \RuntimeException('Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: '.implode(',', array_keys($topLevelPaths))); } continue; } // handle archives which do not have a TOC record for the directory itself if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) { $topLevelPaths[$dirname.'/'] = true; if (\count($topLevelPaths) > 1) { throw new \RuntimeException('Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: '.implode(',', array_keys($topLevelPaths))); } } } if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) { return $index; } throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory'); } }__halt_compiler();----SIGNATURE:----s7Qr9p8WdkJc+mnL+HhQOzdNfpev0PLJYsvq9R/jnfchmCdtsJWVOwiX6wzhPYjnnhnyDj0y5ZjBqXki6GquZk3MzKKNu1vuWIyZBbiQjZWWhEL/NKAuAEY0mjaCWlSE/XlYyrqxNUZJJqYcm5+FfUt45cBQe24rt24XnecXA3d8ZdREu+PVcwDUYE3Uz5Dgh0zREeX1zYuOoSkTDiziCdm5LVWWFSiYo9wqLqwn8l80xkFbvvKB8JwIW/qUQZe1koW9wOx3eFaTGcXYzW+PYFHmVZIPy084Fr/erMh43CDHZwqODoAfgF9n475f6mtxvpWAM4StXMRt0yh/m+f/ysfKh+zYs4EG1y6WX00rLIt8w82u6tXWAZwlrwPWMB+Ma35duxbQrznvM+wbu5VSsrpbyNO98WgTA/v7xkp+ANRlwzmf2o8KeEJ9JWHh01tlAxdjS+iYXoDcjE+gUrmWBA3fsEA7ytBI3+14HDknEUzZluIFwvATDFArE5Zk5Iw+WJMVSTzCvjLMXdbDkB3YdJHsDXu1xRKTvpcL2yOW0Dfqiv1GYIAePNFnGbKpXpqUAloOqkOrsBNTE1kmpDFXzy7syukrj9BJWbc9LXC+u7P7BLa9MsfrLeMTUZ3dGffEIOECQ8BNzvryUM9Y0o9oKMFkVgaSYPn4cV9cf5p0/6o=----ATTACHMENT:----NzQzMTI5NDQyNDMyMjc3MSA1Nzk3Mzk3MjQyODY3MDkzIDgyOTU3Nzg1Mjk3MzI4MTA=