Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[NS] Migrated Zend_Filter to namespaces

- Also, added "BC-BREAKS" file
  • Loading branch information...
commit 9f63908d9280d811eb37284579e34722be1933e4 1 parent fc9fa42
@weierophinney weierophinney authored
Showing with 2,879 additions and 3,371 deletions.
  1. +1 −1  README-DEV.txt
  2. +14 −8 library/Zend/Filter/Alnum.php
  3. +14 −8 library/Zend/Filter/Alpha.php
  4. +8 −3 library/Zend/Filter/BaseName.php
  5. +26 −20 library/Zend/Filter/Boolean.php
  6. +13 −8 library/Zend/Filter/Callback.php
  7. +25 −20 library/Zend/Filter/Compress.php
  8. +10 −5 library/Zend/Filter/Compress/{CompressAbstract.php → AbstractCompressionAlgorithm.php}
  9. +18 −12 library/Zend/Filter/Compress/Bz2.php
  10. +6 −1 library/Zend/Filter/Compress/{CompressInterface.php → CompressionAlgorithm.php}
  11. +19 −13 library/Zend/Filter/Compress/Gz.php
  12. +12 −6 library/Zend/Filter/Compress/Lzf.php
  13. +21 −15 library/Zend/Filter/Compress/Rar.php
  14. +28 −22 library/Zend/Filter/Compress/Tar.php
  15. +48 −42 library/Zend/Filter/Compress/Zip.php
  16. +9 −4 library/Zend/Filter/Decompress.php
  17. +9 −4 library/Zend/Filter/Decrypt.php
  18. +8 −3 library/Zend/Filter/Digits.php
  19. +8 −3 library/Zend/Filter/Dir.php
  20. +19 −14 library/Zend/Filter/Encrypt.php
  21. +13 −1 library/Zend/Filter/Encrypt/{Interface.php → EncryptionAlgorithm.php}
  22. +32 −48 library/Zend/Filter/Encrypt/Mcrypt.php
  23. +36 −29 library/Zend/Filter/Encrypt/Openssl.php
  24. +7 −2 library/Zend/Filter/Exception.php
  25. +15 −9 library/Zend/Filter/File/Decrypt.php
  26. +16 −10 library/Zend/Filter/File/Encrypt.php
  27. +17 −11 library/Zend/Filter/File/LowerCase.php
  28. +23 −16 library/Zend/Filter/File/Rename.php
  29. +16 −10 library/Zend/Filter/File/UpperCase.php
  30. +8 −3 library/Zend/Filter/{Interface.php → Filter.php}
  31. +113 −0 library/Zend/Filter/FilterChain.php
  32. +19 −9 library/Zend/Filter/HtmlEntities.php
  33. +46 −38 library/Zend/Filter/Inflector.php
  34. +62 −53 library/Zend/Filter/Input.php
  35. +8 −3 library/Zend/Filter/Int.php
  36. +18 −12 library/Zend/Filter/LocalizedToNormalized.php
  37. +19 −12 library/Zend/Filter/NormalizedToLocalized.php
  38. +17 −12 library/Zend/Filter/Null.php
  39. +13 −9 library/Zend/Filter/PregReplace.php
  40. +12 −7 library/Zend/Filter/RealPath.php
  41. +22 −114 library/Zend/{Filter.php → Filter/StaticFilter.php}
  42. +15 −10 library/Zend/Filter/StringToLower.php
  43. +14 −9 library/Zend/Filter/StringToUpper.php
  44. +13 −8 library/Zend/Filter/StringTrim.php
  45. +8 −3 library/Zend/Filter/StripNewlines.php
  46. +13 −8 library/Zend/Filter/StripTags.php
  47. +10 −6 library/Zend/Filter/Word/{Separator/Abstract.php → AbstractSeparator.php}
  48. +7 −2 library/Zend/Filter/Word/CamelCaseToDash.php
  49. +15 −6 library/Zend/Filter/Word/CamelCaseToSeparator.php
  50. +7 −2 library/Zend/Filter/Word/CamelCaseToUnderscore.php
  51. +7 −2 library/Zend/Filter/Word/DashToCamelCase.php
  52. +15 −5 library/Zend/Filter/Word/DashToSeparator.php
  53. +7 −2 library/Zend/Filter/Word/DashToUnderscore.php
  54. +15 −6 library/Zend/Filter/Word/SeparatorToCamelCase.php
  55. +6 −2 library/Zend/Filter/Word/SeparatorToDash.php
  56. +12 −8 library/Zend/Filter/Word/SeparatorToSeparator.php
  57. +7 −2 library/Zend/Filter/Word/UnderscoreToCamelCase.php
  58. +7 −2 library/Zend/Filter/Word/UnderscoreToDash.php
  59. +7 −2 library/Zend/Filter/Word/UnderscoreToSeparator.php
  60. +2 −2 library/Zend/Loader/PluginLoader/PluginLoader.php
  61. +14 −17 tests/Zend/Filter/AlnumTest.php
  62. +14 −17 tests/Zend/Filter/AlphaTest.php
  63. +5 −27 tests/Zend/Filter/BaseNameTest.php
  64. +468 −469 tests/Zend/Filter/BooleanTest.php
  65. +16 −20 tests/Zend/Filter/CallbackTest.php
  66. +19 −42 tests/Zend/Filter/Compress/Bz2Test.php
  67. +18 −41 tests/Zend/Filter/Compress/GzTest.php
  68. +5 −28 tests/Zend/Filter/Compress/LzfTest.php
  69. +67 −92 tests/Zend/Filter/Compress/RarTest.php
  70. +59 −83 tests/Zend/Filter/Compress/TarTest.php
  71. +78 −125 tests/Zend/Filter/Compress/ZipTest.php
  72. +27 −50 tests/Zend/Filter/CompressTest.php
  73. +17 −40 tests/Zend/Filter/DecompressTest.php
  74. +24 −106 tests/Zend/Filter/DecryptTest.php
  75. +6 −18 tests/Zend/Filter/DigitsTest.php
  76. +5 −27 tests/Zend/Filter/DirTest.php
  77. +19 −23 tests/Zend/Filter/Encrypt/McryptTest.php
  78. +21 −25 tests/Zend/Filter/Encrypt/OpensslTest.php
  79. +25 −32 tests/Zend/Filter/EncryptTest.php
  80. +35 −42 tests/Zend/Filter/File/DecryptTest.php
  81. +31 −38 tests/Zend/Filter/File/EncryptTest.php
  82. +16 −33 tests/Zend/Filter/File/LowerCaseTest.php
  83. +54 −94 tests/Zend/Filter/File/RenameTest.php
  84. +16 −33 tests/Zend/Filter/File/UpperCaseTest.php
  85. +96 −0 tests/Zend/Filter/FilterChainTest.php
  86. +9 −12 tests/Zend/Filter/HtmlEntitiesTest.php
  87. +62 −105 tests/Zend/Filter/InflectorTest.php
  88. +13 −14 tests/Zend/Filter/InputTest.php
  89. +5 −27 tests/Zend/Filter/IntTest.php
  90. +17 −21 tests/Zend/Filter/LocalizedToNormalizedTest.php
  91. +15 −19 tests/Zend/Filter/NormalizedToLocalizedTest.php
  92. +106 −108 tests/Zend/Filter/NullTest.php
  93. +15 −43 tests/Zend/Filter/PregReplaceTest.php
  94. +16 −26 tests/Zend/Filter/RealPathTest.php
  95. +120 −0 tests/Zend/Filter/StaticFilterTest.php
  96. +21 −28 tests/Zend/Filter/StringToLowerTest.php
  97. +21 −28 tests/Zend/Filter/StringToUpperTest.php
  98. +15 −14 tests/Zend/Filter/StringTrimTest.php
  99. +5 −25 tests/Zend/Filter/StripNewlinesTest.php
  100. +71 −69 tests/Zend/Filter/StripTagsTest.php
  101. +5 −26 tests/Zend/Filter/Word/CamelCaseToDashTest.php
  102. +7 −27 tests/Zend/Filter/Word/CamelCaseToSeparatorTest.php
  103. +12 −32 tests/Zend/Filter/Word/CamelCaseToUnderscoreTest.php
  104. +5 −26 tests/Zend/Filter/Word/DashToCamelCaseTest.php
  105. +7 −28 tests/Zend/Filter/Word/DashToSeparatorTest.php
  106. +5 −26 tests/Zend/Filter/Word/DashToUnderscoreTest.php
  107. +7 −27 tests/Zend/Filter/Word/SeparatorToCamelCaseTest.php
  108. +7 −28 tests/Zend/Filter/Word/SeparatorToDashTest.php
  109. +9 −30 tests/Zend/Filter/Word/SeparatorToSeparatorTest.php
  110. +12 −33 tests/Zend/Filter/Word/UnderscoreToCamelCaseTest.php
  111. +5 −26 tests/Zend/Filter/Word/UnderscoreToDashTest.php
  112. +7 −28 tests/Zend/Filter/Word/UnderscoreToSeparatorTest.php
  113. +0 −242 tests/Zend/FilterTest.php
  114. +66 −0 working/BC-Breaks.txt
  115. +24 −24 working/PHPNamespacer-MappedClasses.xml
