@@ -24,10 +24,10 @@ class Archive extends \ZipArchive
2424
2525
2626 /**
27- * @param bool $file
27+ * @param bool|string $file
2828 * @throws \Exception
2929 */
30- public function __construct ($ file = false )
30+ public function __construct (string | bool $ file = false )
3131 {
3232 if ($ file && is_file ($ file )) {
3333 $ this ->open ($ file );
@@ -41,11 +41,12 @@ public function __construct($file = false)
4141 * Get a file from apk Archive by name.
4242 *
4343 * @param string $name
44- * @param int $length
45- * @param int $flags
46- * @return mixed
44+ * @param int|null $length
45+ * @param int|null $flags
46+ * @return string|false
47+ * @throws \Exception
4748 */
48- public function getFromName ($ name , $ length = null , $ flags = null )
49+ public function getFromName (string $ name , int $ length = null , int $ flags = null ): string | false
4950 {
5051 if (strtolower (substr ($ name , -4 )) == '.xml ' ) {
5152 $ xmlParser = new XmlParser (new Stream ($ this ->getStream ($ name )));
@@ -59,33 +60,34 @@ public function getFromName($name, $length = null, $flags = null)
5960 * Returns an ApkStream which contains AndroidManifest.xml
6061 * @return Stream
6162 */
62- public function getManifestStream ()
63+ public function getManifestStream (): Stream
6364 {
6465 return new Stream ($ this ->getStream ('AndroidManifest.xml ' ));
6566 }
6667
6768 /**
6869 * @return SeekableStream
6970 */
70- public function getResourcesStream ()
71+ public function getResourcesStream (): SeekableStream
7172 {
7273 return new SeekableStream ($ this ->getStream ('resources.arsc ' ));
7374 }
7475
7576 /**
7677 * Returns an \ApkParser\Stream instance which contains classes.dex file
77- * @returns \ApkParser\Stream
78+ * @returns Stream
79+ * @throws \Exception
7880 */
79- public function getClassesDexStream ()
81+ public function getClassesDexStream (): Stream
8082 {
8183 return new Stream ($ this ->getStream ('classes.dex ' ));
8284 }
8385
8486 /**
8587 * Apk file path.
86- * @return string
88+ * @return bool| string
8789 */
88- public function getApkPath ()
90+ public function getApkPath (): bool | string
8991 {
9092 return $ this ->filePath ;
9193 }
@@ -94,19 +96,25 @@ public function getApkPath()
9496 * Apk file name
9597 * @return string
9698 */
97- public function getApkName ()
99+ public function getApkName (): string
98100 {
99101 return $ this ->fileName ;
100102 }
101103
102104
103- public function extractTo ($ destination , $ entries = null )
105+ /**
106+ * @param string $pathto
107+ * @param array|string|null $files
108+ * @return bool
109+ * @throws \Exception
110+ */
111+ public function extractTo (string $ pathto , array |string |null $ files = null ): bool
104112 {
105- if ($ extResult = parent ::extractTo ($ destination , $ entries )) {
106- $ xmlFiles = Utils::globRecursive ($ destination . '/*.xml ' );
113+ if ($ extResult = parent ::extractTo ($ pathto , $ files )) {
114+ $ xmlFiles = Utils::globRecursive ($ pathto . '/*.xml ' );
107115
108116 foreach ($ xmlFiles as $ xmlFile ) {
109- if ($ xmlFile == ($ destination . "/AndroidManifest.xml " )) {
117+ if ($ xmlFile == ($ pathto . "/AndroidManifest.xml " )) {
110118 XmlParser::decompressFile ($ xmlFile );
111119 }
112120 }
0 commit comments