Skip to content

Commit

Permalink
feature: use strict_types
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemorroj committed Jan 4, 2024
1 parent 03b6f84 commit 32d0414
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 13 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@

### Features:

- Support all 7-zip formats: `7z`, `XZ`, `BZIP2`, `GZIP`, `TAR`, `ZIP`, `WIM`, `AR`, `ARJ`, `CAB`, `CHM`, `CPIO`, `CramFS`, `DMG`, `EXT`, `FAT`, `GPT`, `HFS`, `IHEX`, `ISO`, `LZH`, `LZMA`, `MBR`, `MSI`, `NSIS`, `NTFS`, `QCOW2`, `RAR`, `RPM`, `SquashFS`, `UDF`, `UEFI`, `VDI`, `VHD`, `VMDK`, `WIM`, `XAR` and `Z`
- Unpacking archives
- Extract any directory or file
- Supported all 7-zip formats:
- Packing / unpacking: `7z`, `XZ`, `BZIP2`, `GZIP`, `TAR`, `ZIP` and `WIM`.
- Unpacking only: `APFS`, `AR`, `ARJ`, `Base64`, `CAB`, `CHM`, `CPIO`, `CramFS`, `DMG`, `EXT`, `FAT`, `GPT`, `HFS`, `IHEX`, `ISO`, `LZH`, `LZMA`, `MBR`, `MSI`, `NSIS`, `NTFS`, `QCOW2`, `RAR`, `RPM`, `SquashFS`, `UDF`, `UEFI`, `VDI`, `VHD`, `VHDX`, `VMDK`, `XAR` and `Z`.
- List files and directories
- Get contents of any file from archive
- Delete files or directories (not `RAR`)
- Add files or directories (not `RAR`)
- Delete files or directories
- Add files or directories


### Requirements:

- PHP >= 8.0.2
- allow [proc_open](https://www.php.net/proc_open) function
- for Windows: 7-zip >= 7.30 (https://www.7-zip.org/)
- for Linux/MacOs: p7zip >= 9.38 (https://github.com/p7zip-project/p7zip). UPD: original 7-zip supports linux since 21.01 version?
- for Linux/MacOs: 7-zip >= 21.01 or p7zip >= 9.38 (https://github.com/p7zip-project/p7zip)


### Installation:
Expand Down
2 changes: 2 additions & 0 deletions src/Archive7z.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Archive7z;

use Symfony\Component\Process\Process;
Expand Down
12 changes: 8 additions & 4 deletions src/Archive7zTrait.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<?php

declare(strict_types=1);

namespace Archive7z;

trait Archive7zTrait
{
/**
* 7z uses plugins (7z.so and Codecs/Rar.so) to handle archives.
* 7za is a stand-alone executable (7za handles less archive formats than 7z).
* 7zr is a light stand-alone executable that supports only 7z/LZMA/BCJ/BCJ2.
* 7zz (7-Zip) - standalone full version of 7-Zip that supports all formats.
* 7zzs (7-Zip) - standalone full version of 7-Zip that supports all formats (static library linking).
* 7z (p7zip) - 7-Zip that requires 7z.so shared library, and it supports all formats via 7z.so.
* 7zr (p7zip) - standalone reduced version of 7-Zip that supports some 7-Zip's formats: 7z, xz, lzma and split.
* 7za (p7zip) - standalone version of 7-Zip that supports some main formats: 7z, xz, lzma, zip, bzip2, gzip, tar, cab, ppmd and split.
*
* @var string[]
*/
protected static array $binary7zNix = ['/usr/bin/7z', '/usr/bin/7za', '/usr/local/bin/7z', '/usr/local/bin/7za'];
protected static array $binary7zNix = ['/usr/bin/7z', '/usr/bin/7za', '/usr/bin/7zz', '/usr/local/bin/7z', '/usr/local/bin/7za', '/usr/local/bin/7zz'];
/**
* @var string[]
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Entry.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Archive7z;

/*
Expand Down
2 changes: 2 additions & 0 deletions src/Exception.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Archive7z;

class Exception extends \Exception
Expand Down
11 changes: 8 additions & 3 deletions src/Info.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Archive7z;

/*
Expand Down Expand Up @@ -63,6 +65,9 @@ public function __construct(Parser $parser)
}
}

/**
* @param string[] $headerData
*/
private function parseHeader(array $headerData): void
{
foreach ($headerData as $key => $value) {
Expand All @@ -76,11 +81,11 @@ private function parseHeader(array $headerData): void
break;

case 'Physical Size':
$this->physicalSize = $value;
$this->physicalSize = (int) $value;
break;

case 'Headers Size':
$this->headersSize = $value;
$this->headersSize = (int) $value;
break;

case 'Method':
Expand All @@ -92,7 +97,7 @@ private function parseHeader(array $headerData): void
break;

case 'Blocks':
$this->blocks = $value;
$this->blocks = (int) $value;
break;

case 'Code Page':
Expand Down
2 changes: 2 additions & 0 deletions src/Parser.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Archive7z;

class Parser
Expand Down
2 changes: 2 additions & 0 deletions src/SolidMode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Archive7z;

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Archive7zTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Archive7z\Tests;

use Archive7z\Archive7z;
Expand Down
2 changes: 2 additions & 0 deletions tests/EntryTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Archive7z\Tests;

use Archive7z\Archive7z;
Expand Down
2 changes: 2 additions & 0 deletions tests/ExceptionTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Archive7z\Tests;

use Archive7z\Exception;
Expand Down

0 comments on commit 32d0414

Please sign in to comment.