Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
dist: trusty
language: php
sudo: false
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- nightly
- hhvm
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- nightly
- hhvm
before_script:
- composer self-update
- composer install --prefer-source --no-interaction --dev
- composer install
script: ./vendor/bin/phpunit
after_success:
- sh generate-api.sh
- sh generate-api.sh
env:
global:
secure: ctCQVPQgQziwIZf5QGHcnhHlXsyauG0W3AWF/6R8cTP+in2S/RygunPp7CkXiqA1YMluGr2Lo9h4DTVg7oqeXl79FXFXedijQmQEu3g3f4iDWtxbQhGf4bJQk57jXFldge4rQedlOJDzwGzJ1abrimJQlu090BZNeonzWL5cRK4=
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "MIT",

"require": {
"php": ">=5.3.0"
"php": ">=5.4"
},

"suggest": {
Expand All @@ -20,12 +20,21 @@
},

"require-dev": {
"phpunit/phpunit": "4.5.*"
"phpunit/phpunit": "^4.8",
"mikey179/vfsStream": "^1.6",
"ext-zip": "*",
"ext-bz2": "*"
},

"autoload": {
"psr-4": {
"splitbrain\\PHPArchive\\": "src"
}
},

"autoload-dev": {
"psr-4": {
"splitbrain\\PHPArchive\\": "tests"
}
}
}
7 changes: 6 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
<filter>
<whitelist processUncoveredFilesFromWhitelist="false">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
10 changes: 5 additions & 5 deletions src/Tar.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function extract($outdir, $strip = '', $exclude = '', $include = '')

// extract data
if (!$fileinfo->getIsdir()) {
$fp = fopen($output, "wb");
$fp = @fopen($output, "wb");
if (!$fp) {
throw new ArchiveIOException('Could not open file for writing: '.$output);
}
Expand Down Expand Up @@ -245,7 +245,7 @@ public function addFile($file, $fileinfo = '')
throw new ArchiveIOException('Archive has been closed, files can no longer be added');
}

$fp = fopen($file, 'rb');
$fp = @fopen($file, 'rb');
if (!$fp) {
throw new ArchiveIOException('Could not open file for reading: '.$file);
}
Expand Down Expand Up @@ -379,7 +379,7 @@ public function save($file)
$this->setCompression($this->complevel, $this->filetype($file));
}

if (!file_put_contents($file, $this->getArchive())) {
if (!@file_put_contents($file, $this->getArchive())) {
throw new ArchiveIOException('Could not write to file: '.$file);
}
}
Expand Down Expand Up @@ -433,7 +433,7 @@ protected function writebytes($data)
*
* @param int $bytes seek to this position
*/
function skipbytes($bytes)
protected function skipbytes($bytes)
{
if ($this->comptype === Archive::COMPRESS_GZIP) {
@gzseek($this->fh, $bytes, SEEK_CUR);
Expand Down Expand Up @@ -645,7 +645,7 @@ public function filetype($file)
{
// for existing files, try to read the magic bytes
if(file_exists($file) && is_readable($file) && filesize($file) > 5) {
$fh = fopen($file, 'rb');
$fh = @fopen($file, 'rb');
if(!$fh) return false;
$magic = fread($fh, 5);
fclose($fh);
Expand Down
6 changes: 3 additions & 3 deletions src/Zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function contents()
* @throws ArchiveIOException
* @return FileInfo[]
*/
function extract($outdir, $strip = '', $exclude = '', $include = '')
public function extract($outdir, $strip = '', $exclude = '', $include = '')
{
if ($this->closed || !$this->file) {
throw new ArchiveIOException('Can not read from a closed archive');
Expand Down Expand Up @@ -163,7 +163,7 @@ function extract($outdir, $strip = '', $exclude = '', $include = '')
}

// open file for writing
$fp = fopen($extractto, "wb");
$fp = @fopen($extractto, "wb");
if (!$fp) {
throw new ArchiveIOException('Could not open file for writing: '.$extractto);
}
Expand Down Expand Up @@ -419,7 +419,7 @@ public function getArchive()
*/
public function save($file)
{
if (!file_put_contents($file, $this->getArchive())) {
if (!@file_put_contents($file, $this->getArchive())) {
throw new ArchiveIOException('Could not write to file: '.$file);
}
}
Expand Down
15 changes: 13 additions & 2 deletions tests/FileInfo.test.php → tests/FileInfoTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php

namespace splitbrain\PHPArchive;

use splitbrain\PHPArchive\FileInfo;
use PHPUnit\Framework\TestCase;

class FileInfoTest extends PHPUnit_Framework_TestCase
class FileInfoTest extends TestCase
{

public function testDefaults()
Expand Down Expand Up @@ -96,4 +99,12 @@ public function testFromPath()
$this->assertTrue($fileinfo->getIsdir());
$this->assertSame(0, $fileinfo->getSize());
}
}

/**
* @expectedException splitbrain\PHPArchive\FileInfoException
*/
public function testFromPathWithFileNotExisted()
{
$fileinfo = FileInfo::fromPath('invalid_file_path');
}
}
Loading