View
2  README-DEV.txt
@@ -27,7 +27,7 @@ First pass
[ ] Zend_Currency
Second pass:
-[ ] Zend_Filter
+[X] Zend_Filter
skip Input at first
[ ] Zend_Validate
skip Validate_Db at first
View
22 library/Zend/Filter/Alnum.php
@@ -20,14 +20,20 @@
*/
/**
- * @uses Zend_Filter_Interface
- * @uses Zend_Locale
+ * @namespace
+ */
+namespace Zend\Filter;
+use Zend\Locale\Locale;
+
+/**
+ * @uses \Zend\Filter\Filter
+ * @uses \Zend\Locale\Locale
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Alnum implements Zend_Filter_Interface
+class Alnum implements Filter
{
/**
* Whether to allow white space characters; off by default
@@ -47,7 +53,7 @@ class Zend_Filter_Alnum implements Zend_Filter_Interface
/**
* Locale in browser.
*
- * @var Zend_Locale object
+ * @var \Zend\Locale\Locale object
*/
protected $_locale;
@@ -66,7 +72,7 @@ class Zend_Filter_Alnum implements Zend_Filter_Interface
*/
public function __construct($allowWhiteSpace = false)
{
- if ($allowWhiteSpace instanceof Zend_Config) {
+ if ($allowWhiteSpace instanceof \Zend\Config\Config) {
$allowWhiteSpace = $allowWhiteSpace->toArray();
} else if (is_array($allowWhiteSpace)) {
if (array_key_exists('allowwhitespace', $allowWhiteSpace)) {
@@ -82,7 +88,7 @@ public function __construct($allowWhiteSpace = false)
}
if (null === self::$_meansEnglishAlphabet) {
- $this->_locale = new Zend_Locale('auto');
+ $this->_locale = new Locale('auto');
self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(),
array('ja', 'ko', 'zh')
);
@@ -104,7 +110,7 @@ public function getAllowWhiteSpace()
* Sets the allowWhiteSpace option
*
* @param boolean $allowWhiteSpace
- * @return Zend_Filter_Alnum Provides a fluent interface
+ * @return \Zend\Filter\Alnum Provides a fluent interface
*/
public function setAllowWhiteSpace($allowWhiteSpace)
{
@@ -120,7 +126,7 @@ public function setAllowWhiteSpace($allowWhiteSpace)
* @param string $value
* @return string
*/
- public function filter($value)
+ public function __invoke($value)
{
$whiteSpace = $this->allowWhiteSpace ? '\s' : '';
if (!self::$_unicodeEnabled) {
View
22 library/Zend/Filter/Alpha.php
@@ -20,14 +20,20 @@
*/
/**
- * @uses Zend_Filter_Interface
- * @uses Zend_Locale
+ * @namespace
+ */
+namespace Zend\Filter;
+use Zend\Locale\Locale;
+
+/**
+ * @uses \Zend\Filter\Filter
+ * @uses \Zend\Locale\Locale
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Alpha implements Zend_Filter_Interface
+class Alpha implements Filter
{
/**
* Whether to allow white space characters; off by default
@@ -47,7 +53,7 @@ class Zend_Filter_Alpha implements Zend_Filter_Interface
/**
* Locale in browser.
*
- * @var Zend_Locale object
+ * @var \Zend\Locale\Locale object
*/
protected $_locale;
@@ -66,7 +72,7 @@ class Zend_Filter_Alpha implements Zend_Filter_Interface
*/
public function __construct($allowWhiteSpace = false)
{
- if ($allowWhiteSpace instanceof Zend_Config) {
+ if ($allowWhiteSpace instanceof \Zend\Config\Config) {
$allowWhiteSpace = $allowWhiteSpace->toArray();
} else if (is_array($allowWhiteSpace)) {
if (array_key_exists('allowwhitespace', $allowWhiteSpace)) {
@@ -82,7 +88,7 @@ public function __construct($allowWhiteSpace = false)
}
if (null === self::$_meansEnglishAlphabet) {
- $this->_locale = new Zend_Locale('auto');
+ $this->_locale = new Locale('auto');
self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(),
array('ja', 'ko', 'zh')
);
@@ -104,7 +110,7 @@ public function getAllowWhiteSpace()
* Sets the allowWhiteSpace option
*
* @param boolean $allowWhiteSpace
- * @return Zend_Filter_Alpha Provides a fluent interface
+ * @return \Zend\Filter\Alpha Provides a fluent interface
*/
public function setAllowWhiteSpace($allowWhiteSpace)
{
@@ -120,7 +126,7 @@ public function setAllowWhiteSpace($allowWhiteSpace)
* @param string $value
* @return string
*/
- public function filter($value)
+ public function __invoke($value)
{
$whiteSpace = $this->allowWhiteSpace ? '\s' : '';
if (!self::$_unicodeEnabled) {
View
11 library/Zend/Filter/BaseName.php
@@ -20,13 +20,18 @@
*/
/**
- * @uses Zend_Filter_Interface
+ * @namespace
+ */
+namespace Zend\Filter;
+
+/**
+ * @uses \Zend\Filter\Filter
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_BaseName implements Zend_Filter_Interface
+class BaseName implements Filter
{
/**
* Defined by Zend_Filter_Interface
@@ -36,7 +41,7 @@ class Zend_Filter_BaseName implements Zend_Filter_Interface
* @param string $value
* @return string
*/
- public function filter($value)
+ public function __invoke($value)
{
return basename((string) $value);
}
View
46 library/Zend/Filter/Boolean.php
@@ -20,15 +20,21 @@
*/
/**
- * @uses Zend_Filter_Exception
- * @uses Zend_Filter_Interface
- * @uses Zend_Locale
+ * @namespace
+ */
+namespace Zend\Filter;
+use Zend\Locale\Locale;
+
+/**
+ * @uses \Zend\Filter\Exception
+ * @uses \Zend\Filter\Filter
+ * @uses \Zend\Locale\Locale
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Boolean implements Zend_Filter_Interface
+class Boolean implements Filter
{
const BOOLEAN = 1;
const INTEGER = 2;
@@ -80,11 +86,11 @@ class Zend_Filter_Boolean implements Zend_Filter_Interface
/**
* Constructor
*
- * @param string|array|Zend_Config $options OPTIONAL
+ * @param string|array|\Zend\Config\Config $options OPTIONAL
*/
public function __construct($options = null)
{
- if ($options instanceof Zend_Config) {
+ if ($options instanceof \Zend\Config\Config) {
$options = $options->toArray();
} elseif (!is_array($options)) {
$options = func_get_args();
@@ -131,8 +137,8 @@ public function getType()
* Set the null types
*
* @param integer|array $type
- * @throws Zend_Filter_Exception
- * @return Zend_Filter_Boolean
+ * @throws \Zend\Filter\Exception
+ * @return \Zend\Filter\Boolean
*/
public function setType($type = null)
{
@@ -152,7 +158,7 @@ public function setType($type = null)
}
if (!is_int($type) || ($type < 0) || ($type > self::ALL)) {
- throw new Zend_Filter_Exception('Unknown type');
+ throw new Exception('Unknown type');
}
$this->_type = $type;
@@ -172,23 +178,23 @@ public function getLocale()
/**
* Set the locales which are accepted
*
- * @param string|array|Zend_Locale $locale
- * @throws Zend_Filter_Exception
- * @return Zend_Filter_Boolean
+ * @param string|array|\Zend\Locale\Locale $locale
+ * @throws \Zend\Filter\Exception
+ * @return \Zend\Filter\Boolean
*/
public function setLocale($locale = null)
{
if (is_string($locale)) {
$locale = array($locale);
- } elseif ($locale instanceof Zend_Locale) {
+ } elseif ($locale instanceof Locale) {
$locale = array($locale->toString());
} elseif (!is_array($locale)) {
- throw new Zend_Filter_Exception('Locale has to be string, array or an instance of Zend_Locale');
+ throw new Exception('Locale has to be string, array or an instance of Zend_Locale');
}
foreach ($locale as $single) {
- if (!Zend_Locale::isLocale($single)) {
- throw new Zend_Filter_Exception("Unknown locale '$single'");
+ if (!Locale::isLocale($single)) {
+ throw new Exception("Unknown locale '$single'");
}
}
@@ -212,8 +218,8 @@ public function getCasting()
* @param boolean $locale When true this filter works like cast
* When false it recognises only true and false
* and all other values are returned as is
- * @throws Zend_Filter_Exception
- * @return Zend_Filter_Boolean
+ * @throws \Zend\Filter\Exception
+ * @return \Zend\Filter\Boolean
*/
public function setCasting($casting = true)
{
@@ -229,7 +235,7 @@ public function setCasting($casting = true)
* @param string $value
* @return string
*/
- public function filter($value)
+ public function __invoke($value)
{
$type = $this->getType();
$casting = $this->getCasting();
@@ -355,7 +361,7 @@ protected function _getLocalizedQuestion($value, $yes, $locale)
$question = 'no';
$return = false;
}
- $str = Zend_Locale::getTranslation($question, 'question', $locale);
+ $str = Locale::getTranslation($question, 'question', $locale);
$str = explode(':', $str);
if (!empty($str)) {
foreach($str as $no) {
View
21 library/Zend/Filter/Callback.php
@@ -20,14 +20,19 @@
*/
/**
- * @uses Zend_Filter_Exception
- * @uses Zend_Filter_Interface
+ * @namespace
+ */
+namespace Zend\Filter;
+
+/**
+ * @uses \Zend\Filter\Exception
+ * @uses \Zend\Filter\Filter
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Callback implements Zend_Filter_Interface
+class Callback implements Filter
{
/**
* Callback in a call_user_func format
@@ -51,7 +56,7 @@ class Zend_Filter_Callback implements Zend_Filter_Interface
*/
public function __construct($options)
{
- if ($options instanceof Zend_Config) {
+ if ($options instanceof \Zend\Config\Config) {
$options = $options->toArray();
} else if (!is_array($options) || !array_key_exists('callback', $options)) {
$options = func_get_args();
@@ -64,7 +69,7 @@ public function __construct($options)
}
if (!array_key_exists('callback', $options)) {
- throw new Zend_Filter_Exception('Missing callback to use');
+ throw new Exception('Missing callback to use');
}
$this->setCallback($options['callback']);
@@ -92,7 +97,7 @@ public function getCallback()
public function setCallback($callback, $options = null)
{
if (!is_callable($callback)) {
- throw new Zend_Filter_Exception('Callback can not be accessed');
+ throw new Exception('Callback can not be accessed');
}
$this->_callback = $callback;
@@ -114,7 +119,7 @@ public function getOptions()
* Sets new default options to the callback filter
*
* @param mixed $options Default options to set
- * @return Zend_Filter_Callback
+ * @return \Zend\Filter\Callback
*/
public function setOptions($options)
{
@@ -128,7 +133,7 @@ public function setOptions($options)
* @param $value mixed Options for the set callback
* @return mixed Result from the filter which was callbacked
*/
- public function filter($value)
+ public function __invoke($value)
{
$options = array();
View
45 library/Zend/Filter/Compress.php
@@ -20,17 +20,22 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter;
+
+/**
* Compresses a given string
*
- * @uses Zend_Filter_Exception
- * @uses Zend_Filter_Interface
- * @uses Zend_Loader
+ * @uses \Zend\Filter\Exception
+ * @uses \Zend\Filter\FilterInterface
+ * @uses \Zend\Loader
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Compress implements Zend_Filter_Interface
+class Compress implements Filter
{
/**
* Compression adapter
@@ -49,12 +54,12 @@ class Zend_Filter_Compress implements Zend_Filter_Interface
*/
public function __construct($options = null)
{
- if ($options instanceof Zend_Config) {
+ if ($options instanceof \Zend\Config\Config) {
$options = $options->toArray();
}
if (is_string($options)) {
$this->setAdapter($options);
- } elseif ($options instanceof Zend_Filter_Compress_CompressInterface) {
+ } elseif ($options instanceof Compress\CompressionAlgorithm) {
$this->setAdapter($options);
} elseif (is_array($options)) {
$this->setOptions($options);
@@ -65,7 +70,7 @@ public function __construct($options = null)
* Set filter setate
*
* @param array $options
- * @return Zend_Filter_Compress
+ * @return \Zend\Filter\Compress
*/
public function setOptions(array $options)
{
@@ -88,22 +93,22 @@ public function setOptions(array $options)
*/
public function getAdapter()
{
- if ($this->_adapter instanceof Zend_Filter_Compress_CompressInterface) {
+ if ($this->_adapter instanceof Compress\CompressionAlgorithm) {
return $this->_adapter;
}
$adapter = $this->_adapter;
$options = $this->getAdapterOptions();
if (!class_exists($adapter)) {
- if (Zend_Loader::isReadable('Zend/Filter/Compress/' . ucfirst($adapter) . '.php')) {
- $adapter = 'Zend_Filter_Compress_' . ucfirst($adapter);
+ if (\Zend\Loader::isReadable('Zend/Filter/Compress/' . ucfirst($adapter) . '.php')) {
+ $adapter = 'Zend\\Filter\\Compress\\' . ucfirst($adapter);
}
- Zend_Loader::loadClass($adapter);
+ \Zend\Loader::loadClass($adapter);
}
$this->_adapter = new $adapter($options);
- if (!$this->_adapter instanceof Zend_Filter_Compress_CompressInterface) {
- throw new Zend_Filter_Exception("Compression adapter '" . $adapter . "' does not implement Zend_Filter_Compress_CompressInterface");
+ if (!$this->_adapter instanceof Compress\CompressionAlgorithm) {
+ throw new Exception("Compression adapter '" . $adapter . "' does not implement Zend\\Filter\\Compress\\CompressionAlgorithm");
}
return $this->_adapter;
}
@@ -121,17 +126,17 @@ public function getAdapterName()
/**
* Sets compression adapter
*
- * @param string|Zend_Filter_Compress_CompressInterface $adapter Adapter to use
- * @return Zend_Filter_Compress
+ * @param string|\Zend\Filter\Compress\CompressInterface $adapter Adapter to use
+ * @return \Zend\Filter\Compress\Compress
*/
public function setAdapter($adapter)
{
- if ($adapter instanceof Zend_Filter_Compress_CompressInterface) {
+ if ($adapter instanceof Compress\CompressionAlgorithm) {
$this->_adapter = $adapter;
return $this;
}
if (!is_string($adapter)) {
- throw new Zend_Filter_Exception('Invalid adapter provided; must be string or instance of Zend_Filter_Compress_CompressInterface');
+ throw new Exception('Invalid adapter provided; must be string or instance of Zend\\Filter\\Compress\\CompressionAlgorithm');
}
$this->_adapter = $adapter;
@@ -170,21 +175,21 @@ public function __call($method, $options)
{
$adapter = $this->getAdapter();
if (!method_exists($adapter, $method)) {
- throw new Zend_Filter_Exception("Unknown method '{$method}'");
+ throw new Exception("Unknown method '{$method}'");
}
return call_user_func_array(array($adapter, $method), $options);
}
/**
- * Defined by Zend_Filter_Interface
+ * Defined by Zend_Filter_Filter
*
* Compresses the content $value with the defined settings
*
* @param string $value Content to compress
* @return string The compressed content
*/
- public function filter($value)
+ public function __invoke($value)
{
return $this->getAdapter()->compress($value);
}
View
15 ...Zend/Filter/Compress/CompressAbstract.php → ...Compress/AbstractCompressionAlgorithm.php
@@ -20,24 +20,29 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter\Compress;
+
+/**
* Abstract compression adapter
*
- * @uses Zend_Filter_Compress_CompressInterface
+ * @uses \Zend\Filter\Compress\CompressInterface
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-abstract class Zend_Filter_Compress_CompressAbstract implements Zend_Filter_Compress_CompressInterface
+abstract class AbstractCompressionAlgorithm implements CompressionAlgorithm
{
/**
* Class constructor
*
- * @param array|Zend_Config $options (Optional) Options to set
+ * @param array|\Zend\Config\Config $options (Optional) Options to set
*/
public function __construct($options = null)
{
- if ($options instanceof Zend_Config) {
+ if ($options instanceof \Zend\Config\Config) {
$options = $options->toArray();
}
@@ -69,7 +74,7 @@ public function getOptions($option = null)
* Sets all or one option
*
* @param array $options
- * @return Zend_Filter_Compress_Bz2
+ * @return \Zend\Filter\Compress\Bz2
*/
public function setOptions(array $options)
{
View
30 library/Zend/Filter/Compress/Bz2.php
@@ -20,16 +20,22 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter\Compress;
+use Zend\Filter\Exception;
+
+/**
* Compression adapter for Bz2
*
- * @uses Zend_Filter_Compress_CompressAbstract
- * @uses Zend_Filter_Exception
+ * @uses \Zend\Filter\Compress\AbstractCompressionAlgorithm
+ * @uses \Zend\Filter\Exception
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Compress_Bz2 extends Zend_Filter_Compress_CompressAbstract
+class Bz2 extends AbstractCompressionAlgorithm
{
/**
* Compression Options
@@ -48,12 +54,12 @@ class Zend_Filter_Compress_Bz2 extends Zend_Filter_Compress_CompressAbstract
/**
* Class constructor
*
- * @param array|Zend_Config $options (Optional) Options to set
+ * @param array|\Zend\Config\Config $options (Optional) Options to set
*/
public function __construct($options = null)
{
if (!extension_loaded('bz2')) {
- throw new Zend_Filter_Exception('This filter needs the bz2 extension');
+ throw new Exception('This filter needs the bz2 extension');
}
parent::__construct($options);
}
@@ -72,12 +78,12 @@ public function getBlocksize()
* Sets a new blocksize
*
* @param integer $level
- * @return Zend_Filter_Compress_Bz2
+ * @return \Zend\Filter\Compress\Bz2
*/
public function setBlocksize($blocksize)
{
if (($blocksize < 0) || ($blocksize > 9)) {
- throw new Zend_Filter_Exception('Blocksize must be between 0 and 9');
+ throw new Exception('Blocksize must be between 0 and 9');
}
$this->_options['blocksize'] = (int) $blocksize;
@@ -98,7 +104,7 @@ public function getArchive()
* Sets the archive to use for de-/compression
*
* @param string $archive Archive to use
- * @return Zend_Filter_Compress_Bz2
+ * @return \Zend\Filter\Compress\Bz2
*/
public function setArchive($archive)
{
@@ -118,7 +124,7 @@ public function compress($content)
if (!empty($archive)) {
$file = bzopen($archive, 'w');
if (!$file) {
- throw new Zend_Filter_Exception("Error opening the archive '" . $archive . "'");
+ throw new Exception("Error opening the archive '" . $archive . "'");
}
bzwrite($file, $content);
@@ -129,7 +135,7 @@ public function compress($content)
}
if (is_int($compressed)) {
- throw new Zend_Filter_Exception('Error during compression');
+ throw new Exception('Error during compression');
}
return $compressed;
@@ -151,7 +157,7 @@ public function decompress($content)
if (file_exists($archive)) {
$file = bzopen($archive, 'r');
if (!$file) {
- throw new Zend_Filter_Exception("Error opening the archive '" . $content . "'");
+ throw new Exception("Error opening the archive '" . $content . "'");
}
$compressed = bzread($file);
@@ -161,7 +167,7 @@ public function decompress($content)
}
if (is_int($compressed)) {
- throw new Zend_Filter_Exception('Error during decompression');
+ throw new Exception('Error during decompression');
}
return $compressed;
View
7 ...end/Filter/Compress/CompressInterface.php → .../Filter/Compress/CompressionAlgorithm.php
@@ -20,6 +20,11 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter\Compress;
+
+/**
* Compression interface
*
* @category Zend
@@ -27,7 +32,7 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-interface Zend_Filter_Compress_CompressInterface
+interface CompressionAlgorithm
{
/**
* Compresses $value with the defined settings
View
32 library/Zend/Filter/Compress/Gz.php
@@ -20,16 +20,22 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter\Compress;
+use Zend\Filter\Exception;
+
+/**
* Compression adapter for Gzip (ZLib)
*
- * @uses Zend_Filter_Compress_CompressAbstract
- * @uses Zend_Filter_Exception
+ * @uses \Zend\Filter\Compress\AbstractCompressionAlgorithm
+ * @uses \Zend\Filter\Exception
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Compress_Gz extends Zend_Filter_Compress_CompressAbstract
+class Gz extends AbstractCompressionAlgorithm
{
/**
* Compression Options
@@ -50,12 +56,12 @@ class Zend_Filter_Compress_Gz extends Zend_Filter_Compress_CompressAbstract
/**
* Class constructor
*
- * @param array|Zend_Config|null $options (Optional) Options to set
+ * @param array|\Zend\Config\Config|null $options (Optional) Options to set
*/
public function __construct($options = null)
{
if (!extension_loaded('zlib')) {
- throw new Zend_Filter_Exception('This filter needs the zlib extension');
+ throw new Exception('This filter needs the zlib extension');
}
parent::__construct($options);
}
@@ -74,12 +80,12 @@ public function getLevel()
* Sets a new compression level
*
* @param integer $level
- * @return Zend_Filter_Compress_Gz
+ * @return \Zend\Filter\Compress\Gz
*/
public function setLevel($level)
{
if (($level < 0) || ($level > 9)) {
- throw new Zend_Filter_Exception('Level must be between 0 and 9');
+ throw new Exception('Level must be between 0 and 9');
}
$this->_options['level'] = (int) $level;
@@ -104,7 +110,7 @@ public function getMode()
public function setMode($mode)
{
if (($mode != 'compress') && ($mode != 'deflate')) {
- throw new Zend_Filter_Exception('Given compression mode not supported');
+ throw new Exception('Given compression mode not supported');
}
$this->_options['mode'] = $mode;
@@ -125,7 +131,7 @@ public function getArchive()
* Sets the archive to use for de-/compression
*
* @param string $archive Archive to use
- * @return Zend_Filter_Compress_Gz
+ * @return \Zend\Filter\Compress\Gz
*/
public function setArchive($archive)
{
@@ -145,7 +151,7 @@ public function compress($content)
if (!empty($archive)) {
$file = gzopen($archive, 'w' . $this->getLevel());
if (!$file) {
- throw new Zend_Filter_Exception("Error opening the archive '" . $this->_options['archive'] . "'");
+ throw new Exception("Error opening the archive '" . $this->_options['archive'] . "'");
}
gzwrite($file, $content);
@@ -158,7 +164,7 @@ public function compress($content)
}
if (!$compressed) {
- throw new Zend_Filter_Exception('Error during compression');
+ throw new Exception('Error during compression');
}
return $compressed;
@@ -181,7 +187,7 @@ public function decompress($content)
if (file_exists($archive)) {
$handler = fopen($archive, "rb");
if (!$handler) {
- throw new Zend_Filter_Exception("Error opening the archive '" . $archive . "'");
+ throw new Exception("Error opening the archive '" . $archive . "'");
}
fseek($handler, -4, SEEK_END);
@@ -200,7 +206,7 @@ public function decompress($content)
}
if (!$compressed) {
- throw new Zend_Filter_Exception('Error during compression');
+ throw new Exception('Error during compression');
}
return $compressed;
View
18 library/Zend/Filter/Compress/Lzf.php
@@ -20,16 +20,22 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter\Compress;
+use Zend\Filter\Exception;
+
+/**
* Compression adapter for Lzf
*
- * @uses Zend_Filter_Compress_CompressInterface
- * @uses Zend_Filter_Exception
+ * @uses \Zend\Filter\Compress\CompressionAlgorithm
+ * @uses \Zend\Filter\Exception
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Compress_Lzf implements Zend_Filter_Compress_CompressInterface
+class Lzf implements CompressionAlgorithm
{
/**
* Class constructor
@@ -37,7 +43,7 @@ class Zend_Filter_Compress_Lzf implements Zend_Filter_Compress_CompressInterface
public function __construct()
{
if (!extension_loaded('lzf')) {
- throw new Zend_Filter_Exception('This filter needs the lzf extension');
+ throw new Exception('This filter needs the lzf extension');
}
}
@@ -51,7 +57,7 @@ public function compress($content)
{
$compressed = lzf_compress($content);
if (!$compressed) {
- throw new Zend_Filter_Exception('Error during compression');
+ throw new Exception('Error during compression');
}
return $compressed;
@@ -67,7 +73,7 @@ public function decompress($content)
{
$compressed = lzf_decompress($content);
if (!$compressed) {
- throw new Zend_Filter_Exception('Error during compression');
+ throw new Exception('Error during compression');
}
return $compressed;
View
36 library/Zend/Filter/Compress/Rar.php
@@ -20,16 +20,22 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter\Compress;
+use Zend\Filter\Exception;
+
+/**
* Compression adapter for Rar
*
- * @uses Zend_Filter_Compress_CompressAbstract
- * @uses Zend_Filter_Exception
+ * @uses \Zend\Filter\Compress\AbstractCompressionAlgorithm
+ * @uses \Zend\Filter\Exception
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Compress_Rar extends Zend_Filter_Compress_CompressAbstract
+class Rar extends AbstractCompressionAlgorithm
{
/**
* Compression Options
@@ -57,7 +63,7 @@ class Zend_Filter_Compress_Rar extends Zend_Filter_Compress_CompressAbstract
public function __construct($options = null)
{
if (!extension_loaded('rar')) {
- throw new Zend_Filter_Exception('This filter needs the rar extension');
+ throw new Exception('This filter needs the rar extension');
}
parent::__construct($options);
}
@@ -76,12 +82,12 @@ public function getCallback()
* Sets the callback to use
*
* @param string $callback
- * @return Zend_Filter_Compress_Rar
+ * @return \Zend\Filter\Compress\Rar
*/
public function setCallback($callback)
{
if (!is_callable($callback)) {
- throw new Zend_Filter_Exception('Callback can not be accessed');
+ throw new Exception('Callback can not be accessed');
}
$this->_options['callback'] = $callback;
@@ -102,7 +108,7 @@ public function getArchive()
* Sets the archive to use for de-/compression
*
* @param string $archive Archive to use
- * @return Zend_Filter_Compress_Rar
+ * @return \Zend\Filter\Compress\Rar
*/
public function setArchive($archive)
{
@@ -126,7 +132,7 @@ public function getPassword()
* Sets the password to use
*
* @param string $password
- * @return Zend_Filter_Compress_Rar
+ * @return \Zend\Filter\Compress\Rar
*/
public function setPassword($password)
{
@@ -148,12 +154,12 @@ public function getTarget()
* Sets the targetpath to use
*
* @param string $target
- * @return Zend_Filter_Compress_Rar
+ * @return \Zend\Filter\Compress\Rar
*/
public function setTarget($target)
{
if (!file_exists(dirname($target))) {
- throw new Zend_Filter_Exception("The directory '$target' does not exist");
+ throw new Exception("The directory '$target' does not exist");
}
$target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target);
@@ -171,7 +177,7 @@ public function compress($content)
{
$callback = $this->getCallback();
if (is_null($callback)) {
- throw new Zend_Filter_Exception('No compression callback available');
+ throw new Exception('No compression callback available');
}
$options = $this->getOptions();
@@ -179,7 +185,7 @@ public function compress($content)
$result = call_user_func($callback, $options, $content);
if ($result !== true) {
- throw new Zend_Filter_Exception('Error compressing the RAR Archive');
+ throw new Exception('Error compressing the RAR Archive');
}
return $this->getArchive();
@@ -197,7 +203,7 @@ public function decompress($content)
if (file_exists($content)) {
$archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
} elseif (empty($archive) || !file_exists($archive)) {
- throw new Zend_Filter_Exception('RAR Archive not found');
+ throw new Exception('RAR Archive not found');
}
$password = $this->getPassword();
@@ -208,7 +214,7 @@ public function decompress($content)
}
if (!$archive) {
- throw new Zend_Filter_Exception("Error opening the RAR Archive");
+ throw new Exception("Error opening the RAR Archive");
}
$target = $this->getTarget();
@@ -218,7 +224,7 @@ public function decompress($content)
$filelist = rar_list($archive);
if (!$filelist) {
- throw new Zend_Filter_Exception("Error reading the RAR Archive");
+ throw new Exception("Error reading the RAR Archive");
}
foreach($filelist as $file) {
View
50 library/Zend/Filter/Compress/Tar.php
@@ -20,20 +20,26 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter\Compress;
+use Zend\Filter\Exception;
+
+/**
* Compression adapter for Tar
*
* @uses Archive_Tar
* @uses RecursiveDirectoryIterator
* @uses RecursiveIteratorIterator
- * @uses Zend_Filter_Compress_CompressAbstract
- * @uses Zend_Filter_Exception
- * @uses Zend_Loader
+ * @uses \Zend\Filter\Compress\AbstractCompressionAlgorithm
+ * @uses \Zend\Filter\Exception
+ * @uses \Zend\Loader
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Compress_Tar extends Zend_Filter_Compress_CompressAbstract
+class Tar extends AbstractCompressionAlgorithm
{
/**
* Compression Options
@@ -59,9 +65,9 @@ public function __construct($options = null)
{
if (!class_exists('Archive_Tar')) {
try {
- Zend_Loader::loadClass('Archive_Tar');
- } catch (Zend_Exception $e) {
- throw new Zend_Filter_Exception('This filter needs PEARs Archive_Tar', 0, $e);
+ \Zend\Loader::loadClass('Archive_Tar');
+ } catch (\Zend\Exception $e) {
+ throw new Exception('This filter needs PEARs Archive_Tar', 0, $e);
}
}
@@ -82,7 +88,7 @@ public function getArchive()
* Sets the archive to use for de-/compression
*
* @param string $archive Archive to use
- * @return Zend_Filter_Compress_Tar
+ * @return \Zend\Filter\Compress\Tar
*/
public function setArchive($archive)
{
@@ -106,12 +112,12 @@ public function getTarget()
* Sets the targetpath to use
*
* @param string $target
- * @return Zend_Filter_Compress_Tar
+ * @return \Zend\Filter\Compress\Tar
*/
public function setTarget($target)
{
if (!file_exists(dirname($target))) {
- throw new Zend_Filter_Exception("The directory '$target' does not exist");
+ throw new Exception("The directory '$target' does not exist");
}
$target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target);
@@ -137,15 +143,15 @@ public function setMode($mode)
{
$mode = ucfirst(strtolower($mode));
if (($mode != 'Bz2') && ($mode != 'Gz')) {
- throw new Zend_Filter_Exception("The mode '$mode' is unknown");
+ throw new Exception("The mode '$mode' is unknown");
}
if (($mode == 'Bz2') && (!extension_loaded('bz2'))) {
- throw new Zend_Filter_Exception('This mode needs the bz2 extension');
+ throw new Exception('This mode needs the bz2 extension');
}
if (($mode == 'Gz') && (!extension_loaded('zlib'))) {
- throw new Zend_Filter_Exception('This mode needs the zlib extension');
+ throw new Exception('This mode needs the zlib extension');
}
}
@@ -157,7 +163,7 @@ public function setMode($mode)
*/
public function compress($content)
{
- $archive = new Archive_Tar($this->getArchive(), $this->getMode());
+ $archive = new \Archive_Tar($this->getArchive(), $this->getMode());
if (!file_exists($content)) {
$file = $this->getTarget();
if (is_dir($file)) {
@@ -166,7 +172,7 @@ public function compress($content)
$result = file_put_contents($file, $content);
if ($result === false) {
- throw new Zend_Filter_Exception('Error creating the temporary file');
+ throw new Exception('Error creating the temporary file');
}
$content = $file;
@@ -174,9 +180,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
+ foreach (new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator($content, \RecursiveDirectoryIterator::KEY_AS_PATHNAME),
+ \RecursiveIteratorIterator::SELF_FIRST
) as $directory => $info
) {
if ($info->isFile()) {
@@ -189,7 +195,7 @@ public function compress($content)
$result = $archive->create($content);
if ($result === false) {
- throw new Zend_Filter_Exception('Error creating the Tar archive');
+ throw new Exception('Error creating the Tar archive');
}
return $this->getArchive();
@@ -207,10 +213,10 @@ public function decompress($content)
if (file_exists($content)) {
$archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
} elseif (empty($archive) || !file_exists($archive)) {
- throw new Zend_Filter_Exception('Tar Archive not found');
+ throw new Exception('Tar Archive not found');
}
- $archive = new Archive_Tar($archive, $this->getMode());
+ $archive = new \Archive_Tar($archive, $this->getMode());
$target = $this->getTarget();
if (!is_dir($target)) {
$target = dirname($target);
@@ -218,7 +224,7 @@ public function decompress($content)
$result = $archive->extract($target);
if ($result === false) {
- throw new Zend_Filter_Exception('Error while extracting the Tar archive');
+ throw new Exception('Error while extracting the Tar archive');
}
return true;
View
90 library/Zend/Filter/Compress/Zip.php
@@ -20,17 +20,23 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter\Compress;
+use Zend\Filter\Exception;
+
+/**
* Compression adapter for zip
*
- * @uses Zend_Filter_Compress_CompressAbstract
- * @uses Zend_Filter_Exception
+ * @uses \Zend\Filter\Compress\AbstractCompressionAlgorithm
+ * @uses \Zend\Filter\Exception
* @uses ZipArchive
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Compress_Zip extends Zend_Filter_Compress_CompressAbstract
+class Zip extends AbstractCompressionAlgorithm
{
/**
* Compression Options
@@ -55,7 +61,7 @@ class Zend_Filter_Compress_Zip extends Zend_Filter_Compress_CompressAbstract
public function __construct($options = null)
{
if (!extension_loaded('zip')) {
- throw new Zend_Filter_Exception('This filter needs the zip extension');
+ throw new Exception('This filter needs the zip extension');
}
parent::__construct($options);
}
@@ -74,7 +80,7 @@ public function getArchive()
* Sets the archive to use for de-/compression
*
* @param string $archive Archive to use
- * @return Zend_Filter_Compress_Rar
+ * @return \Zend\Filter\Compress\Rar
*/
public function setArchive($archive)
{
@@ -98,12 +104,12 @@ public function getTarget()
* Sets the target to use
*
* @param string $target
- * @return Zend_Filter_Compress_Rar
+ * @return \Zend\Filter\Compress\Rar
*/
public function setTarget($target)
{
if (!file_exists(dirname($target))) {
- throw new Zend_Filter_Exception("The directory '$target' does not exist");
+ throw new Exception("The directory '$target' does not exist");
}
$target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target);
@@ -119,11 +125,11 @@ public function setTarget($target)
*/
public function compress($content)
{
- $zip = new ZipArchive();
- $res = $zip->open($this->getArchive(), ZipArchive::CREATE | ZipArchive::OVERWRITE);
+ $zip = new \ZipArchive();
+ $res = $zip->open($this->getArchive(), \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
if ($res !== true) {
- throw new Zend_Filter_Exception($this->_errorString($res));
+ throw new Exception($this->_errorString($res));
}
if (file_exists($content)) {
@@ -158,14 +164,14 @@ public function compress($content)
foreach ($files as $file) {
$zip->addFile($current . $file, $local . $file);
if ($res !== true) {
- throw new Zend_Filter_Exception($this->_errorString($res));
+ throw new Exception($this->_errorString($res));
}
}
}
} else {
$res = $zip->addFile($content, $basename);
if ($res !== true) {
- throw new Zend_Filter_Exception($this->_errorString($res));
+ throw new Exception($this->_errorString($res));
}
}
} else {
@@ -178,7 +184,7 @@ public function compress($content)
$res = $zip->addFromString($file, $content);
if ($res !== true) {
- throw new Zend_Filter_Exception($this->_errorString($res));
+ throw new Exception($this->_errorString($res));
}
}
@@ -198,10 +204,10 @@ public function decompress($content)
if (file_exists($content)) {
$archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
} elseif (empty($archive) || !file_exists($archive)) {
- throw new Zend_Filter_Exception('ZIP Archive not found');
+ throw new Exception('ZIP Archive not found');
}
- $zip = new ZipArchive();
+ $zip = new \ZipArchive();
$res = $zip->open($archive);
$target = $this->getTarget();
@@ -215,11 +221,11 @@ public function decompress($content)
}
if (empty($target) || !is_dir($target)) {
- throw new Zend_Filter_Exception('No target for ZIP decompression set');
+ throw new Exception('No target for ZIP decompression set');
}
if ($res !== true) {
- throw new Zend_Filter_Exception($this->_errorString($res));
+ throw new Exception($this->_errorString($res));
}
if (version_compare(PHP_VERSION, '5.2.8', '<')) {
@@ -231,7 +237,7 @@ public function decompress($content)
(substr($currName, 0, 4) == './..')
)
{
- throw new Zend_Filter_Exception('Upward directory traversal was detected inside ' . $archive
+ throw new Exception('Upward directory traversal was detected inside ' . $archive
. ' please use PHP 5.2.8 or greater to take advantage of path resolution features of '
. 'the zip extension in this decompress() method.'
);
@@ -241,7 +247,7 @@ public function decompress($content)
$res = @$zip->extractTo($target);
if ($res !== true) {
- throw new Zend_Filter_Exception($this->_errorString($res));
+ throw new Exception($this->_errorString($res));
}
$zip->close();
@@ -256,73 +262,73 @@ public function decompress($content)
protected 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 :
View
13 library/Zend/Filter/Decompress.php
@@ -20,25 +20,30 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter;
+
+/**
* Decompresses a given string
*
- * @uses Zend_Filter_Compress
+ * @uses \Zend\Filter\Compress\Compress
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Decompress extends Zend_Filter_Compress
+class Decompress extends Compress
{
/**
- * Defined by Zend_Filter_Interface
+ * Defined by Zend_Filter_Filter
*
* Decompresses the content $value with the defined settings
*
* @param string $value Content to decompress
* @return string The decompressed content
*/
- public function filter($value)
+ public function __invoke($value)
{
return $this->getAdapter()->decompress($value);
}
View
13 library/Zend/Filter/Decrypt.php
@@ -20,25 +20,30 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter;
+
+/**
* Decrypts a given string
*
- * @uses Zend_Filter_Encrypt
+ * @uses \Zend\Filter\Encrypt
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Decrypt extends Zend_Filter_Encrypt
+class Decrypt extends Encrypt
{
/**
- * Defined by Zend_Filter_Interface
+ * Defined by Zend\Filter\Filter
*
* Decrypts the content $value with the defined settings
*
* @param string $value Content to decrypt
* @return string The decrypted content
*/
- public function filter($value)
+ public function __invoke($value)
{
return $this->_adapter->decrypt($value);
}
View
11 library/Zend/Filter/Digits.php
@@ -20,13 +20,18 @@
*/
/**
- * @uses Zend_Filter_Interface
+ * @namespace
+ */
+namespace Zend\Filter;
+
+/**
+ * @uses \Zend\Filter\Filter
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Digits implements Zend_Filter_Interface
+class Digits implements Filter
{
/**
* Is PCRE is compiled with UTF-8 and Unicode support
@@ -57,7 +62,7 @@ public function __construct()
* @param string $value
* @return string
*/
- public function filter($value)
+ public function __invoke($value)
{
if (!self::$_unicodeEnabled) {
// POSIX named classes are not supported, use alternative 0-9 match
View
11 library/Zend/Filter/Dir.php
@@ -20,13 +20,18 @@
*/
/**
- * @uses Zend_Filter_Interface
+ * @namespace
+ */
+namespace Zend\Filter;
+
+/**
+ * @uses \Zend\Filter\Filter
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Dir implements Zend_Filter_Interface
+class Dir implements Filter
{
/**
* Defined by Zend_Filter_Interface
@@ -36,7 +41,7 @@ class Zend_Filter_Dir implements Zend_Filter_Interface
* @param string $value
* @return string
*/
- public function filter($value)
+ public function __invoke($value)
{
return dirname((string) $value);
}
View
33 library/Zend/Filter/Encrypt.php
@@ -20,17 +20,22 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter;
+
+/**
* Encrypts a given string
*
- * @uses Zend_Filter_Exception
- * @uses Zend_Filter_Interface
- * @uses Zend_Loader
+ * @uses \Zend\Filter\Exception
+ * @uses \Zend\Filter\FilterInterface
+ * @uses \Zend\Loader
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Encrypt implements Zend_Filter_Interface
+class Encrypt implements Filter
{
/**
* Encryption adapter
@@ -44,7 +49,7 @@ class Zend_Filter_Encrypt implements Zend_Filter_Interface
*/
public function __construct($options = null)
{
- if ($options instanceof Zend_Config) {
+ if ($options instanceof \Zend\Config\Config) {
$options = $options->toArray();
}
@@ -65,7 +70,7 @@ public function getAdapter()
* Sets new encryption options
*
* @param string|array $options (Optional) Encryption options
- * @return Zend_Filter_Encrypt
+ * @return \Zend\Filter\Encrypt\Encrypt
*/
public function setAdapter($options = null)
{
@@ -82,17 +87,17 @@ public function setAdapter($options = null)
$options = array();
}
- if (Zend_Loader::isReadable('Zend/Filter/Encrypt/' . ucfirst($adapter). '.php')) {
- $adapter = 'Zend_Filter_Encrypt_' . ucfirst($adapter);
+ if (\Zend\Loader::isReadable('Zend/Filter/Encrypt/' . ucfirst($adapter). '.php')) {
+ $adapter = 'Zend\\Filter\\Encrypt\\' . ucfirst($adapter);
}
if (!class_exists($adapter)) {
- Zend_Loader::loadClass($adapter);
+ \Zend\Loader::loadClass($adapter);
}
$this->_adapter = new $adapter($options);
- if (!$this->_adapter instanceof Zend_Filter_Encrypt_Interface) {
- throw new Zend_Filter_Exception("Encoding adapter '" . $adapter . "' does not implement Zend_Filter_Encrypt_Interface");
+ if (!$this->_adapter instanceof Encrypt\EncryptionAlgorithm) {
+ throw new Exception("Encoding adapter '" . $adapter . "' does not implement Zend\\Filter\\Encrypt\\EncryptionAlgorithm");
}
return $this;
@@ -108,21 +113,21 @@ public function __call($method, $options)
{
$part = substr($method, 0, 3);
if ((($part != 'get') and ($part != 'set')) or !method_exists($this->_adapter, $method)) {
- throw new Zend_Filter_Exception("Unknown method '{$method}'");
+ throw new Exception("Unknown method '{$method}'");
}
return call_user_func_array(array($this->_adapter, $method), $options);
}
/**
- * Defined by Zend_Filter_Interface
+ * Defined by Zend\Filter\Filter
*
* Encrypts the content $value with the defined settings
*
* @param string $value Content to encrypt
* @return string The encrypted content
*/
- public function filter($value)
+ public function __invoke($value)
{
return $this->_adapter->encrypt($value);
}
View
14 library/Zend/Filter/Encrypt/Interface.php → ...nd/Filter/Encrypt/EncryptionAlgorithm.php
@@ -20,6 +20,11 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter\Encrypt;
+
+/**
* Encryption interface
*
* @category Zend
@@ -27,7 +32,7 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-interface Zend_Filter_Encrypt_Interface
+interface EncryptionAlgorithm
{
/**
* Encrypts $value with the defined settings
@@ -44,4 +49,11 @@ public function encrypt($value);
* @return string The decrypted data
*/
public function decrypt($value);
+
+ /**
+ * Return the adapter name
+ *
+ * @return string
+ */
+ public function toString();
}
View
80 library/Zend/Filter/Encrypt/Mcrypt.php
@@ -20,16 +20,24 @@
*/
/**
+ * @namespace
+ */
+namespace Zend\Filter\Encrypt;
+use Zend\Filter\Exception,
+ Zend\Filter\Compress,
+ Zend\Filter\Decompress;
+
+/**
* Encryption adapter for mcrypt
*
- * @uses Zend_Filter_Encrypt_Interface
- * @uses Zend_Filter_Exception
+ * @uses \Zend\Filter\Encrypt\EncryptionAlgorithm
+ * @uses \Zend\Filter\Exception
* @category Zend
* @package Zend_Filter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Filter_Encrypt_Mcrypt implements Zend_Filter_Encrypt_Interface
+class Mcrypt implements EncryptionAlgorithm
{
/**
* Definitions for encryption
@@ -48,7 +56,7 @@ class Zend_Filter_Encrypt_Mcrypt implements Zend_Filter_Encrypt_Interface
'mode' => 'cbc',
'mode_directory' => '',
'vector' => null,
- 'salt' => false
+ 'salt' => false,
);
/**
@@ -58,25 +66,23 @@ class Zend_Filter_Encrypt_Mcrypt implements Zend_Filter_Encrypt_Interface
*/
protected $_compression;
- protected static $_srandCalled = false;
-
/**
* Class constructor
*
- * @param string|array|Zend_Config $options Cryption Options
+ * @param string|array|\Zend\Config\Config $options Cryption Options