Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into dev-filefilessize
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 29 changed files with 59 additions and 76 deletions.
12 changes: 8 additions & 4 deletions src/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ public function setOptions($options)
} elseif (array_key_exists($key, $this->options)) {
$this->options[$key] = $value;
} else {
throw new Exception\InvalidArgumentException(sprintf(
'The option "%s" does not have a matching %s setter method or options[%s] array key',
$key, $setter, $key
));
throw new Exception\InvalidArgumentException(
sprintf(
'The option "%s" does not have a matching %s setter method or options[%s] array key',
$key,
$setter,
$key
)
);
}
}
return $this;
Expand Down
5 changes: 1 addition & 4 deletions src/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ public function __construct($typeOrOptions = null, $casting = true, $translation
}

if (is_array($typeOrOptions)) {
if (isset($typeOrOptions['type'])
|| isset($typeOrOptions['casting'])
|| isset($typeOrOptions['translations']))
{
if (isset($typeOrOptions['type']) || isset($typeOrOptions['casting']) || isset($typeOrOptions['translations'])) {
$this->setOptions($typeOrOptions);
} else {
$this->setType($typeOrOptions);
Expand Down
10 changes: 5 additions & 5 deletions src/Compress/Tar.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public function __construct($options = null)
if (!class_exists('Archive_Tar')) {
throw new Exception\ExtensionNotLoadedException(
'This filter needs PEAR\'s Archive_Tar component. '
. 'Ensure loading Archive_Tar (registering autoload or require_once)');
. 'Ensure loading Archive_Tar (registering autoload or require_once)'
);
}

parent::__construct($options);
Expand Down Expand Up @@ -171,10 +172,9 @@ public function compress($content)
if (is_dir($content)) {
// collect all file infos
foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($content, RecursiveDirectoryIterator::KEY_AS_PATHNAME),
RecursiveIteratorIterator::SELF_FIRST
) as $directory => $info
) {
new RecursiveDirectoryIterator($content, RecursiveDirectoryIterator::KEY_AS_PATHNAME),
RecursiveIteratorIterator::SELF_FIRST
) as $directory => $info) {
if ($info->isFile()) {
$file[] = $directory;
}
Expand Down
48 changes: 24 additions & 24 deletions src/Compress/Zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,76 +228,76 @@ public function decompress($content)
public function errorString($error)
{
switch ($error) {
case ZipArchive::ER_MULTIDISK :
case ZipArchive::ER_MULTIDISK:
return 'Multidisk ZIP Archives not supported';

case ZipArchive::ER_RENAME :
case ZipArchive::ER_RENAME:
return 'Failed to rename the temporary file for ZIP';

case ZipArchive::ER_CLOSE :
case ZipArchive::ER_CLOSE:
return 'Failed to close the ZIP Archive';

case ZipArchive::ER_SEEK :
case ZipArchive::ER_SEEK:
return 'Failure while seeking the ZIP Archive';

case ZipArchive::ER_READ :
case ZipArchive::ER_READ:
return 'Failure while reading the ZIP Archive';

case ZipArchive::ER_WRITE :
case ZipArchive::ER_WRITE:
return 'Failure while writing the ZIP Archive';

case ZipArchive::ER_CRC :
case ZipArchive::ER_CRC:
return 'CRC failure within the ZIP Archive';

case ZipArchive::ER_ZIPCLOSED :
case ZipArchive::ER_ZIPCLOSED:
return 'ZIP Archive already closed';

case ZipArchive::ER_NOENT :
case ZipArchive::ER_NOENT:
return 'No such file within the ZIP Archive';

case ZipArchive::ER_EXISTS :
case ZipArchive::ER_EXISTS:
return 'ZIP Archive already exists';

case ZipArchive::ER_OPEN :
case ZipArchive::ER_OPEN:
return 'Can not open ZIP Archive';

case ZipArchive::ER_TMPOPEN :
case ZipArchive::ER_TMPOPEN:
return 'Failure creating temporary ZIP Archive';

case ZipArchive::ER_ZLIB :
case ZipArchive::ER_ZLIB:
return 'ZLib Problem';

case ZipArchive::ER_MEMORY :
case ZipArchive::ER_MEMORY:
return 'Memory allocation problem while working on a ZIP Archive';

case ZipArchive::ER_CHANGED :
case ZipArchive::ER_CHANGED:
return 'ZIP Entry has been changed';

case ZipArchive::ER_COMPNOTSUPP :
case ZipArchive::ER_COMPNOTSUPP:
return 'Compression method not supported within ZLib';

case ZipArchive::ER_EOF :
case ZipArchive::ER_EOF:
return 'Premature EOF within ZIP Archive';

case ZipArchive::ER_INVAL :
case ZipArchive::ER_INVAL:
return 'Invalid argument for ZLIB';

case ZipArchive::ER_NOZIP :
case ZipArchive::ER_NOZIP:
return 'Given file is no zip archive';

case ZipArchive::ER_INTERNAL :
case ZipArchive::ER_INTERNAL:
return 'Internal error while working on a ZIP Archive';

case ZipArchive::ER_INCONS :
case ZipArchive::ER_INCONS:
return 'Inconsistent ZIP archive';

case ZipArchive::ER_REMOVE :
case ZipArchive::ER_REMOVE:
return 'Can not remove ZIP Archive';

case ZipArchive::ER_DELETED :
case ZipArchive::ER_DELETED:
return 'ZIP Entry has been deleted';

default :
default:
return 'Unknown error within ZIP Archive';
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/Encrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,20 @@ public function setAdapter($options = null)
$adapter = 'Zend\Filter\Encrypt\\' . ucfirst($adapter);
} elseif (!class_exists($adapter)) {
throw new Exception\DomainException(
sprintf('%s expects a valid registry class name; received "%s", which did not resolve',
sprintf(
'%s expects a valid registry class name; received "%s", which did not resolve',
__METHOD__,
$adapter
));
)
);
}

$this->adapter = new $adapter($options);
if (!$this->adapter instanceof Encrypt\EncryptionAlgorithmInterface) {
throw new Exception\InvalidArgumentException(
"Encoding adapter '" . $adapter
. "' does not implement Zend\\Filter\\Encrypt\\EncryptionAlgorithmInterface");
. "' does not implement Zend\\Filter\\Encrypt\\EncryptionAlgorithmInterface"
);
}

