Skip to content

Commit

Permalink
Format Code using up-to-date PHP-CS
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen committed Oct 6, 2024
1 parent e84a6d7 commit b531e02
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private function addFileHeader(): void

$zip64Enabled = $footer !== '';

if($zip64Enabled) {
if ($zip64Enabled) {
$this->version = Version::ZIP64;
}

Expand Down Expand Up @@ -359,7 +359,7 @@ private function readStream(bool $send): void

private function compressionInit(): ?DeflateContext
{
switch($this->compressionMethod) {
switch ($this->compressionMethod) {
case CompressionMethod::STORE:
// Noting to do
return null;
Expand Down Expand Up @@ -390,7 +390,7 @@ private function getCdrFile(): string

return CentralDirectoryFileHeader::generate(
versionMadeBy: ZipStream::ZIP_VERSION_MADE_BY,
versionNeededToExtract:$this->version->value,
versionNeededToExtract: $this->version->value,
generalPurposeBitFlag: $this->generalPurposeBitFlag,
compressionMethod: $this->compressionMethod,
lastModificationDateTime: $this->lastModificationDateTime,
Expand Down
2 changes: 1 addition & 1 deletion src/PackField.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function pack(self ...$fields): string
}, '');

$args = array_map(function (self $field) {
switch($field->format) {
switch ($field->format) {
case 'V':
if ($field->value > self::MAX_V) {
throw new RuntimeException(print_r($field->value, true) . ' is larger than 32 bits');
Expand Down
3 changes: 1 addition & 2 deletions src/Zip64/ExtendedInformationExtraField.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public static function generate(
new PackField(format: 'v', value: self::TAG),
new PackField(
format: 'v',
value:
($originalSize === null ? 0 : 8) +
value: ($originalSize === null ? 0 : 8) +
($compressedSize === null ? 0 : 8) +
($relativeHeaderOffset === null ? 0 : 8) +
($diskStartNumber === null ? 0 : 4)
Expand Down
12 changes: 6 additions & 6 deletions src/ZipStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,11 @@ public function addFileFromCallback(
dataCallback: function () use ($callback, $maxSize) {
$data = $callback();

if(is_resource($data)) {
if (is_resource($data)) {
return $data;
}

if($data instanceof StreamInterface) {
if ($data instanceof StreamInterface) {
return StreamWrapper::getResource($data);
}

Expand Down Expand Up @@ -612,7 +612,7 @@ public function addFileFromCallback(
enableZeroHeader: $enableZeroHeader ?? $this->defaultEnableZeroHeader,
);

if($this->operationMode !== OperationMode::NORMAL) {
if ($this->operationMode !== OperationMode::NORMAL) {
$this->recordedSimulation[] = $file;
}

Expand Down Expand Up @@ -677,11 +677,11 @@ public function addDirectory(
*/
public function executeSimulation(): void
{
if($this->operationMode !== OperationMode::NORMAL) {
if ($this->operationMode !== OperationMode::NORMAL) {
throw new RuntimeException('Zip simulation is not finished.');
}

foreach($this->recordedSimulation as $file) {
foreach ($this->recordedSimulation as $file) {
$this->centralDirectoryRecords[] = $file->cloneSimulationExecution()->process();
}

Expand Down Expand Up @@ -855,7 +855,7 @@ private function clear(): void
$this->centralDirectoryRecords = [];
$this->offset = 0;

if($this->operationMode === OperationMode::NORMAL) {
if ($this->operationMode === OperationMode::NORMAL) {
$this->ready = false;
$this->recordedSimulation = [];
} else {
Expand Down
4 changes: 2 additions & 2 deletions test/Assertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected function assertFileContains(string $filePath, string $needle): void
while (!feof($handle)) {
$line = fgets($handle, 1024);

if(str_contains($last . $line, $needle)) {
if (str_contains($last . $line, $needle)) {
fclose($handle);
return;
}
Expand All @@ -35,7 +35,7 @@ protected function assertFileDoesNotContain(string $filePath, string $needle): v
while (!feof($handle)) {
$line = fgets($handle, 1024);

if(str_contains($last . $line, $needle)) {
if (str_contains($last . $line, $needle)) {
fclose($handle);

$this->fail("File {$filePath} must not contain {$needle}");
Expand Down
2 changes: 1 addition & 1 deletion test/EndlessCycleStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function isSeekable(): bool

public function seek(int $offset, int $whence = SEEK_SET): void
{
switch($whence) {
switch ($whence) {
case SEEK_SET:
$this->offset = $offset;
break;
Expand Down
2 changes: 1 addition & 1 deletion test/Tempfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp(): void
protected function tearDown(): void
{
unlink($this->tempfile);
if(is_resource($this->tempfileStream)) {
if (is_resource($this->tempfileStream)) {
fclose($this->tempfileStream);
}

Expand Down
2 changes: 1 addition & 1 deletion test/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function validateAndExtractZip(string $zipPath): string

protected function zipArchiveOpenErrorCodeName(int $code): string
{
switch($code) {
switch ($code) {
case ZipArchive::ER_EXISTS: return 'ER_EXISTS';
case ZipArchive::ER_INCONS: return 'ER_INCONS';
case ZipArchive::ER_INVAL: return 'ER_INVAL';
Expand Down
2 changes: 1 addition & 1 deletion test/ZipStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ public function testAddFileSimulateWithZeroSizeInFstat(): void
outputStream: $this->tempfileStream,
);

$zip->addFileFromPsr7Stream('sample.txt', new class () implements StreamInterface {
$zip->addFileFromPsr7Stream('sample.txt', new class implements StreamInterface {
public $pos = 0;

public function __toString(): string
Expand Down

0 comments on commit b531e02

Please sign in to comment.