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' of https://github.com/zendframework/zf2 into zf…
Browse files Browse the repository at this point in the history
…-3371
  • Loading branch information
Show file tree
Hide file tree
Showing 79 changed files with 1,598 additions and 447 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"zendframework/zend-i18n": "Zend\\I18n component",
"zendframework/zend-servicemanager": "Zend\\ServiceManager component",
"zendframework/zend-uri": "Zend\\Uri component for UriNormalize filter",
"zendframework/zend-validator": "Zend\\Validator component"
"zendframework/zend-validator": "Zend\\Validator component",
"zendframework/zend-stdlib": "Zend\\Stdlib component"
},
"extra": {
"branch-alias": {
Expand Down
25 changes: 3 additions & 22 deletions src/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter;

use Traversable;
use Zend\Stdlib\ErrorHandler;
use Zend\Stdlib\StringUtils;

/**
* @category Zend
* @package Zend_Filter
*/
abstract class AbstractFilter implements FilterInterface
{
/**
Expand All @@ -26,27 +21,13 @@ abstract class AbstractFilter implements FilterInterface
*/
protected $options = array();

/**
* Is PCRE is compiled with UTF-8 and Unicode support
*
* @var bool
**/
protected static $hasPcreUnicodeSupport = null;

/**
* @return bool
* @deprecated Since 2.1.0
*/
public static function hasPcreUnicodeSupport()
{
if (static::$hasPcreUnicodeSupport === null) {
static::$hasPcreUnicodeSupport = false;
ErrorHandler::start();
if (defined('PREG_BAD_UTF8_OFFSET_ERROR') && preg_match('/\pL/u', 'a') == 1) {
static::$hasPcreUnicodeSupport = true;
}
ErrorHandler::stop();
}
return static::$hasPcreUnicodeSupport;
return StringUtils::hasPcreUnicodeSupport();
}

/**
Expand Down
5 changes: 0 additions & 5 deletions src/AbstractUnicode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter;

/**
* @category Zend
* @package Zend_Filter
*/
abstract class AbstractUnicode extends AbstractFilter
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/BaseName.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter;

/**
* @category Zend
* @package Zend_Filter
*/
class BaseName extends AbstractFilter
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter;

use Traversable;
use Zend\Stdlib\ArrayUtils;

/**
* @category Zend
* @package Zend_Filter
*/
class Boolean extends AbstractFilter
{
const TYPE_BOOLEAN = 1;
Expand Down
5 changes: 0 additions & 5 deletions src/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter;

use Traversable;

/**
* @category Zend
* @package Zend_Filter
*/
class Callback extends AbstractFilter
{
/**
Expand Down
4 changes: 0 additions & 4 deletions src/Compress.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter;
Expand All @@ -15,9 +14,6 @@

/**
* Compresses a given string
*
* @category Zend
* @package Zend_Filter
*/
class Compress extends AbstractFilter
{
Expand Down
4 changes: 0 additions & 4 deletions src/Compress/AbstractCompressionAlgorithm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter\Compress;
Expand All @@ -15,9 +14,6 @@

/**
* Abstract compression adapter
*
* @category Zend
* @package Zend_Filter
*/
abstract class AbstractCompressionAlgorithm implements CompressionAlgorithmInterface
{
Expand Down
4 changes: 0 additions & 4 deletions src/Compress/Bz2.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter\Compress;
Expand All @@ -14,9 +13,6 @@

/**
* Compression adapter for Bz2
*
* @category Zend
* @package Zend_Filter
*/
class Bz2 extends AbstractCompressionAlgorithm
{
Expand Down
4 changes: 0 additions & 4 deletions src/Compress/CompressionAlgorithmInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter\Compress;

/**
* Compression interface
*
* @category Zend
* @package Zend_Filter
*/
interface CompressionAlgorithmInterface
{
Expand Down
4 changes: 0 additions & 4 deletions src/Compress/Gz.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter\Compress;
Expand All @@ -14,9 +13,6 @@

/**
* Compression adapter for Gzip (ZLib)
*
* @category Zend
* @package Zend_Filter
*/
class Gz extends AbstractCompressionAlgorithm
{
Expand Down
4 changes: 0 additions & 4 deletions src/Compress/Lzf.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter\Compress;
Expand All @@ -14,9 +13,6 @@

/**
* Compression adapter for Lzf
*
* @category Zend
* @package Zend_Filter
*/
class Lzf implements CompressionAlgorithmInterface
{
Expand Down
4 changes: 0 additions & 4 deletions src/Compress/Rar.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter\Compress;
Expand All @@ -14,9 +13,6 @@

/**
* Compression adapter for Rar
*
* @category Zend
* @package Zend_Filter
*/
class Rar extends AbstractCompressionAlgorithm
{
Expand Down
77 changes: 77 additions & 0 deletions src/Compress/Snappy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Filter\Compress;

use Zend\Filter\Exception;

/**
* Compression adapter for php snappy (http://code.google.com/p/php-snappy/)
*/
class Snappy implements CompressionAlgorithmInterface
{
/**
* Class constructor
*
* @param null|array|\Traversable $options (Optional) Options to set
* @throws Exception\ExtensionNotLoadedException if snappy extension not loaded
*/
public function __construct($options = null)
{
if (!extension_loaded('snappy')) {
throw new Exception\ExtensionNotLoadedException('This filter needs the snappy extension');
}
}

/**
* Compresses the given content
*
* @param string $content
* @return string
* @throws Exception\RuntimeException on memory, output length or data warning
*/
public function compress($content)
{
$compressed = snappy_compress($content);

if ($compressed === false) {
throw new Exception\RuntimeException('Error while compressing.');
}

return $compressed;
}

/**
* Decompresses the given content
*
* @param string $content
* @return string
* @throws Exception\RuntimeException on memory, output length or data warning
*/
public function decompress($content)
{
$compressed = snappy_uncompress($content);

if ($compressed === false) {
throw new Exception\RuntimeException('Error while decompressing.');
}

return $compressed;
}

/**
* Returns the adapter name
*
* @return string
*/
public function toString()
{
return 'Snappy';
}
}
4 changes: 0 additions & 4 deletions src/Compress/Tar.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter\Compress;
Expand All @@ -17,9 +16,6 @@

/**
* Compression adapter for Tar
*
* @category Zend
* @package Zend_Filter
*/
class Tar extends AbstractCompressionAlgorithm
{
Expand Down
4 changes: 0 additions & 4 deletions src/Compress/Zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Filter
*/

namespace Zend\Filter\Compress;
Expand All @@ -15,9 +14,6 @@

/**
* Compression adapter for zip
*
* @category Zend
* @package Zend_Filter
*/
class Zip extends AbstractCompressionAlgorithm
{
Expand Down
Loading

0 comments on commit 07f05df

Please sign in to comment.