return $this;
Expand Down
1 change: 0 additions & 1 deletion src/File/Decrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public function filter($value)
$value = $value['tmp_name'];
}


if (!file_exists($value)) {
throw new Exception\InvalidArgumentException("File '$value' not found");
}
Expand Down
6 changes: 3 additions & 3 deletions src/File/Rename.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ protected function _convertOptions($options)
$files['source'] = (string) $value;
break;

case 'target' :
case 'target':
$files['target'] = (string) $value;
break;

case 'overwrite' :
case 'overwrite':
$files['overwrite'] = (bool) $value;
break;

case 'randomize' :
case 'randomize':
$files['randomize'] = (bool) $value;
break;

Expand Down
5 changes: 3 additions & 2 deletions src/File/RenameUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function filter($value)
$isFileUpload = true;
$uploadData = $value;
$sourceFile = $value['tmp_name'];
} else{
} else {
$uploadData = array(
'tmp_name' => $value,
'name' => $value,
Expand Down Expand Up @@ -218,7 +218,8 @@ protected function moveUploadedFile($sourceFile, $targetFile)
if (!$result || null !== $warningException) {
throw new Exception\RuntimeException(
sprintf("File '%s' could not be renamed. An error occurred while processing the file.", $sourceFile),
0, $warningException
0,
$warningException
);
}

Expand Down
3 changes: 1 addition & 2 deletions src/HtmlEntities.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,14 @@ public function setQuoteStyle($quoteStyle)
return $this;
}


/**
* Get encoding
*
* @return string
*/
public function getEncoding()
{
return $this->encoding;
return $this->encoding;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/PregReplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public function __construct($options = null)
$options = iterator_to_array($options);
}

if (!is_array($options)
|| (!isset($options['pattern']) && !isset($options['replacement'])))
{
if (!is_array($options) || (!isset($options['pattern']) && !isset($options['replacement']))) {
$args = func_get_args();
if (isset($args[0])) {
$this->setPattern($args[0]);
Expand Down
2 changes: 1 addition & 1 deletion src/RealPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getExists()
*/
public function filter($value)
{
if(!is_string($value)){
if (!is_string($value)) {
return $value;
}
$path = (string) $value;
Expand Down
2 changes: 1 addition & 1 deletion src/StringToLower.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function filter($value)
$value = (string) $value;

if ($this->options['encoding'] !== null) {
return mb_strtolower($value, $this->options['encoding']);
return mb_strtolower($value, $this->options['encoding']);
}

return strtolower($value);
Expand Down
2 changes: 1 addition & 1 deletion src/StringToUpper.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function filter($value)
$value = (string) $value;

if ($this->options['encoding'] !== null) {
return mb_strtoupper($value, $this->options['encoding']);
return mb_strtoupper($value, $this->options['encoding']);
}

return strtoupper($value);
Expand Down
4 changes: 1 addition & 3 deletions src/StringTrim.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ class StringTrim extends AbstractFilter
public function __construct($charlistOrOptions = null)
{
if ($charlistOrOptions !== null) {
if (!is_array($charlistOrOptions)
&& !$charlistOrOptions instanceof Traversable)
{
if (!is_array($charlistOrOptions) && !$charlistOrOptions instanceof Traversable) {
$this->setCharList($charlistOrOptions);
} else {
$this->setOptions($charlistOrOptions);
Expand Down
1 change: 0 additions & 1 deletion src/StripNewlines.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class StripNewlines extends AbstractFilter
{

/**
* Defined by Zend\Filter\FilterInterface
*
Expand Down
7 changes: 3 additions & 4 deletions src/StripTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ public function setTagsAllowed($tagsAllowed)
$tagName = strtolower($element);
// Store the tag as allowed with no attributes
$this->tagsAllowed[$tagName] = array();
}
// Otherwise, if a tag was provided with attributes
elseif (is_string($index) && (is_array($element) || is_string($element))) {
} elseif (is_string($index) && (is_array($element) || is_string($element))) {
// Otherwise, if a tag was provided with attributes
// Canonicalize the tag name
$tagName = strtolower($index);
// Canonicalize the attributes
Expand Down Expand Up @@ -189,7 +188,7 @@ public function filter($value)
if (!preg_match('/--\s*>/s', $value)) {
$value = '';
} else {
$value = preg_replace('/<(?:!(?:--[\s\S]*?--\s*)?(>))/s', '', $value);
$value = preg_replace('/<(?:!(?:--[\s\S]*?--\s*)?(>))/s', '', $value);
}

$value = $start . $value;
Expand Down
1 change: 0 additions & 1 deletion src/UriNormalize.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public function filter($value)
if ($this->enforcedScheme && (!$uri->getScheme())) {
$this->enforceScheme($uri);
}

} catch (UriException $ex) {
// We are unable to parse / enfore scheme with the given config and input
return $value;
Expand Down
1 change: 0 additions & 1 deletion src/Word/AbstractSeparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

abstract class AbstractSeparator extends AbstractFilter
{

protected $separator = ' ';

/**
Expand Down
1 change: 0 additions & 1 deletion test/BaseNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
class BaseNameTest extends \PHPUnit_Framework_TestCase
{

/**
* Ensures that the filter follows expected behavior
*
Expand Down
1 change: 0 additions & 1 deletion test/Compress/RarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ public function testSettingCallback()
$callback = array(__CLASS__, 'rarCompress');
$filter->setCallback($callback);
$this->assertEquals($callback, $filter->getCallback());

}

public function testSettingCallbackThrowsExceptionOnMissingCallback()
Expand Down
1 change: 0 additions & 1 deletion test/Compress/ZipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public function setUp()
file_put_contents($this->tmp . '/Compress/First/zipextracted.txt', 'compress me');
file_put_contents($this->tmp . '/Compress/zipextracted.txt', 'compress me');
}

}

public function tearDown()
Expand Down
1 change: 0 additions & 1 deletion test/Encrypt/BlockCipherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public function testBasicBlockCipher()
*/
public function testGetSetVector()
{

$filter = new BlockCipherEncryption(array('key' => 'testkey'));
$filter->setVector('1234567890123456');
$this->assertEquals('1234567890123456', $filter->getVector());
Expand Down
2 changes: 0 additions & 2 deletions test/Encrypt/OpensslTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public function testSetPublicKey()

$this->setExpectedException('\Zend\Filter\Exception\InvalidArgumentException', 'not valid');
$filter->setPublicKey(123);

}

/**
Expand Down Expand Up @@ -170,7 +169,6 @@ public function testSetPrivateKey()

$this->setExpectedException('\Zend\Filter\Exception\InvalidArgumentException', 'not valid');
$filter->setPrivateKey(123);

}

/**
Expand Down
1 change: 0 additions & 1 deletion test/File/EncryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
class EncryptTest extends \PHPUnit_Framework_TestCase
{

public function setUp()
{
if (! extension_loaded('mcrypt')) {
Expand Down
Loading

0 comments on commit 8933479

Please sign in to comment.