diff --git a/src/FileInfo.php b/src/FileInfo.php index 11fca7e..6b07ae9 100644 --- a/src/FileInfo.php +++ b/src/FileInfo.php @@ -37,6 +37,24 @@ class FileInfo $this->setPath($path); } + /** + * Handle calls to deprecated methods + * + * @param string $name + * @param array $arguments + * @return mixed + */ + public function __call($name, $arguments) + { + if($name === 'match') { + trigger_error('FileInfo::match() is deprecated, use FileInfo::matchExpression() instead.', E_USER_NOTICE); + return call_user_func_array([$this, $name], $arguments); + } + + trigger_error('Call to undefined method FileInfo::'.$name.'()', E_USER_ERROR); + return null; + } + /** * Factory to build FileInfo from existing file or directory * @@ -324,7 +342,7 @@ class FileInfo * @param string $exclude Regular expression of files to exclude * @return bool */ - public function match($include = '', $exclude = '') + public function matchExpression($include = '', $exclude = '') { $extract = true; if ($include && !preg_match($include, $this->getPath())) { diff --git a/src/Tar.php b/src/Tar.php index 93483f6..d5bdd61 100644 --- a/src/Tar.php +++ b/src/Tar.php @@ -158,7 +158,7 @@ class Tar extends Archive $fileinfo->strip($strip); // skip unwanted files - if (!strlen($fileinfo->getPath()) || !$fileinfo->match($include, $exclude)) { + if (!strlen($fileinfo->getPath()) || !$fileinfo->matchExpression($include, $exclude)) { $this->skipbytes(ceil($header['size'] / 512) * 512); continue; } diff --git a/src/Zip.php b/src/Zip.php index 3dade80..c6ba9e5 100644 --- a/src/Zip.php +++ b/src/Zip.php @@ -142,7 +142,7 @@ class Zip extends Archive $fileinfo->strip($strip); // skip unwanted files - if (!strlen($fileinfo->getPath()) || !$fileinfo->match($include, $exclude)) { + if (!strlen($fileinfo->getPath()) || !$fileinfo->matchExpression($include, $exclude)) { continue; } diff --git a/tests/FileInfoTest.php b/tests/FileInfoTest.php index 02c7fbf..4df33ac 100644 --- a/tests/FileInfoTest.php +++ b/tests/FileInfoTest.php @@ -71,19 +71,28 @@ class FileInfoTest extends TestCase $this->assertEquals('baz/bang', $fileinfo->getPath()); } - public function testMatch() + public function testMatchExpression() { $fileinfo = new FileInfo('foo/bar/baz/bang'); - $this->assertTrue($fileinfo->match()); - $this->assertTrue($fileinfo->match('/bang/')); - $this->assertFalse($fileinfo->match('/bark/')); + $this->assertTrue($fileinfo->matchExpression()); + $this->assertTrue($fileinfo->matchExpression('/bang/')); + $this->assertFalse($fileinfo->matchExpression('/bark/')); - $this->assertFalse($fileinfo->match('', '/bang/')); - $this->assertTrue($fileinfo->match('', '/bark/')); + $this->assertFalse($fileinfo->matchExpression('', '/bang/')); + $this->assertTrue($fileinfo->matchExpression('', '/bark/')); - $this->assertFalse($fileinfo->match('/bang/', '/foo/')); - $this->assertTrue($fileinfo->match('/bang/', '/bark/')); + $this->assertFalse($fileinfo->matchExpression('/bang/', '/foo/')); + $this->assertTrue($fileinfo->matchExpression('/bang/', '/bark/')); + } + + /** + * @expectedException \PHPUnit_Framework_Error_Notice + */ + public function testMatchDeprecation() + { + $fileinfo = new FileInfo('foo/bar/baz/bang'); + $fileinfo->match('/bang/', '/bark/'); } public function testFromPath()