From 5c4a417149a3119be72370dc0344ca985f5dfa6b Mon Sep 17 00:00:00 2001 From: Jay Klehr Date: Mon, 16 Apr 2018 08:10:15 -0600 Subject: [PATCH] adding grumphp, php-cs-fixer, fixing style, narrowing namespace --- .gitignore | 3 +- .php_cs | 22 ++++++ .travis.yml | 14 +++- composer.json | 30 ++++++-- grumphp.yml.dist | 17 +++++ phpstan.neon | 5 +- phpunit.xml.dist | 5 ++ require-checker-config.json | 20 +++++ src/Zend/Filter.php | 1 - src/Zend/Filter/Alnum.php | 16 ++-- src/Zend/Filter/Alpha.php | 16 ++-- src/Zend/Filter/Boolean.php | 4 +- src/Zend/Filter/Callback.php | 2 +- src/Zend/Filter/Compress/Gz.php | 8 +- src/Zend/Filter/Compress/Rar.php | 10 +-- src/Zend/Filter/Compress/Tar.php | 14 ++-- src/Zend/Filter/Compress/Zip.php | 68 ++++++++--------- src/Zend/Filter/Digits.php | 2 +- src/Zend/Filter/Encrypt.php | 4 +- src/Zend/Filter/Encrypt/Mcrypt.php | 11 +-- src/Zend/Filter/Encrypt/Openssl.php | 30 ++++---- src/Zend/Filter/Exception.php | 3 +- src/Zend/Filter/File/Rename.php | 13 ++-- src/Zend/Filter/HtmlEntities.php | 6 +- src/Zend/Filter/Inflector.php | 35 ++++----- src/Zend/Filter/LocalizedToNormalized.php | 4 +- src/Zend/Filter/NormalizedToLocalized.php | 4 +- src/Zend/Filter/Null.php | 22 +++--- src/Zend/Filter/PregReplace.php | 9 +-- src/Zend/Filter/StringToLower.php | 2 +- src/Zend/Filter/StringToUpper.php | 2 +- src/Zend/Filter/StringTrim.php | 2 +- src/Zend/Filter/StripNewlines.php | 2 +- src/Zend/Filter/StripTags.php | 16 ++-- src/Zend/Filter/Word/CamelCaseToSeparator.php | 2 - src/Zend/Filter/Word/DashToSeparator.php | 1 - src/Zend/Filter/Word/Separator/Abstract.php | 2 - src/Zend/Filter/Word/SeparatorToCamelCase.php | 6 +- src/Zend/Filter/Word/SeparatorToDash.php | 1 - src/Zend/Filter/Word/SeparatorToSeparator.php | 4 +- tests/Zend/Filter/AlnumTest.php | 47 ++++++------ tests/Zend/Filter/AlphaTest.php | 76 ++++++++++--------- tests/Zend/Filter/BooleanTest.php | 4 +- tests/Zend/Filter/Compress/Bz2Test.php | 10 +-- tests/Zend/Filter/Compress/GzTest.php | 12 +-- tests/Zend/Filter/Compress/LzfTest.php | 2 +- tests/Zend/Filter/Compress/RarTest.php | 13 ++-- tests/Zend/Filter/Compress/TarTest.php | 24 +++--- tests/Zend/Filter/Compress/ZipTest.php | 20 ++--- tests/Zend/Filter/CompressTest.php | 14 ++-- tests/Zend/Filter/DecompressTest.php | 6 +- tests/Zend/Filter/DecryptTest.php | 12 +-- tests/Zend/Filter/DigitsTest.php | 4 +- tests/Zend/Filter/Encrypt/McryptTest.php | 33 ++++---- tests/Zend/Filter/Encrypt/OpensslTest.php | 13 ++-- tests/Zend/Filter/EncryptTest.php | 38 +++++----- tests/Zend/Filter/File/DecryptTest.php | 63 ++++++++------- tests/Zend/Filter/File/EncryptTest.php | 54 +++++++------ tests/Zend/Filter/File/LowerCaseTest.php | 4 +- tests/Zend/Filter/File/RenameTest.php | 18 +++-- tests/Zend/Filter/File/UpperCaseTest.php | 4 +- tests/Zend/Filter/InflectorTest.php | 25 +++--- .../Zend/Filter/LocalizedToNormalizedTest.php | 30 ++++---- .../Zend/Filter/NormalizedToLocalizedTest.php | 62 +++++++-------- tests/Zend/Filter/PregReplaceTest.php | 2 +- tests/Zend/Filter/RealPathTest.php | 2 +- tests/Zend/Filter/StripNewlinesTest.php | 18 ++--- tests/Zend/Filter/StripTagsTest.php | 22 +++--- .../Filter/Word/CamelCaseToUnderscoreTest.php | 6 +- .../Zend/Filter/Word/DashToSeparatorTest.php | 1 - .../Zend/Filter/Word/SeparatorToDashTest.php | 1 - .../Filter/Word/SeparatorToSeparatorTest.php | 1 - .../Filter/Word/UnderscoreToCamelCaseTest.php | 2 +- .../Filter/Word/UnderscoreToSeparatorTest.php | 1 - .../_files/TestNamespace/StringEquals.php | 2 - tests/Zend/FilterTest.php | 4 +- 76 files changed, 602 insertions(+), 486 deletions(-) create mode 100644 .php_cs create mode 100644 grumphp.yml.dist create mode 100644 require-checker-config.json diff --git a/.gitignore b/.gitignore index bfd8159..0bb322f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /vendor /composer.lock /clover.xml -/tests/Zend/Filter/_files/Users \ No newline at end of file +/tests/Zend/Filter/_files/Users +.php_cs.cache diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..acac6b1 --- /dev/null +++ b/.php_cs @@ -0,0 +1,22 @@ +exclude('vendor') + ->files() + ->in(__DIR__) +; + +return PhpCsFixer\Config::create() + ->setRiskyAllowed(true) + ->setRules([ + '@PSR2' => true, + '@PHPUnit60Migration:risky' => true, + 'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => true], + 'single_quote' => true, + 'array_syntax' => ['syntax' => 'long'], + 'concat_space' => ['spacing' => 'one'], + 'psr0' => true + ]) + ->setUsingCache(true) + ->setFinder($finder); +; diff --git a/.travis.yml b/.travis.yml index 5e02ac6..26e9e8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ install: stages: - test + - style check - phpstan analysis - test with coverage @@ -34,6 +35,11 @@ jobs: allow_failures: - php: nightly include: + - stage: style check + php: 7.1 + env: TMPDIR=/tmp USE_XDEBUG=false + script: + - composer style-check - stage: phpstan analysis php: 7.1 env: TMPDIR=/tmp USE_XDEBUG=false @@ -41,8 +47,14 @@ jobs: - composer phpstan - stage: test with coverage php: 7.1 - env: TMPDIR=/tmp USE_XDEBUG=true + env: TMPDIR=/tmp USE_XDEBUG=true CC_TEST_REPORTER_ID=8f28da13e0ea0172cf806fdf90c46437edc8b2bda156e9849e9b2d2215df8cd1 + before_script: + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + - chmod +x ./cc-test-reporter + - ./cc-test-reporter before-build script: - composer test-with-coverage after_success: - bash <(curl -s https://codecov.io/bash) -f ./clover.xml + after_script: + - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT diff --git a/composer.json b/composer.json index f422129..4de954e 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,11 @@ }, "autoload": { "psr-0": { - "Zend_": "src/" - } + "Zend_Filter_": "src/" + }, + "classmap": [ + "src/Zend/Filter.php" + ] }, "autoload-dev": { "psr-0": { @@ -40,7 +43,10 @@ "phpunit/phpunit": "^6.0", "phpstan/phpstan": "^0.9.2", "jetbrains/phpstorm-stubs": "dev-phpstan", - "pear/archive_tar": "^1.4" + "pear/archive_tar": "^1.4", + "friendsofphp/php-cs-fixer": "^2.11", + "maglnet/composer-require-checker": "^0.1.6 | ^0.2.1", + "phpro/grumphp": "^0.14.0" }, "include-path": [ "src/" @@ -49,11 +55,23 @@ "exclude": ["/tests"] }, "scripts": { - "test": "phpunit ./tests", - "test-with-coverage": "phpunit --coverage-clover=clover.xml ./tests", - "phpstan": "phpstan analyze -l6 -c phpstan.neon --no-progress ./src --ansi" + "test": "phpunit", + "test-with-coverage": "phpunit --coverage-clover=clover.xml", + "phpstan": "phpstan analyze -l6 -c phpstan.neon --no-progress ./ --ansi", + "style-check": "php-cs-fixer fix --dry-run -vv" }, "suggest": { + "ext-iconv": "Optionally used in the Zend_Filter_HtmlEntities filter", + "ext-ctype": "Used in the Zend_Filter_Encrypt_Openssl filter", + "ext-mbstring": "Optionally used in the Zend_Filter_StringToLower/Upper filters", + "ext-mcrypt": "Used in the Zend_Filter_Encrypt_Mcrypt filter", + "ext-zlib": "Used in the Zend_Filter_Compress_Gz filter", + "ext-openssl": "Used in the Zend_Filter_Encrypt_Openssl filter", + "ext-bz2": "Used in the Zend_Filter_Compress_Bz2 and (optionally) in the Zend_Filter_Compress_Tar filters", + "ext-zip": "Used in the Zend_Filter_Compress_Zip filter", + "ext-rar": "Used in the Zend_Filter_Compress_Rar filter", + "ext-lzf": "Used in the Zend_Filter_Compress_Lzf filter", + "pear/archive_tar": "For the Zend_Filter_Compress_Tar filter", "diablomedia/zendframework1-filter-input": "Provides the separate Zend_Filter_Input component" } } diff --git a/grumphp.yml.dist b/grumphp.yml.dist new file mode 100644 index 0000000..62f4101 --- /dev/null +++ b/grumphp.yml.dist @@ -0,0 +1,17 @@ +# grumphp.yml +parameters: + tasks: + composer: + strict: true + composer_require_checker: + config_file: require-checker-config.json + phpcsfixer2: + allow_risky: true + config: .php_cs + phpstan: + level: 6 + configuration: phpstan.neon + phpunit: + metadata: + priority: 100 + always_execute: true diff --git a/phpstan.neon b/phpstan.neon index 4238018..5c0b010 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,7 @@ parameters: + excludes_analyse: + - %rootDir%/../../../tests/* + - %rootDir%/../../../vendor/* bootstrap: %rootDir%/../../../phpstan-bootstrap.php ignoreErrors: - '#Casting to .+ something that.s already .+\.#' @@ -10,4 +13,4 @@ parameters: - '#Zend_Filter_.+::__construct\(\) does not call parent constructor from Zend_Filter_.+\.#' - '#Variable \$file might not be defined\.#' - '#Parameter \#1 \$p_filelist of method Archive_Tar::create\(\) expects array, array\|string given\.#' - - '#Parameter \#3 \$locale of static method Zend_Locale::getTranslation\(\) expects string\|Zend_Locale\|null, array given\.#' \ No newline at end of file + - '#Parameter \#3 \$locale of static method Zend_Locale::getTranslation\(\) expects string\|Zend_Locale\|null, array given\.#' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 078072b..2204d13 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -6,6 +6,11 @@ backupGlobals="true" stderr="true" colors="true"> + + + ./tests + + ./src diff --git a/require-checker-config.json b/require-checker-config.json new file mode 100644 index 0000000..0a85a65 --- /dev/null +++ b/require-checker-config.json @@ -0,0 +1,20 @@ +{ + "symbol-whitelist" : [ + "null", "true", "false", + "static", "self", "parent", + "array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", + "iconv", + "ctype_print", + "mb_internal_encoding", "mb_list_encodings", "mb_strtolower", "mb_strtoupper", + "Archive_Tar", + "mcrypt_list_algorithms", "mcrypt_list_modes", "mcrypt_module_self_test", "mcrypt_enc_get_iv_size", "MCRYPT_RAND", + "MCRYPT_DEV_URANDOM", "MCRYPT_DEV_RANDOM", "mcrypt_create_iv", "mcrypt_generic", "mcrypt_generic_deinit", + "mdecrypt_generic", "mcrypt_module_open", "mcrypt_module_close", "mcrypt_enc_get_supported_key_sizes", "mcrypt_enc_get_key_size", "mcrypt_generic_init", + "gzopen", "gzwrite", "gzclose", "gzdeflate", "gzcompress", "gzread", "gzinflate", "gzuncompress", + "openssl_pkey_get_public", "openssl_free_key", "openssl_pkey_get_private", "openssl_pkey_get_details", "openssl_seal", "openssl_open", + "bzopen", "bzwrite", "bzclose", "bzcompress", "bzread", "bzdecompress", + "ZipArchive", + "rar_open", "rar_list", "rar_close", + "lzf_compress", "lzf_decompress" + ] +} diff --git a/src/Zend/Filter.php b/src/Zend/Filter.php index 13a6853..3e7707e 100644 --- a/src/Zend/Filter.php +++ b/src/Zend/Filter.php @@ -27,7 +27,6 @@ */ class Zend_Filter implements Zend_Filter_Interface { - const CHAIN_APPEND = 'append'; const CHAIN_PREPEND = 'prepend'; diff --git a/src/Zend/Filter/Alnum.php b/src/Zend/Filter/Alnum.php index 4512af5..0dc2236 100644 --- a/src/Zend/Filter/Alnum.php +++ b/src/Zend/Filter/Alnum.php @@ -66,7 +66,7 @@ public function __construct($allowWhiteSpace = false) { if ($allowWhiteSpace instanceof Zend_Config) { $allowWhiteSpace = $allowWhiteSpace->toArray(); - } else if (is_array($allowWhiteSpace)) { + } elseif (is_array($allowWhiteSpace)) { if (array_key_exists('allowwhitespace', $allowWhiteSpace)) { $allowWhiteSpace = $allowWhiteSpace['allowwhitespace']; } else { @@ -80,12 +80,12 @@ public function __construct($allowWhiteSpace = false) } if (null === self::$_meansEnglishAlphabet) { - $this->_locale = new Zend_Locale('auto'); - self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), - array('ja', 'ko', 'zh') - ); + $this->_locale = new Zend_Locale('auto'); + self::$_meansEnglishAlphabet = in_array( + $this->_locale->getLanguage(), + array('ja', 'ko', 'zh') + ); } - } /** @@ -124,9 +124,9 @@ public function filter($value) if (!self::$_unicodeEnabled) { // POSIX named classes are not supported, use alternative a-zA-Z0-9 match $pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/'; - } else if (self::$_meansEnglishAlphabet) { + } elseif (self::$_meansEnglishAlphabet) { //The Alphabet means english alphabet. - $pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/u'; + $pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/u'; } else { //The Alphabet means each language's alphabet. $pattern = '/[^\p{L}\p{N}' . $whiteSpace . ']/u'; diff --git a/src/Zend/Filter/Alpha.php b/src/Zend/Filter/Alpha.php index e7c5f2c..92a56a2 100644 --- a/src/Zend/Filter/Alpha.php +++ b/src/Zend/Filter/Alpha.php @@ -66,7 +66,7 @@ public function __construct($allowWhiteSpace = false) { if ($allowWhiteSpace instanceof Zend_Config) { $allowWhiteSpace = $allowWhiteSpace->toArray(); - } else if (is_array($allowWhiteSpace)) { + } elseif (is_array($allowWhiteSpace)) { if (array_key_exists('allowwhitespace', $allowWhiteSpace)) { $allowWhiteSpace = $allowWhiteSpace['allowwhitespace']; } else { @@ -80,12 +80,12 @@ public function __construct($allowWhiteSpace = false) } if (null === self::$_meansEnglishAlphabet) { - $this->_locale = new Zend_Locale('auto'); - self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), - array('ja', 'ko', 'zh') - ); + $this->_locale = new Zend_Locale('auto'); + self::$_meansEnglishAlphabet = in_array( + $this->_locale->getLanguage(), + array('ja', 'ko', 'zh') + ); } - } /** @@ -124,9 +124,9 @@ public function filter($value) if (!self::$_unicodeEnabled) { // POSIX named classes are not supported, use alternative a-zA-Z match $pattern = '/[^a-zA-Z' . $whiteSpace . ']/'; - } else if (self::$_meansEnglishAlphabet) { + } elseif (self::$_meansEnglishAlphabet) { //The Alphabet means english alphabet. - $pattern = '/[^a-zA-Z' . $whiteSpace . ']/u'; + $pattern = '/[^a-zA-Z' . $whiteSpace . ']/u'; } else { //The Alphabet means each language's alphabet. $pattern = '/[^\p{L}' . $whiteSpace . ']/u'; diff --git a/src/Zend/Filter/Boolean.php b/src/Zend/Filter/Boolean.php index 18c47b9..4165a9f 100644 --- a/src/Zend/Filter/Boolean.php +++ b/src/Zend/Filter/Boolean.php @@ -135,7 +135,7 @@ public function setType($type = null) { if (is_array($type)) { $detected = 0; - foreach($type as $value) { + foreach ($type as $value) { if (is_int($value)) { $detected += $value; } elseif (in_array($value, $this->_constants)) { @@ -355,7 +355,7 @@ protected function _getLocalizedQuestion($value, $yes, $locale) $str = Zend_Locale::getTranslation($question, 'question', $locale); $str = explode(':', $str); if (!empty($str)) { - foreach($str as $no) { + foreach ($str as $no) { if (($no == $value) || (strtolower($no) == strtolower($value))) { return $return; } diff --git a/src/Zend/Filter/Callback.php b/src/Zend/Filter/Callback.php index a5e797e..36a2bfb 100644 --- a/src/Zend/Filter/Callback.php +++ b/src/Zend/Filter/Callback.php @@ -51,7 +51,7 @@ public function __construct($options) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } else if (!is_array($options) || !array_key_exists('callback', $options)) { + } elseif (!is_array($options) || !array_key_exists('callback', $options)) { $options = func_get_args(); $temp['callback'] = array_shift($options); if (!empty($options)) { diff --git a/src/Zend/Filter/Compress/Gz.php b/src/Zend/Filter/Compress/Gz.php index b1916a7..9dbed60 100644 --- a/src/Zend/Filter/Compress/Gz.php +++ b/src/Zend/Filter/Compress/Gz.php @@ -149,7 +149,7 @@ public function compress($content) gzwrite($file, $content); gzclose($file); $compressed = true; - } else if ($this->_options['mode'] == 'deflate') { + } elseif ($this->_options['mode'] == 'deflate') { $compressed = gzdeflate($content, $this->getLevel()); } else { $compressed = gzcompress($content, $this->getLevel()); @@ -177,21 +177,21 @@ public function decompress($content) } if (@file_exists($archive)) { - $handler = fopen($archive, "rb"); + $handler = fopen($archive, 'rb'); if (!$handler) { throw new Zend_Filter_Exception("Error opening the archive '" . $archive . "'"); } fseek($handler, -4, SEEK_END); $packet = fread($handler, 4); - $bytes = unpack("V", $packet); + $bytes = unpack('V', $packet); $size = end($bytes); fclose($handler); $file = gzopen($archive, 'r'); $compressed = gzread($file, $size); gzclose($file); - } else if ($mode == 'deflate') { + } elseif ($mode == 'deflate') { $compressed = gzinflate($content); } else { $compressed = gzuncompress($content); diff --git a/src/Zend/Filter/Compress/Rar.php b/src/Zend/Filter/Compress/Rar.php index 46c57df..2ea847d 100644 --- a/src/Zend/Filter/Compress/Rar.php +++ b/src/Zend/Filter/Compress/Rar.php @@ -104,7 +104,7 @@ public function getArchive() */ public function setArchive($archive) { - $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive); + $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive); $this->_options['archive'] = (string) $archive; return $this; @@ -154,7 +154,7 @@ public function setTarget($target) throw new Zend_Filter_Exception("The directory '$target' does not exist"); } - $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target); + $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target); $this->_options['target'] = (string) $target; return $this; } @@ -206,7 +206,7 @@ public function decompress($content) } if (!$archive) { - throw new Zend_Filter_Exception("Error opening the RAR Archive"); + throw new Zend_Filter_Exception('Error opening the RAR Archive'); } $target = $this->getTarget(); @@ -216,10 +216,10 @@ public function decompress($content) $filelist = rar_list($archive); if (!$filelist) { - throw new Zend_Filter_Exception("Error reading the RAR Archive"); + throw new Zend_Filter_Exception('Error reading the RAR Archive'); } - foreach($filelist as $file) { + foreach ($filelist as $file) { $file->extract($target); } diff --git a/src/Zend/Filter/Compress/Tar.php b/src/Zend/Filter/Compress/Tar.php index 4bc8c8e..ae9395b 100644 --- a/src/Zend/Filter/Compress/Tar.php +++ b/src/Zend/Filter/Compress/Tar.php @@ -39,9 +39,9 @@ class Zend_Filter_Compress_Tar extends Zend_Filter_Compress_CompressAbstract * @var array */ protected $_options = array( - 'archive' => null, - 'target' => '.', - 'mode' => null, + 'archive' => null, + 'target' => '.', + 'mode' => null, ); /** @@ -80,7 +80,7 @@ public function getArchive() */ public function setArchive($archive) { - $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive); + $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive); $this->_options['archive'] = (string) $archive; return $this; @@ -108,7 +108,7 @@ public function setTarget($target) throw new Zend_Filter_Exception("The directory '$target' does not exist"); } - $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target); + $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target); $this->_options['target'] = (string) $target; return $this; } @@ -155,7 +155,7 @@ public function compress($content) if (!file_exists($content)) { $file = $this->getTarget(); if (is_dir($file)) { - $file .= DIRECTORY_SEPARATOR . "tar.tmp"; + $file .= DIRECTORY_SEPARATOR . 'tar.tmp'; } $result = file_put_contents($file, $content); @@ -182,7 +182,7 @@ public function compress($content) } /** @var bool $result Docblock of Archive_Tar::create is incorrect */ - $result = $archive->create($content); + $result = $archive->create($content); if ($result === false) { throw new Zend_Filter_Exception('Error creating the Tar archive'); } diff --git a/src/Zend/Filter/Compress/Zip.php b/src/Zend/Filter/Compress/Zip.php index 1407c0d..2abc579 100644 --- a/src/Zend/Filter/Compress/Zip.php +++ b/src/Zend/Filter/Compress/Zip.php @@ -75,7 +75,7 @@ public function getArchive() */ public function setArchive($archive) { - $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive); + $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive); $this->_options['archive'] = (string) $archive; return $this; @@ -103,7 +103,7 @@ public function setTarget($target) throw new Zend_Filter_Exception("The directory '$target' does not exist"); } - $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target); + $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target); $this->_options['target'] = (string) $target; return $this; } @@ -127,9 +127,9 @@ public function compress($content) $content = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content)); $basename = substr($content, strrpos($content, DIRECTORY_SEPARATOR) + 1); if (is_dir($content)) { - $index = strrpos($content, DIRECTORY_SEPARATOR) + 1; + $index = strrpos($content, DIRECTORY_SEPARATOR) + 1; $content .= DIRECTORY_SEPARATOR; - $stack = array($content); + $stack = array($content); while (!empty($stack)) { $current = array_pop($stack); $files = array(); @@ -170,7 +170,7 @@ public function compress($content) if (!is_dir($file)) { $file = basename($file); } else { - $file = "zip.tmp"; + $file = 'zip.tmp'; } $res = $zip->addFromString($file, $content); @@ -222,13 +222,13 @@ public function decompress($content) if (version_compare(PHP_VERSION, '5.2.8', '<')) { for ($i = 0; $i < $zip->numFiles; $i++) { $statIndex = $zip->statIndex($i); - $currName = $statIndex['name']; + $currName = $statIndex['name']; if (($currName{0} == '/') || (substr($currName, 0, 2) == '..') || (substr($currName, 0, 4) == './..') - ) - { - throw new Zend_Filter_Exception('Upward directory traversal was detected inside ' . $archive + ) { + throw new Zend_Filter_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.' ); @@ -252,77 +252,77 @@ public function decompress($content) */ protected function _errorString($error) { - switch($error) { - case ZipArchive::ER_MULTIDISK : + switch ($error) { + 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'; } } diff --git a/src/Zend/Filter/Digits.php b/src/Zend/Filter/Digits.php index 7ed47c9..5d2c483 100644 --- a/src/Zend/Filter/Digits.php +++ b/src/Zend/Filter/Digits.php @@ -63,7 +63,7 @@ public function filter($value) if (!self::$_unicodeEnabled) { // POSIX named classes are not supported, use alternative 0-9 match $pattern = '/[^0-9]/'; - } else if (extension_loaded('mbstring')) { + } elseif (extension_loaded('mbstring')) { // Filter for the value with mbstring $pattern = '/[^[:digit:]]/'; } else { diff --git a/src/Zend/Filter/Encrypt.php b/src/Zend/Filter/Encrypt.php index e09dfff..311e2f1 100644 --- a/src/Zend/Filter/Encrypt.php +++ b/src/Zend/Filter/Encrypt.php @@ -68,7 +68,7 @@ public function setAdapter($options = null) { if (is_string($options)) { $adapter = $options; - } else if (isset($options['adapter'])) { + } elseif (isset($options['adapter'])) { $adapter = $options['adapter']; unset($options['adapter']); } else { @@ -79,7 +79,7 @@ public function setAdapter($options = null) $options = array(); } - if (Zend_Loader::isReadable('Zend/Filter/Encrypt/' . ucfirst($adapter). '.php')) { + if (Zend_Loader::isReadable('Zend/Filter/Encrypt/' . ucfirst($adapter) . '.php')) { $adapter = 'Zend_Filter_Encrypt_' . ucfirst($adapter); } diff --git a/src/Zend/Filter/Encrypt/Mcrypt.php b/src/Zend/Filter/Encrypt/Mcrypt.php index ca9e963..c9633c5 100644 --- a/src/Zend/Filter/Encrypt/Mcrypt.php +++ b/src/Zend/Filter/Encrypt/Mcrypt.php @@ -111,7 +111,7 @@ public function setEncryption($options) throw new Zend_Filter_Exception('Invalid options argument provided to filter'); } - $options = $options + $this->getEncryption(); + $options = $options + $this->getEncryption(); $algorithms = mcrypt_list_algorithms($options['algorithm_directory']); if (!in_array($options['algorithm'], $algorithms)) { throw new Zend_Filter_Exception("The algorithm '{$options['algorithm']}' is not supported"); @@ -170,7 +170,7 @@ public function setVector($vector = null) } } $vector = mcrypt_create_iv($size, $method); - } else if (strlen($vector) != $size) { + } elseif (strlen($vector) != $size) { throw new Zend_Filter_Exception('The given vector has a wrong size for the set algorithm'); } @@ -222,7 +222,7 @@ public function encrypt($value) $value = $compress->filter($value); } - $cipher = $this->_openCipher(); + $cipher = $this->_openCipher(); $this->_initCipher($cipher); $encrypted = mcrypt_generic($cipher, $value); mcrypt_generic_deinit($cipher); @@ -278,7 +278,8 @@ protected function _openCipher() $this->_encryption['algorithm'], $this->_encryption['algorithm_directory'], $this->_encryption['mode'], - $this->_encryption['mode_directory']); + $this->_encryption['mode_directory'] + ); if ($cipher === false) { throw new Zend_Filter_Exception('Mcrypt can not be opened with your settings'); @@ -316,7 +317,7 @@ protected function _initCipher($cipher) $this->_srand(); $keysize = mcrypt_enc_get_key_size($cipher); $key = substr(md5($key), 0, $keysize); - } else if (!in_array(strlen($key), $keysizes)) { + } elseif (!in_array(strlen($key), $keysizes)) { throw new Zend_Filter_Exception('The given key has a wrong size for the set algorithm'); } diff --git a/src/Zend/Filter/Encrypt/Openssl.php b/src/Zend/Filter/Encrypt/Openssl.php index aac2970..7c69c54 100644 --- a/src/Zend/Filter/Encrypt/Openssl.php +++ b/src/Zend/Filter/Encrypt/Openssl.php @@ -180,7 +180,7 @@ public function getPublicKey() public function setPublicKey($key) { if (is_array($key)) { - foreach($key as $type => $option) { + foreach ($key as $type => $option) { if ($type !== 'public') { $key['public'] = $option; unset($key[$type]); @@ -214,7 +214,7 @@ public function getPrivateKey() public function setPrivateKey($key, $passphrase = null) { if (is_array($key)) { - foreach($key as $type => $option) { + foreach ($key as $type => $option) { if ($type !== 'private') { $key['private'] = $option; unset($key[$type]); @@ -251,7 +251,7 @@ public function getEnvelopeKey() public function setEnvelopeKey($key) { if (is_array($key)) { - foreach($key as $type => $option) { + foreach ($key as $type => $option) { if ($type !== 'envelope') { $key['envelope'] = $option; unset($key[$type]); @@ -354,7 +354,7 @@ public function encrypt($value) $keys = array(); $fingerprints = array(); $count = -1; - foreach($this->_keys['public'] as $key => $cert) { + foreach ($this->_keys['public'] as $key => $cert) { $keys[$key] = openssl_pkey_get_public($cert); if ($this->_package) { $details = openssl_pkey_get_details($keys[$key]); @@ -373,7 +373,7 @@ public function encrypt($value) $value = $compress->filter($value); } - $crypt = openssl_seal($value, $encrypted, $encryptedkeys, $keys); + $crypt = openssl_seal($value, $encrypted, $encryptedkeys, $keys); foreach ($keys as $key) { openssl_free_key($key); } @@ -387,7 +387,7 @@ public function encrypt($value) // Pack data and envelope keys into single string if ($this->_package) { $header = pack('n', count($this->_keys['envelope'])); - foreach($this->_keys['envelope'] as $key => $envKey) { + foreach ($this->_keys['envelope'] as $key => $envKey) { $header .= pack('H32n', $fingerprints[$key], strlen($envKey)) . $envKey; } @@ -408,7 +408,7 @@ public function encrypt($value) */ public function decrypt($value) { - $decrypted = ""; + $decrypted = ''; $envelope = current($this->getEnvelopeKey()); if (count($this->_keys['private']) !== 1) { @@ -421,7 +421,7 @@ public function decrypt($value) $keys = null; - foreach($this->_keys['private'] as $key => $cert) { + foreach ($this->_keys['private'] as $key => $cert) { $keys = openssl_pkey_get_private($cert, $this->getPassphrase()); } @@ -430,15 +430,15 @@ public function decrypt($value) if ($details !== false) { $fingerprint = md5($details['key']); } else { - $fingerprint = md5("ZendFramework"); + $fingerprint = md5('ZendFramework'); } - $count = unpack('ncount', $value); - $count = $count['count']; - $length = 2; - for($i = $count; $i > 0; --$i) { + $count = unpack('ncount', $value); + $count = $count['count']; + $length = 2; + for ($i = $count; $i > 0; --$i) { $header = unpack('H32print/nsize', substr($value, $length, 18)); - $length += 18; + $length += 18; if ($header['print'] == $fingerprint) { $envelope = substr($value, $length, $header['size']); } @@ -450,7 +450,7 @@ public function decrypt($value) $value = substr($value, $length); } - $crypt = openssl_open($value, $decrypted, $envelope, $keys); + $crypt = openssl_open($value, $decrypted, $envelope, $keys); openssl_free_key($keys); if ($crypt === false) { diff --git a/src/Zend/Filter/Exception.php b/src/Zend/Filter/Exception.php index ae9cb15..73b86cd 100644 --- a/src/Zend/Filter/Exception.php +++ b/src/Zend/Filter/Exception.php @@ -28,4 +28,5 @@ * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Filter_Exception extends Zend_Exception -{} +{ +} diff --git a/src/Zend/Filter/File/Rename.php b/src/Zend/Filter/File/Rename.php index f22aebf..fde1b71 100644 --- a/src/Zend/Filter/File/Rename.php +++ b/src/Zend/Filter/File/Rename.php @@ -114,7 +114,7 @@ public function addFile($options) if (is_string($options)) { $options = array('target' => $options); } elseif (!is_array($options)) { - throw new Zend_Filter_Exception ('Invalid options to rename filter provided'); + throw new Zend_Filter_Exception('Invalid options to rename filter provided'); } $this->_convertOptions($options); @@ -173,7 +173,7 @@ public function getNewName($value, $source = false) */ public function filter($value) { - $file = $this->getNewName($value, true); + $file = $this->getNewName($value, true); if (is_string($file)) { return $file; } @@ -194,7 +194,8 @@ public function filter($value) * @param array $options * @return $this */ - protected function _convertOptions($options) { + protected function _convertOptions($options) + { $files = array(); foreach ($options as $key => $value) { if (is_array($value)) { @@ -203,15 +204,15 @@ protected function _convertOptions($options) { } switch ($key) { - case "source": + case 'source': $files['source'] = (string) $value; break; - case 'target' : + case 'target': $files['target'] = (string) $value; break; - case 'overwrite' : + case 'overwrite': $files['overwrite'] = (boolean) $value; break; diff --git a/src/Zend/Filter/HtmlEntities.php b/src/Zend/Filter/HtmlEntities.php index f29dafb..3d43ed6 100644 --- a/src/Zend/Filter/HtmlEntities.php +++ b/src/Zend/Filter/HtmlEntities.php @@ -59,8 +59,8 @@ public function __construct($options = array()) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); + } elseif (!is_array($options)) { + $options = func_get_args(); $temp['quotestyle'] = array_shift($options); if (!empty($options)) { $temp['charset'] = array_shift($options); @@ -119,7 +119,7 @@ public function setQuoteStyle($quoteStyle) */ public function getEncoding() { - return $this->_encoding; + return $this->_encoding; } /** diff --git a/src/Zend/Filter/Inflector.php b/src/Zend/Filter/Inflector.php index 540aebd..c78d9ba 100644 --- a/src/Zend/Filter/Inflector.php +++ b/src/Zend/Filter/Inflector.php @@ -64,7 +64,7 @@ public function __construct($options = null) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } else if (!is_array($options)) { + } elseif (!is_array($options)) { $options = func_get_args(); $temp = array(); @@ -134,7 +134,8 @@ public function setConfig(Zend_Config $config) * @param array|Zend_Config $options * @return Zend_Filter_Inflector */ - public function setOptions($options) { + public function setOptions($options) + { if ($options instanceof Zend_Config) { $options = $options->toArray(); } @@ -259,7 +260,7 @@ public function getTarget() */ public function setTargetReference(&$target) { - $this->_target =& $target; + $this->_target = & $target; return $this; } @@ -270,7 +271,7 @@ public function setTargetReference(&$target) * @param array $rules * @return Zend_Filter_Inflector */ - public function setRules(Array $rules) + public function setRules(array $rules) { $this->clearRules(); $this->addRules($rules); @@ -293,7 +294,7 @@ public function setRules(Array $rules) * @param array $rules * @return Zend_Filter_Inflector */ - public function addRules(Array $rules) + public function addRules(array $rules) { $keys = array_keys($rules); foreach ($keys as $spec) { @@ -368,7 +369,7 @@ public function clearRules() */ public function setFilterRule($spec, $ruleSet) { - $spec = $this->_normalizeSpec($spec); + $spec = $this->_normalizeSpec($spec); $this->_rules[$spec] = array(); return $this->addFilterRule($spec, $ruleSet); } @@ -392,8 +393,8 @@ public function addFilterRule($spec, $ruleSet) } if (is_string($this->_rules[$spec])) { - $temp = $this->_rules[$spec]; - $this->_rules[$spec] = array(); + $temp = $this->_rules[$spec]; + $this->_rules[$spec] = array(); $this->_rules[$spec][] = $temp; } @@ -413,7 +414,7 @@ public function addFilterRule($spec, $ruleSet) */ public function setStaticRule($name, $value) { - $name = $this->_normalizeSpec($name); + $name = $this->_normalizeSpec($name); $this->_rules[$name] = (string) $value; return $this; } @@ -431,8 +432,8 @@ public function setStaticRule($name, $value) */ public function setStaticRuleReference($name, &$reference) { - $name = $this->_normalizeSpec($name); - $this->_rules[$name] =& $reference; + $name = $this->_normalizeSpec($name); + $this->_rules[$name] = & $reference; return $this; } @@ -445,34 +446,34 @@ public function setStaticRuleReference($name, &$reference) public function filter($source) { // clean source - foreach ( (array) $source as $sourceName => $sourceValue) { + foreach ((array) $source as $sourceName => $sourceValue) { $source[ltrim($sourceName, ':')] = $sourceValue; } $pregQuotedTargetReplacementIdentifier = preg_quote($this->_targetReplacementIdentifier, '#'); - $processedParts = array(); + $processedParts = array(); foreach ($this->_rules as $ruleName => $ruleValue) { if (isset($source[$ruleName])) { if (is_string($ruleValue)) { // overriding the set rule - $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = str_replace('\\', '\\\\', $source[$ruleName]); + $processedParts['#' . $pregQuotedTargetReplacementIdentifier . $ruleName . '#'] = str_replace('\\', '\\\\', $source[$ruleName]); } elseif (is_array($ruleValue)) { $processedPart = $source[$ruleName]; foreach ($ruleValue as $ruleFilter) { $processedPart = $ruleFilter->filter($processedPart); } - $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = str_replace('\\', '\\\\', $processedPart); + $processedParts['#' . $pregQuotedTargetReplacementIdentifier . $ruleName . '#'] = str_replace('\\', '\\\\', $processedPart); } } elseif (is_string($ruleValue)) { - $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = str_replace('\\', '\\\\', $ruleValue); + $processedParts['#' . $pregQuotedTargetReplacementIdentifier . $ruleName . '#'] = str_replace('\\', '\\\\', $ruleValue); } } // all of the values of processedParts would have been str_replace('\\', '\\\\', ..)'d to disable preg_replace backreferences $inflectedTarget = preg_replace(array_keys($processedParts), array_values($processedParts), $this->_target); - if ($this->_throwTargetExceptionsOn && (preg_match('#(?='.$pregQuotedTargetReplacementIdentifier.'[A-Za-z]{1})#', $inflectedTarget) == true)) { + if ($this->_throwTargetExceptionsOn && (preg_match('#(?=' . $pregQuotedTargetReplacementIdentifier . '[A-Za-z]{1})#', $inflectedTarget) == true)) { throw new Zend_Filter_Exception('A replacement identifier ' . $this->_targetReplacementIdentifier . ' was found inside the inflected target, perhaps a rule was not satisfied with a target source? Unsatisfied inflected target: ' . $inflectedTarget); } diff --git a/src/Zend/Filter/LocalizedToNormalized.php b/src/Zend/Filter/LocalizedToNormalized.php index 0bc1ad4..ba1ae7f 100644 --- a/src/Zend/Filter/LocalizedToNormalized.php +++ b/src/Zend/Filter/LocalizedToNormalized.php @@ -89,10 +89,10 @@ public function filter($value) { if (Zend_Locale_Format::isNumber($value, $this->_options)) { return Zend_Locale_Format::getNumber($value, $this->_options); - } else if (($this->_options['date_format'] === null) && (strpos($value, ':') !== false)) { + } elseif (($this->_options['date_format'] === null) && (strpos($value, ':') !== false)) { // Special case, no date format specified, detect time input return Zend_Locale_Format::getTime($value, $this->_options); - } else if (Zend_Locale_Format::checkDateFormat($value, $this->_options)) { + } elseif (Zend_Locale_Format::checkDateFormat($value, $this->_options)) { // Detect date or time input return Zend_Locale_Format::getDate($value, $this->_options); } diff --git a/src/Zend/Filter/NormalizedToLocalized.php b/src/Zend/Filter/NormalizedToLocalized.php index 1f80f17..e5ccff1 100644 --- a/src/Zend/Filter/NormalizedToLocalized.php +++ b/src/Zend/Filter/NormalizedToLocalized.php @@ -89,9 +89,9 @@ public function filter($value) if (is_array($value)) { $date = new Zend_Date($value, $this->_options['locale']); return $date->toString($this->_options['date_format']); - } else if ($this->_options['precision'] === 0) { + } elseif ($this->_options['precision'] === 0) { return Zend_Locale_Format::toInteger($value, $this->_options); - } else if ($this->_options['precision'] === null) { + } elseif ($this->_options['precision'] === null) { return Zend_Locale_Format::toFloat($value, $this->_options); } diff --git a/src/Zend/Filter/Null.php b/src/Zend/Filter/Null.php index 1f14b90..2e4655d 100644 --- a/src/Zend/Filter/Null.php +++ b/src/Zend/Filter/Null.php @@ -27,12 +27,12 @@ */ class Zend_Filter_Null implements Zend_Filter_Interface { - const BOOLEAN = 1; - const INTEGER = 2; - const EMPTY_ARRAY = 4; - const STRING = 8; - const ZERO = 16; - const ALL = 31; + const BOOLEAN = 1; + const INTEGER = 2; + const EMPTY_ARRAY = 4; + const STRING = 8; + const ZERO = 16; + const ALL = 31; protected $_constants = array( self::BOOLEAN => 'boolean', @@ -59,14 +59,14 @@ public function __construct($options = null) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } else if (!is_array($options)) { + } elseif (!is_array($options)) { $options = func_get_args(); $temp = array(); if (!empty($options)) { $temp = array_shift($options); } $options = $temp; - } else if (is_array($options) && array_key_exists('type', $options)) { + } elseif (is_array($options) && array_key_exists('type', $options)) { $options = $options['type']; } @@ -96,16 +96,16 @@ public function setType($type = null) { if (is_array($type)) { $detected = 0; - foreach($type as $value) { + foreach ($type as $value) { if (is_int($value)) { $detected += $value; - } else if (in_array($value, $this->_constants)) { + } elseif (in_array($value, $this->_constants)) { $detected += array_search($value, $this->_constants); } } $type = $detected; - } else if (is_string($type)) { + } elseif (is_string($type)) { if (in_array($type, $this->_constants)) { $type = array_search($type, $this->_constants); } diff --git a/src/Zend/Filter/PregReplace.php b/src/Zend/Filter/PregReplace.php index b86cc66..005109f 100644 --- a/src/Zend/Filter/PregReplace.php +++ b/src/Zend/Filter/PregReplace.php @@ -44,14 +44,14 @@ class Zend_Filter_PregReplace implements Zend_Filter_Interface * * @var bool */ - static protected $_unicodeSupportEnabled = null; + protected static $_unicodeSupportEnabled = null; /** * Is Unicode Support Enabled Utility function * * @return bool */ - static public function isUnicodeSupportEnabled() + public static function isUnicodeSupportEnabled() { if (self::$_unicodeSupportEnabled === null) { self::_determineUnicodeSupport(); @@ -65,7 +65,7 @@ static public function isUnicodeSupportEnabled() * * @return bool */ - static protected function _determineUnicodeSupport() + protected static function _determineUnicodeSupport() { self::$_unicodeSupportEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; } @@ -83,7 +83,7 @@ public function __construct($options = null) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } else if (!is_array($options)) { + } elseif (!is_array($options)) { $options = func_get_args(); $temp = array(); if (!empty($options)) { @@ -164,5 +164,4 @@ public function filter($value) return preg_replace($this->_matchPattern, $this->_replacement, $value); } - } diff --git a/src/Zend/Filter/StringToLower.php b/src/Zend/Filter/StringToLower.php index b41c76b..e44d9f0 100644 --- a/src/Zend/Filter/StringToLower.php +++ b/src/Zend/Filter/StringToLower.php @@ -43,7 +43,7 @@ public function __construct($options = null) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } else if (!is_array($options)) { + } elseif (!is_array($options)) { $options = func_get_args(); $temp = array(); if (!empty($options)) { diff --git a/src/Zend/Filter/StringToUpper.php b/src/Zend/Filter/StringToUpper.php index d181f8a..adec281 100644 --- a/src/Zend/Filter/StringToUpper.php +++ b/src/Zend/Filter/StringToUpper.php @@ -43,7 +43,7 @@ public function __construct($options = null) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } else if (!is_array($options)) { + } elseif (!is_array($options)) { $options = func_get_args(); $temp = array(); if (!empty($options)) { diff --git a/src/Zend/Filter/StringTrim.php b/src/Zend/Filter/StringTrim.php index 92a5c3f..9dfd5e3 100644 --- a/src/Zend/Filter/StringTrim.php +++ b/src/Zend/Filter/StringTrim.php @@ -47,7 +47,7 @@ public function __construct($options = null) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } else if (!is_array($options)) { + } elseif (!is_array($options)) { $options = func_get_args(); $temp['charlist'] = array_shift($options); $options = $temp; diff --git a/src/Zend/Filter/StripNewlines.php b/src/Zend/Filter/StripNewlines.php index 5a52733..b43d426 100644 --- a/src/Zend/Filter/StripNewlines.php +++ b/src/Zend/Filter/StripNewlines.php @@ -36,7 +36,7 @@ class Zend_Filter_StripNewlines implements Zend_Filter_Interface * @param string $value * @return string */ - public function filter ($value) + public function filter($value) { return str_replace(array("\n", "\r"), '', $value); } diff --git a/src/Zend/Filter/StripTags.php b/src/Zend/Filter/StripTags.php index 2bb37ad..a9b84a3 100644 --- a/src/Zend/Filter/StripTags.php +++ b/src/Zend/Filter/StripTags.php @@ -78,9 +78,9 @@ public function __construct($options = null) { if ($options instanceof Zend_Config) { $options = $options->toArray(); - } else if ((!is_array($options)) || (is_array($options) && !array_key_exists('allowTags', $options) && + } elseif ((!is_array($options)) || (is_array($options) && !array_key_exists('allowTags', $options) && !array_key_exists('allowAttribs', $options) && !array_key_exists('allowComments', $options))) { - $options = func_get_args(); + $options = func_get_args(); $temp['allowTags'] = array_shift($options); if (!empty($options)) { $temp['allowAttribs'] = array_shift($options); @@ -130,8 +130,8 @@ public function getCommentsAllowed() */ public function setCommentsAllowed($commentsAllowed) { - $this->commentsAllowed = (boolean) $commentsAllowed; - return $this; + $this->commentsAllowed = (boolean) $commentsAllowed; + return $this; } /** @@ -165,7 +165,7 @@ public function setTagsAllowed($tagsAllowed) $this->_tagsAllowed[$tagName] = array(); } // Otherwise, if a tag was provided with attributes - else if (is_string($index) && (is_array($element) || is_string($element))) { + elseif (is_string($index) && (is_array($element) || is_string($element))) { // Canonicalize the tag name $tagName = strtolower($index); // Canonicalize the attributes @@ -177,7 +177,7 @@ public function setTagsAllowed($tagsAllowed) foreach ($element as $attribute) { if (is_string($attribute)) { // Canonicalize the attribute name - $attributeName = strtolower($attribute); + $attributeName = strtolower($attribute); $this->_tagsAllowed[$tagName][$attributeName] = null; } } @@ -213,7 +213,7 @@ public function setAttributesAllowed($attributesAllowed) foreach ($attributesAllowed as $attribute) { if (is_string($attribute)) { // Canonicalize the attribute name - $attributeName = strtolower($attribute); + $attributeName = strtolower($attribute); $this->_attributesAllowed[$attributeName] = null; } } @@ -243,7 +243,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; diff --git a/src/Zend/Filter/Word/CamelCaseToSeparator.php b/src/Zend/Filter/Word/CamelCaseToSeparator.php index 696c6ba..e1d1528 100644 --- a/src/Zend/Filter/Word/CamelCaseToSeparator.php +++ b/src/Zend/Filter/Word/CamelCaseToSeparator.php @@ -27,7 +27,6 @@ */ class Zend_Filter_Word_CamelCaseToSeparator extends Zend_Filter_Word_Separator_Abstract { - public function filter($value) { if (self::isUnicodeSupportEnabled()) { @@ -40,5 +39,4 @@ public function filter($value) return parent::filter($value); } - } diff --git a/src/Zend/Filter/Word/DashToSeparator.php b/src/Zend/Filter/Word/DashToSeparator.php index d88b610..a767374 100644 --- a/src/Zend/Filter/Word/DashToSeparator.php +++ b/src/Zend/Filter/Word/DashToSeparator.php @@ -27,7 +27,6 @@ */ class Zend_Filter_Word_DashToSeparator extends Zend_Filter_Word_Separator_Abstract { - public function filter($value) { $this->setMatchPattern('#-#'); diff --git a/src/Zend/Filter/Word/Separator/Abstract.php b/src/Zend/Filter/Word/Separator/Abstract.php index df83ab1..3f8a14f 100644 --- a/src/Zend/Filter/Word/Separator/Abstract.php +++ b/src/Zend/Filter/Word/Separator/Abstract.php @@ -28,7 +28,6 @@ */ abstract class Zend_Filter_Word_Separator_Abstract extends Zend_Filter_PregReplace { - protected $_separator = null; /** @@ -66,5 +65,4 @@ public function getSeparator() { return $this->_separator; } - } diff --git a/src/Zend/Filter/Word/SeparatorToCamelCase.php b/src/Zend/Filter/Word/SeparatorToCamelCase.php index 5bf6ffd..05029da 100644 --- a/src/Zend/Filter/Word/SeparatorToCamelCase.php +++ b/src/Zend/Filter/Word/SeparatorToCamelCase.php @@ -27,17 +27,16 @@ */ class Zend_Filter_Word_SeparatorToCamelCase extends Zend_Filter_Word_Separator_Abstract { - public function filter($value) { // a unicode safe way of converting characters to \x00\x00 notation $pregQuotedSeparator = preg_quote($this->_separator, '#'); if (self::isUnicodeSupportEnabled()) { - parent::setMatchPattern(array('#('.$pregQuotedSeparator.')(\p{L}{1})#','#(^\p{Ll}{1})#')); + parent::setMatchPattern(array('#(' . $pregQuotedSeparator . ')(\p{L}{1})#','#(^\p{Ll}{1})#')); parent::setReplacement(array('Zend_Filter_Word_SeparatorToCamelCase', '_strtoupperArray')); } else { - parent::setMatchPattern(array('#('.$pregQuotedSeparator.')([A-Za-z]{1})#','#(^[A-Za-z]{1})#')); + parent::setMatchPattern(array('#(' . $pregQuotedSeparator . ')([A-Za-z]{1})#','#(^[A-Za-z]{1})#')); parent::setReplacement(array('Zend_Filter_Word_SeparatorToCamelCase', '_strtoupperArray')); } @@ -55,5 +54,4 @@ private static function _strtoupperArray(array $matches) } return strtoupper($matches[1]); } - } diff --git a/src/Zend/Filter/Word/SeparatorToDash.php b/src/Zend/Filter/Word/SeparatorToDash.php index 05900fd..1fad99e 100644 --- a/src/Zend/Filter/Word/SeparatorToDash.php +++ b/src/Zend/Filter/Word/SeparatorToDash.php @@ -37,5 +37,4 @@ public function __construct($searchSeparator = ' ') { parent::__construct($searchSeparator, '-'); } - } diff --git a/src/Zend/Filter/Word/SeparatorToSeparator.php b/src/Zend/Filter/Word/SeparatorToSeparator.php index e047982..aebf706 100644 --- a/src/Zend/Filter/Word/SeparatorToSeparator.php +++ b/src/Zend/Filter/Word/SeparatorToSeparator.php @@ -27,8 +27,7 @@ */ class Zend_Filter_Word_SeparatorToSeparator extends Zend_Filter_PregReplace { - - protected $_searchSeparator = null; + protected $_searchSeparator = null; protected $_replacementSeparator = null; /** @@ -119,5 +118,4 @@ protected function _separatorToSeparatorFilter($value) $this->setReplacement($this->_replacementSeparator); return parent::filter($value); } - } diff --git a/tests/Zend/Filter/AlnumTest.php b/tests/Zend/Filter/AlnumTest.php index 5b59605..92433d5 100644 --- a/tests/Zend/Filter/AlnumTest.php +++ b/tests/Zend/Filter/AlnumTest.php @@ -71,8 +71,9 @@ public function setUp() self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; } if (null === self::$_meansEnglishAlphabet) { - $this->_locale = new Zend_Locale('auto'); - self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), + $this->_locale = new Zend_Locale('auto'); + self::$_meansEnglishAlphabet = in_array( + $this->_locale->getLanguage(), array('ja') ); } @@ -94,7 +95,8 @@ public function testBasic() 'AZ@#4.3' => 'AZ43', '' => '' ); - } if (self::$_meansEnglishAlphabet) { + } + if (self::$_meansEnglishAlphabet) { //The Alphabet means english alphabet. /** * The first element contains multibyte alphabets and digits. @@ -104,20 +106,20 @@ public function testBasic() * The third contains various multibyte or singebyte characters. */ $valuesExpected = array( - 'aABb3456' => 'aB35', - 'z7 Y8 x9' => 'z8x', + 'aABb3456' => 'aB35', + 'z7 Y8 x9' => 'z8x', ',s1.2r3#:q,' => 's12rq', ); } else { //The Alphabet means each language's alphabet. $valuesExpected = array( - 'abc123' => 'abc123', - 'abc 123' => 'abc123', - 'abcxyz' => 'abcxyz', - 'če2t3ně' => 'če2t3ně', - 'grz5e4gżółka' => 'grz5e4gżółka', - 'Be3l5gië' => 'Be3l5gië', - '' => '' + 'abc123' => 'abc123', + 'abc 123' => 'abc123', + 'abcxyz' => 'abcxyz', + 'če2t3ně' => 'če2t3ně', + 'grz5e4gżółka' => 'grz5e4gżółka', + 'Be3l5gië' => 'Be3l5gië', + '' => '' ); } foreach ($valuesExpected as $input => $output) { @@ -149,22 +151,23 @@ public function testAllowWhiteSpace() "\n" => "\n", " \t " => " \t " ); - } if (self::$_meansEnglishAlphabet) { + } + if (self::$_meansEnglishAlphabet) { //The Alphabet means english alphabet. $valuesExpected = array( - 'a B 45' => 'a B 5', - 'z3 x' => 'z3x' + 'a B 45' => 'a B 5', + 'z3 x' => 'z3x' ); } else { //The Alphabet means each language's alphabet. $valuesExpected = array( - 'abc123' => 'abc123', - 'abc 123' => 'abc 123', - 'abcxyz' => 'abcxyz', - 'če2 t3ně' => 'če2 t3ně', - 'gr z5e4gżółka' => 'gr z5e4gżółka', - 'Be3l5 gië' => 'Be3l5 gië', - '' => '', + 'abc123' => 'abc123', + 'abc 123' => 'abc 123', + 'abcxyz' => 'abcxyz', + 'če2 t3ně' => 'če2 t3ně', + 'gr z5e4gżółka' => 'gr z5e4gżółka', + 'Be3l5 gië' => 'Be3l5 gië', + '' => '', ); } foreach ($valuesExpected as $input => $output) { diff --git a/tests/Zend/Filter/AlphaTest.php b/tests/Zend/Filter/AlphaTest.php index 84aa09d..f26ad49 100644 --- a/tests/Zend/Filter/AlphaTest.php +++ b/tests/Zend/Filter/AlphaTest.php @@ -71,8 +71,9 @@ public function setUp() self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; } if (null === self::$_meansEnglishAlphabet) { - $this->_locale = new Zend_Locale('auto'); - self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), + $this->_locale = new Zend_Locale('auto'); + self::$_meansEnglishAlphabet = in_array( + $this->_locale->getLanguage(), array('ja') ); } @@ -88,12 +89,12 @@ public function testBasic() if (!self::$_unicodeEnabled) { // POSIX named classes are not supported, use alternative a-zA-Z match $valuesExpected = array( - 'abc123' => 'abc', - 'abc 123' => 'abc', - 'abcxyz' => 'abcxyz', - '' => '' + 'abc123' => 'abc', + 'abc 123' => 'abc', + 'abcxyz' => 'abcxyz', + '' => '' ); - } else if (self::$_meansEnglishAlphabet) { + } elseif (self::$_meansEnglishAlphabet) { //The Alphabet means english alphabet. /** * The first element contains multibyte alphabets. @@ -104,23 +105,23 @@ public function testBasic() * The last contains only singlebyte alphabets. */ $valuesExpected = array( - 'aABbc' => 'aBc', - 'z Y x' => 'zx', - 'W1v3U4t' => 'vt', + 'aABbc' => 'aBc', + 'z Y x' => 'zx', + 'W1v3U4t' => 'vt', ',sй.rλ:qν_p' => 'srqp', - 'onml' => 'onml' + 'onml' => 'onml' ); } else { //The Alphabet means each language's alphabet. $valuesExpected = array( - 'abc123' => 'abc', - 'abc 123' => 'abc', - 'abcxyz' => 'abcxyz', - 'četně' => 'četně', - 'لعربية' => 'لعربية', - 'grzegżółka' => 'grzegżółka', - 'België' => 'België', - '' => '' + 'abc123' => 'abc', + 'abc 123' => 'abc', + 'abcxyz' => 'abcxyz', + 'četně' => 'četně', + 'لعربية' => 'لعربية', + 'grzegżółka' => 'grzegżółka', + 'België' => 'België', + '' => '' ); } @@ -144,32 +145,33 @@ public function testAllowWhiteSpace() if (!self::$_unicodeEnabled) { // POSIX named classes are not supported, use alternative a-zA-Z match $valuesExpected = array( - 'abc123' => 'abc', - 'abc 123' => 'abc ', - 'abcxyz' => 'abcxyz', - '' => '', - "\n" => "\n", - " \t " => " \t " + 'abc123' => 'abc', + 'abc 123' => 'abc ', + 'abcxyz' => 'abcxyz', + '' => '', + "\n" => "\n", + " \t " => " \t " ); - } if (self::$_meansEnglishAlphabet) { + } + if (self::$_meansEnglishAlphabet) { //The Alphabet means english alphabet. $valuesExpected = array( 'a B' => 'a B', - 'zY x' => 'zx' + 'zY x' => 'zx' ); } else { //The Alphabet means each language's alphabet. $valuesExpected = array( - 'abc123' => 'abc', - 'abc 123' => 'abc ', - 'abcxyz' => 'abcxyz', - 'četně' => 'četně', - 'لعربية' => 'لعربية', - 'grzegżółka' => 'grzegżółka', - 'België' => 'België', - '' => '', - "\n" => "\n", - " \t " => " \t " + 'abc123' => 'abc', + 'abc 123' => 'abc ', + 'abcxyz' => 'abcxyz', + 'četně' => 'četně', + 'لعربية' => 'لعربية', + 'grzegżółka' => 'grzegżółka', + 'België' => 'België', + '' => '', + "\n" => "\n", + " \t " => " \t " ); } diff --git a/tests/Zend/Filter/BooleanTest.php b/tests/Zend/Filter/BooleanTest.php index 1c40ac3..fd8b75e 100644 --- a/tests/Zend/Filter/BooleanTest.php +++ b/tests/Zend/Filter/BooleanTest.php @@ -575,7 +575,9 @@ public function testSettingLocale() public function testSettingLocalePerConstructorString() { $filter = new Zend_Filter_Boolean( - 'all', true, 'de' + 'all', + true, + 'de' ); $this->assertFalse($filter->filter(false)); diff --git a/tests/Zend/Filter/Compress/Bz2Test.php b/tests/Zend/Filter/Compress/Bz2Test.php index 257cfcd..179f7f4 100644 --- a/tests/Zend/Filter/Compress/Bz2Test.php +++ b/tests/Zend/Filter/Compress/Bz2Test.php @@ -52,7 +52,7 @@ public function tearDown() */ public function testBasicUsage() { - $filter = new Zend_Filter_Compress_Bz2(); + $filter = new Zend_Filter_Compress_Bz2(); $content = $filter->compress('compress me'); $this->assertNotEquals('compress me', $content); @@ -92,7 +92,7 @@ public function testBz2GetSetOptions() */ public function testBz2GetSetOptionsInConstructor() { - $filter2= new Zend_Filter_Compress_Bz2(array('blocksize' => 8)); + $filter2 = new Zend_Filter_Compress_Bz2(array('blocksize' => 8)); $this->assertEquals(array('blocksize' => 8, 'archive' => null), $filter2->getOptions()); } @@ -111,7 +111,7 @@ public function testBz2GetSetBlocksize() try { $filter->setBlocksize(15); $this->fail('Exception expected'); - } catch(Zend_Filter_Exception $e) { + } catch (Zend_Filter_Exception $e) { $this->assertContains('must be between', $e->getMessage()); } } @@ -137,7 +137,7 @@ public function testBz2GetSetArchive() */ public function testBz2CompressToFile() { - $filter = new Zend_Filter_Compress_Bz2(); + $filter = new Zend_Filter_Compress_Bz2(); $archive = dirname(__FILE__) . '/../_files/compressed.bz2'; $filter->setArchive($archive); @@ -172,7 +172,7 @@ public function testBz2ToString() */ public function testBz2DecompressArchive() { - $filter = new Zend_Filter_Compress_Bz2(); + $filter = new Zend_Filter_Compress_Bz2(); $archive = dirname(__FILE__) . '/../_files/compressed.bz2'; $filter->setArchive($archive); diff --git a/tests/Zend/Filter/Compress/GzTest.php b/tests/Zend/Filter/Compress/GzTest.php index 4db750f..27f38e2 100644 --- a/tests/Zend/Filter/Compress/GzTest.php +++ b/tests/Zend/Filter/Compress/GzTest.php @@ -52,7 +52,7 @@ public function tearDown() */ public function testBasicUsage() { - $filter = new Zend_Filter_Compress_Gz(); + $filter = new Zend_Filter_Compress_Gz(); $content = $filter->compress('compress me'); $this->assertNotEquals('compress me', $content); @@ -94,7 +94,7 @@ public function testGzGetSetOptions() */ public function testGzGetSetOptionsInConstructor() { - $filter2= new Zend_Filter_Compress_Gz(array('level' => 8)); + $filter2 = new Zend_Filter_Compress_Gz(array('level' => 8)); $this->assertEquals(array('mode' => 'compress', 'level' => 8, 'archive' => null), $filter2->getOptions()); } @@ -113,7 +113,7 @@ public function testGzGetSetLevel() try { $filter->setLevel(15); $this->fail('Exception expected'); - } catch(Zend_Filter_Exception $e) { + } catch (Zend_Filter_Exception $e) { $this->assertContains('must be between', $e->getMessage()); } } @@ -133,7 +133,7 @@ public function testGzGetSetMode() try { $filter->setMode('unknown'); $this->fail('Exception expected'); - } catch(Zend_Filter_Exception $e) { + } catch (Zend_Filter_Exception $e) { $this->assertContains('mode not supported', $e->getMessage()); } } @@ -159,7 +159,7 @@ public function testGzGetSetArchive() */ public function testGzCompressToFile() { - $filter = new Zend_Filter_Compress_Gz(); + $filter = new Zend_Filter_Compress_Gz(); $archive = dirname(__FILE__) . '/../_files/compressed.gz'; $filter->setArchive($archive); @@ -183,7 +183,7 @@ public function testGzCompressToFile() */ public function testGzDeflate() { - $filter = new Zend_Filter_Compress_Gz(array('mode' => 'deflate')); + $filter = new Zend_Filter_Compress_Gz(array('mode' => 'deflate')); $content = $filter->compress('compress me'); $this->assertNotEquals('compress me', $content); diff --git a/tests/Zend/Filter/Compress/LzfTest.php b/tests/Zend/Filter/Compress/LzfTest.php index 8d71220..9d31dc1 100644 --- a/tests/Zend/Filter/Compress/LzfTest.php +++ b/tests/Zend/Filter/Compress/LzfTest.php @@ -45,7 +45,7 @@ public function setUp() */ public function testBasicUsage() { - $filter = new Zend_Filter_Compress_Lzf(); + $filter = new Zend_Filter_Compress_Lzf(); $text = 'compress me'; $compressed = $filter->compress($text); diff --git a/tests/Zend/Filter/Compress/RarTest.php b/tests/Zend/Filter/Compress/RarTest.php index 4172cf6..368defc 100644 --- a/tests/Zend/Filter/Compress/RarTest.php +++ b/tests/Zend/Filter/Compress/RarTest.php @@ -49,7 +49,7 @@ public function setUp() dirname(__FILE__) . '/../_files/_compress' ); - foreach($files as $file) { + foreach ($files as $file) { if (file_exists($file)) { if (is_dir($file)) { rmdir($file); @@ -81,7 +81,7 @@ public function tearDown() dirname(__FILE__) . '/../_files/_compress' ); - foreach($files as $file) { + foreach ($files as $file) { if (file_exists($file)) { if (is_dir($file)) { rmdir($file); @@ -106,7 +106,7 @@ public function tearDown() */ public function testBasicUsage() { - $filter = new Zend_Filter_Compress_Rar( + $filter = new Zend_Filter_Compress_Rar( array( 'archive' => dirname(__FILE__) . '/../_files/compressed.rar', 'target' => dirname(__FILE__) . '/../_files/zipextracted.txt', @@ -199,7 +199,7 @@ public function testRarGetSetTarget() try { $filter->setTarget('/unknown/path/to/file.txt'); $this->fails('Exception expected'); - } catch(Zend_Filter_Exception $e) { + } catch (Zend_Filter_Exception $e) { $this->assertContains('does not exist', $e->getMessage()); } } @@ -230,7 +230,6 @@ public function testSettingCallback() $callback = array('Zend_Filter_Compress_RarTest', 'rarCompress'); $filter->setCallback($callback); $this->assertEquals($callback, $filter->getCallback()); - } /** @@ -240,7 +239,7 @@ public function testSettingCallback() */ public function testRarCompressFile() { - $filter = new Zend_Filter_Compress_Rar( + $filter = new Zend_Filter_Compress_Rar( array( 'archive' => dirname(__FILE__) . '/../_files/compressed.rar', 'target' => dirname(__FILE__) . '/../_files/zipextracted.txt', @@ -267,7 +266,7 @@ public function testRarCompressFile() */ public function testRarCompressDirectory() { - $filter = new Zend_Filter_Compress_Rar( + $filter = new Zend_Filter_Compress_Rar( array( 'archive' => dirname(__FILE__) . '/../_files/compressed.rar', 'target' => dirname(__FILE__) . '/../_files/_compress', diff --git a/tests/Zend/Filter/Compress/TarTest.php b/tests/Zend/Filter/Compress/TarTest.php index 747ec74..52677d0 100644 --- a/tests/Zend/Filter/Compress/TarTest.php +++ b/tests/Zend/Filter/Compress/TarTest.php @@ -54,7 +54,7 @@ public function setUp() dirname(__FILE__) . '/../_files/compressed.tar' ); - foreach($files as $file) { + foreach ($files as $file) { if (file_exists($file)) { if (is_dir($file)) { rmdir($file); @@ -87,7 +87,7 @@ public function tearDown() dirname(__FILE__) . '/../_files/compressed.tar' ); - foreach($files as $file) { + foreach ($files as $file) { if (file_exists($file)) { if (is_dir($file)) { rmdir($file); @@ -112,10 +112,10 @@ public function tearDown() */ public function testBasicUsage() { - $filter = new Zend_Filter_Compress_Tar( + $filter = new Zend_Filter_Compress_Tar( array( - 'archive' => dirname(__FILE__) . '/../_files/compressed.tar', - 'target' => dirname(__FILE__) . '/../_files/zipextracted.txt' + 'archive' => dirname(__FILE__) . '/../_files/compressed.tar', + 'target' => dirname(__FILE__) . '/../_files/zipextracted.txt' ) ); @@ -185,7 +185,7 @@ public function testTarGetSetTarget() try { $filter->setTarget('/unknown/path/to/file.txt'); $this->fail('Exception expected'); - } catch(Zend_Filter_Exception $e) { + } catch (Zend_Filter_Exception $e) { $this->assertContains('does not exist', $e->getMessage()); } } @@ -197,10 +197,10 @@ public function testTarGetSetTarget() */ public function testTarCompressToFile() { - $filter = new Zend_Filter_Compress_Tar( + $filter = new Zend_Filter_Compress_Tar( array( - 'archive' => dirname(__FILE__) . '/../_files/compressed.tar', - 'target' => dirname(__FILE__) . '/../_files/zipextracted.txt' + 'archive' => dirname(__FILE__) . '/../_files/compressed.tar', + 'target' => dirname(__FILE__) . '/../_files/zipextracted.txt' ) ); file_put_contents(dirname(__FILE__) . '/../_files/zipextracted.txt', 'compress me'); @@ -222,10 +222,10 @@ public function testTarCompressToFile() */ public function testTarCompressDirectory() { - $filter = new Zend_Filter_Compress_Tar( + $filter = new Zend_Filter_Compress_Tar( array( - 'archive' => dirname(__FILE__) . '/../_files/compressed.tar', - 'target' => dirname(__FILE__) . '/../_files/_compress' + 'archive' => dirname(__FILE__) . '/../_files/compressed.tar', + 'target' => dirname(__FILE__) . '/../_files/_compress' ) ); $content = $filter->compress(dirname(__FILE__) . '/../_files/Compress'); diff --git a/tests/Zend/Filter/Compress/ZipTest.php b/tests/Zend/Filter/Compress/ZipTest.php index 52b08b0..9e491e6 100644 --- a/tests/Zend/Filter/Compress/ZipTest.php +++ b/tests/Zend/Filter/Compress/ZipTest.php @@ -51,7 +51,7 @@ public function setUp() dirname(__FILE__) . '/../_files/_compress' ); - foreach($files as $file) { + foreach ($files as $file) { if (file_exists($file)) { if (is_dir($file)) { rmdir($file); @@ -85,7 +85,7 @@ public function tearDown() dirname(__FILE__) . '/../_files/_compress' ); - foreach($files as $file) { + foreach ($files as $file) { if (file_exists($file)) { if (is_dir($file)) { rmdir($file); @@ -110,7 +110,7 @@ public function tearDown() */ public function testBasicUsage() { - $filter = new Zend_Filter_Compress_Zip( + $filter = new Zend_Filter_Compress_Zip( array( 'archive' => dirname(__FILE__) . '/../_files/compressed.zip', 'target' => dirname(__FILE__) . '/../_files/zipextracted.txt' @@ -177,7 +177,7 @@ public function testZipGetSetTarget() try { $filter->setTarget('/unknown/path/to/file.txt'); $this->fails('Exception expected'); - } catch(Zend_Filter_Exception $e) { + } catch (Zend_Filter_Exception $e) { $this->assertContains('does not exist', $e->getMessage()); } } @@ -189,7 +189,7 @@ public function testZipGetSetTarget() */ public function testZipCompressFile() { - $filter = new Zend_Filter_Compress_Zip( + $filter = new Zend_Filter_Compress_Zip( array( 'archive' => dirname(__FILE__) . '/../_files/compressed.zip', 'target' => dirname(__FILE__) . '/../_files/zipextracted.txt' @@ -215,7 +215,7 @@ public function testZipCompressFile() */ public function testCompressNonExistingTargetFile() { - $filter = new Zend_Filter_Compress_Zip( + $filter = new Zend_Filter_Compress_Zip( array( 'archive' => dirname(__FILE__) . '/../_files/compressed.zip', 'target' => dirname(__FILE__) . '/../_files' @@ -239,7 +239,7 @@ public function testCompressNonExistingTargetFile() */ public function testZipCompressDirectory() { - $filter = new Zend_Filter_Compress_Zip( + $filter = new Zend_Filter_Compress_Zip( array( 'archive' => dirname(__FILE__) . '/../_files/compressed.zip', 'target' => dirname(__FILE__) . '/../_files/_compress' @@ -285,7 +285,7 @@ public function testDecompressWillThrowExceptionWhenDecompressingWithNoTarget() { $this->expectException(\Zend_Filter_Exception::class); - $filter = new Zend_Filter_Compress_Zip( + $filter = new Zend_Filter_Compress_Zip( array( 'archive' => dirname(__FILE__) . '/../_files/compressed.zip', 'target' => dirname(__FILE__) . '/../_files/_compress' @@ -296,7 +296,7 @@ public function testDecompressWillThrowExceptionWhenDecompressingWithNoTarget() $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'compressed.zip', $content); - $filter = new Zend_Filter_Compress_Zip( + $filter = new Zend_Filter_Compress_Zip( array( 'archive' => dirname(__FILE__) . '/../_files/compressed.zip' ) @@ -319,7 +319,7 @@ public function testDecompressWillThrowExceptionWhenDetectingUpwardDirectoryTrav return; } - $filter = new Zend_Filter_Compress_Zip( + $filter = new Zend_Filter_Compress_Zip( array( 'archive' => dirname(__FILE__) . '/../_files/compressed.zip', 'target' => dirname(__FILE__) . '/../_files/evil.zip' diff --git a/tests/Zend/Filter/CompressTest.php b/tests/Zend/Filter/CompressTest.php index cbf7789..ba16735 100644 --- a/tests/Zend/Filter/CompressTest.php +++ b/tests/Zend/Filter/CompressTest.php @@ -52,9 +52,9 @@ public function tearDown() */ public function testBasicUsage() { - $filter = new Zend_Filter_Compress('bz2'); + $filter = new Zend_Filter_Compress('bz2'); - $text = 'compress me'; + $text = 'compress me'; $compressed = $filter->filter($text); $this->assertNotEquals($text, $compressed); @@ -100,7 +100,7 @@ public function testGetSetAdapterOptions() 'archive' => 'test.txt', )); $this->assertEquals( - array('blocksize' => 6, 'archive' => 'test.txt'), + array('blocksize' => 6, 'archive' => 'test.txt'), $filter->getAdapterOptions() ); $adapter = $filter->getAdapter(); @@ -123,7 +123,7 @@ public function testGetSetBlocksize() try { $filter->setBlocksize(15); $this->fail('Exception expected'); - } catch(Zend_Filter_Exception $e) { + } catch (Zend_Filter_Exception $e) { $this->assertContains('must be between', $e->getMessage()); } } @@ -149,7 +149,7 @@ public function testGetSetArchive() */ public function testCompressToFile() { - $filter = new Zend_Filter_Compress('bz2'); + $filter = new Zend_Filter_Compress('bz2'); $archive = dirname(__FILE__) . '/../_files/compressed.bz2'; $filter->setArchive($archive); @@ -184,7 +184,7 @@ public function testToString() */ public function testGetAdapter() { - $filter = new Zend_Filter_Compress('bz2'); + $filter = new Zend_Filter_Compress('bz2'); $adapter = $filter->getAdapter(); $this->assertTrue($adapter instanceof Zend_Filter_Compress_CompressInterface); $this->assertEquals('Bz2', $filter->getAdapterName()); @@ -220,7 +220,7 @@ public function testSetAdapter() */ public function testDecompressArchive() { - $filter = new Zend_Filter_Compress('bz2'); + $filter = new Zend_Filter_Compress('bz2'); $archive = dirname(__FILE__) . '/../_files/compressed.bz2'; $filter->setArchive($archive); diff --git a/tests/Zend/Filter/DecompressTest.php b/tests/Zend/Filter/DecompressTest.php index e77cc17..cae6a19 100644 --- a/tests/Zend/Filter/DecompressTest.php +++ b/tests/Zend/Filter/DecompressTest.php @@ -52,7 +52,7 @@ public function tearDown() */ public function testBasicUsage() { - $filter = new Zend_Filter_Decompress('bz2'); + $filter = new Zend_Filter_Decompress('bz2'); $text = 'compress me'; $compressed = $filter->compress($text); @@ -69,7 +69,7 @@ public function testBasicUsage() */ public function testCompressToFile() { - $filter = new Zend_Filter_Decompress('bz2'); + $filter = new Zend_Filter_Decompress('bz2'); $archive = dirname(__FILE__) . '/../_files/compressed.bz2'; $filter->setArchive($archive); @@ -93,7 +93,7 @@ public function testCompressToFile() */ public function testDecompressArchive() { - $filter = new Zend_Filter_Decompress('bz2'); + $filter = new Zend_Filter_Decompress('bz2'); $archive = dirname(__FILE__) . '/../_files/compressed.bz2'; $filter->setArchive($archive); diff --git a/tests/Zend/Filter/DecryptTest.php b/tests/Zend/Filter/DecryptTest.php index 027c4fe..b6eacbc 100644 --- a/tests/Zend/Filter/DecryptTest.php +++ b/tests/Zend/Filter/DecryptTest.php @@ -66,7 +66,7 @@ public function testBasicMcrypt() $this->markTestSkipped('Mcrypt extension not installed'); } - $filter = new Zend_Filter_Decrypt(array('adapter' => 'Mcrypt')); + $filter = new Zend_Filter_Decrypt(array('adapter' => 'Mcrypt')); $valuesExpected = array( 'STRING' => 'STRING', 'ABC1@3' => 'ABC1@3', @@ -120,7 +120,8 @@ public function testBasicOpenssl() d/fxzPfuO/bLpADozTAnYT9Hu3wPrQVLeAfCp0ojqH7DYg== -----END RSA PRIVATE KEY----- '), - $key); + $key + ); } @@ -181,8 +182,9 @@ public function testGetSetEncryption() $filter = new Zend_Filter_Decrypt(array('adapter' => 'Mcrypt', 'key' => 'testkey')); $filter->setVector('testvect'); $filter->setEncryption( - array('mode' => MCRYPT_MODE_ECB, - 'algorithm' => MCRYPT_3DES)); + array('mode' => MCRYPT_MODE_ECB, + 'algorithm' => MCRYPT_3DES) + ); $this->assertEquals( array( 'mode' => MCRYPT_MODE_ECB, @@ -233,7 +235,7 @@ public function testEncryptionWithDecryptionOpenssl() $filter = new Zend_Filter_Encrypt(array('adapter' => 'Openssl')); $filter->setPublicKey(dirname(__FILE__) . '/_files/publickey.pem'); - $output = $filter->filter('teststring'); + $output = $filter->filter('teststring'); $envelopekeys = $filter->getEnvelopeKey(); $this->assertNotEquals('teststring', $output); diff --git a/tests/Zend/Filter/DigitsTest.php b/tests/Zend/Filter/DigitsTest.php index 04ec893..8eb3cf8 100644 --- a/tests/Zend/Filter/DigitsTest.php +++ b/tests/Zend/Filter/DigitsTest.php @@ -77,9 +77,9 @@ public function testBasic() */ $valuesExpected = array( '192八3四8' => '123', - 'C 4.5B 6' => '456', + 'C 4.5B 6' => '456', '9壱8@7.6,5#4' => '987654', - '789' => '789' + '789' => '789' ); } else { // POSIX named classes are not supported, use alternative 0-9 match diff --git a/tests/Zend/Filter/Encrypt/McryptTest.php b/tests/Zend/Filter/Encrypt/McryptTest.php index 0176c9d..8bf0550 100644 --- a/tests/Zend/Filter/Encrypt/McryptTest.php +++ b/tests/Zend/Filter/Encrypt/McryptTest.php @@ -60,7 +60,7 @@ public function tearDown() */ public function testBasicMcrypt() { - $filter = new Zend_Filter_Encrypt_Mcrypt(array('key' => 'testkey')); + $filter = new Zend_Filter_Encrypt_Mcrypt(array('key' => 'testkey')); $valuesExpected = array( 'STRING' => 'STRING', 'ABC1@3' => 'ABC1@3', @@ -104,13 +104,13 @@ public function testDefaultEncryption() $filter = new Zend_Filter_Encrypt_Mcrypt(array('key' => 'testkey')); $filter->setVector('testvect'); $this->assertEquals( - array('key' => 'testkey', - 'algorithm' => MCRYPT_BLOWFISH, + array('key' => 'testkey', + 'algorithm' => MCRYPT_BLOWFISH, 'algorithm_directory' => '', - 'mode' => MCRYPT_MODE_CBC, - 'mode_directory' => '', - 'vector' => 'testvect', - 'salt' => false), + 'mode' => MCRYPT_MODE_CBC, + 'mode_directory' => '', + 'vector' => 'testvect', + 'salt' => false), $filter->getEncryption() ); } @@ -125,16 +125,17 @@ public function testGetSetEncryption() $filter = new Zend_Filter_Encrypt_Mcrypt(array('key' => 'testkey')); $filter->setVector('testvect'); $filter->setEncryption( - array('mode' => MCRYPT_MODE_ECB, - 'algorithm' => MCRYPT_3DES)); + array('mode' => MCRYPT_MODE_ECB, + 'algorithm' => MCRYPT_3DES) + ); $this->assertEquals( - array('key' => 'testkey', - 'algorithm' => MCRYPT_3DES, + array('key' => 'testkey', + 'algorithm' => MCRYPT_3DES, 'algorithm_directory' => '', - 'mode' => MCRYPT_MODE_ECB, - 'mode_directory' => '', - 'vector' => 'testvect', - 'salt' => false), + 'mode' => MCRYPT_MODE_ECB, + 'mode_directory' => '', + 'vector' => 'testvect', + 'salt' => false), $filter->getEncryption() ); } @@ -162,7 +163,7 @@ public function testEncryptionWithDecryptionMcrypt() public function testConstructionWithStringKey() { $filter = new Zend_Filter_Encrypt_Mcrypt('testkey'); - $data = $filter->getEncryption(); + $data = $filter->getEncryption(); $this->assertEquals('testkey', $data['key']); } diff --git a/tests/Zend/Filter/Encrypt/OpensslTest.php b/tests/Zend/Filter/Encrypt/OpensslTest.php index 7d370e2..6bcfcce 100644 --- a/tests/Zend/Filter/Encrypt/OpensslTest.php +++ b/tests/Zend/Filter/Encrypt/OpensslTest.php @@ -45,7 +45,7 @@ public function setUp() */ public function testBasicOpenssl() { - $filter = new Zend_Filter_Encrypt_Openssl(dirname(__FILE__) . '/../_files/publickey.pem'); + $filter = new Zend_Filter_Encrypt_Openssl(dirname(__FILE__) . '/../_files/publickey.pem'); $valuesExpected = array( 'STRING' => 'STRING', 'ABC1@3' => 'ABC1@3', @@ -74,7 +74,8 @@ public function testBasicOpenssl() PIDs9E7uuizAKDhRRRvho8BS -----END CERTIFICATE----- '), - $key); + $key + ); foreach ($valuesExpected as $input => $output) { $this->assertNotEquals($output, $filter->encrypt($input)); } @@ -89,7 +90,7 @@ public function testEncryptionWithDecryptionOpenssl() { $filter = new Zend_Filter_Encrypt_Openssl(); $filter->setPublicKey(dirname(__FILE__) . '/../_files/publickey.pem'); - $output = $filter->encrypt('teststring'); + $output = $filter->encrypt('teststring'); $envelopekeys = $filter->getEnvelopeKey(); $this->assertNotEquals('teststring', $output); @@ -114,7 +115,7 @@ public function testEncryptionWithDecryptionSingleOptionOpenssl() { $filter = new Zend_Filter_Encrypt_Openssl(); $filter->setPublicKey(dirname(__FILE__) . '/../_files/publickey.pem'); - $output = $filter->encrypt('teststring'); + $output = $filter->encrypt('teststring'); $envelopekeys = $filter->getEnvelopeKey(); $this->assertNotEquals('teststring', $output); @@ -245,9 +246,9 @@ public function testMultipleOptionsAtInitiation() Izcez5wgmkpNElg/D7/VCd9E+grTfPYNmuTVccGOes+n8ISJJdW0vYX1xwWv5l bK22CwD/l7SMBOz4M9XH0Jb0OhNxLza4XMDu0ANMIpnkn1KOcmQ4gB8fmAbBt'; $filter = new Zend_Filter_Encrypt_Openssl(array( - 'public' => dirname(__FILE__) . '/../_files/publickey.pem', + 'public' => dirname(__FILE__) . '/../_files/publickey.pem', 'passphrase' => $passphrase, - 'private' => dirname(__FILE__) . '/../_files/privatekey.pem')); + 'private' => dirname(__FILE__) . '/../_files/privatekey.pem')); $public = $filter->getPublicKey(); $this->assertNotEmpty($public); $this->assertEquals($passphrase, $filter->getPassphrase()); diff --git a/tests/Zend/Filter/EncryptTest.php b/tests/Zend/Filter/EncryptTest.php index 3c19d90..f481d59 100644 --- a/tests/Zend/Filter/EncryptTest.php +++ b/tests/Zend/Filter/EncryptTest.php @@ -66,7 +66,7 @@ public function testBasicMcrypt() $this->markTestSkipped('Mcrypt extension not installed'); } - $filter = new Zend_Filter_Encrypt(array('adapter' => 'Mcrypt', 'key' => 'testkey')); + $filter = new Zend_Filter_Encrypt(array('adapter' => 'Mcrypt', 'key' => 'testkey')); $valuesExpected = array( 'STRING' => 'STRING', 'ABC1@3' => 'ABC1@3', @@ -92,7 +92,7 @@ public function testBasicOpenssl() $this->markTestSkipped('Openssl extension not installed'); } - $filter = new Zend_Filter_Encrypt(array('adapter' => 'Openssl')); + $filter = new Zend_Filter_Encrypt(array('adapter' => 'Openssl')); $valuesExpected = array( 'STRING' => 'STRING', 'ABC1@3' => 'ABC1@3', @@ -122,7 +122,8 @@ public function testBasicOpenssl() PIDs9E7uuizAKDhRRRvho8BS -----END CERTIFICATE----- '), - $key); + $key + ); foreach ($valuesExpected as $input => $output) { $this->assertNotEquals($output, $filter->filter($input)); } @@ -159,13 +160,13 @@ public function testDefaultEncryption() $filter = new Zend_Filter_Encrypt(array('adapter' => 'Mcrypt', 'key' => 'testkey')); $filter->setVector('testvect'); $this->assertEquals( - array('key' => 'testkey', - 'algorithm' => MCRYPT_BLOWFISH, + array('key' => 'testkey', + 'algorithm' => MCRYPT_BLOWFISH, 'algorithm_directory' => '', - 'mode' => MCRYPT_MODE_CBC, - 'mode_directory' => '', - 'vector' => 'testvect', - 'salt' => false), + 'mode' => MCRYPT_MODE_CBC, + 'mode_directory' => '', + 'vector' => 'testvect', + 'salt' => false), $filter->getEncryption() ); } @@ -184,16 +185,17 @@ public function testGetSetEncryption() $filter = new Zend_Filter_Encrypt(array('adapter' => 'Mcrypt', 'key' => 'testkey')); $filter->setVector('testvect'); $filter->setEncryption( - array('mode' => MCRYPT_MODE_ECB, - 'algorithm' => MCRYPT_3DES)); + array('mode' => MCRYPT_MODE_ECB, + 'algorithm' => MCRYPT_3DES) + ); $this->assertEquals( - array('key' => 'testkey', - 'algorithm' => MCRYPT_3DES, + array('key' => 'testkey', + 'algorithm' => MCRYPT_3DES, 'algorithm_directory' => '', - 'mode' => MCRYPT_MODE_ECB, - 'mode_directory' => '', - 'vector' => 'testvect', - 'salt' => false), + 'mode' => MCRYPT_MODE_ECB, + 'mode_directory' => '', + 'vector' => 'testvect', + 'salt' => false), $filter->getEncryption() ); } @@ -234,7 +236,7 @@ public function testEncryptionWithDecryptionOpenssl() $filter = new Zend_Filter_Encrypt(array('adapter' => 'Openssl')); $filter->setPublicKey(dirname(__FILE__) . '/_files/publickey.pem'); - $output = $filter->filter('teststring'); + $output = $filter->filter('teststring'); $envelopekeys = $filter->getEnvelopeKey(); $this->assertNotEquals('teststring', $output); diff --git a/tests/Zend/Filter/File/DecryptTest.php b/tests/Zend/Filter/File/DecryptTest.php index 233ff43..54867a2 100644 --- a/tests/Zend/Filter/File/DecryptTest.php +++ b/tests/Zend/Filter/File/DecryptTest.php @@ -43,12 +43,12 @@ public function setUp() $this->markTestSkipped('This filter needs the mcrypt extension'); } - if (file_exists(dirname(__FILE__).'/../_files/newencryption.txt')) { - unlink(dirname(__FILE__).'/../_files/newencryption.txt'); + if (file_exists(dirname(__FILE__) . '/../_files/newencryption.txt')) { + unlink(dirname(__FILE__) . '/../_files/newencryption.txt'); } - if (file_exists(dirname(__FILE__).'/../_files/newencryption2.txt')) { - unlink(dirname(__FILE__).'/../_files/newencryption2.txt'); + if (file_exists(dirname(__FILE__) . '/../_files/newencryption2.txt')) { + unlink(dirname(__FILE__) . '/../_files/newencryption2.txt'); } } @@ -58,12 +58,12 @@ public function tearDown() error_reporting($this->errorReporting); } - if (file_exists(dirname(__FILE__).'/../_files/newencryption.txt')) { - unlink(dirname(__FILE__).'/../_files/newencryption.txt'); + if (file_exists(dirname(__FILE__) . '/../_files/newencryption.txt')) { + unlink(dirname(__FILE__) . '/../_files/newencryption.txt'); } - if (file_exists(dirname(__FILE__).'/../_files/newencryption2.txt')) { - unlink(dirname(__FILE__).'/../_files/newencryption2.txt'); + if (file_exists(dirname(__FILE__) . '/../_files/newencryption2.txt')) { + unlink(dirname(__FILE__) . '/../_files/newencryption2.txt'); } } @@ -75,57 +75,66 @@ public function tearDown() public function testBasic() { $filter = new Zend_Filter_File_Encrypt(); - $filter->setFilename(dirname(__FILE__).'/../_files/newencryption.txt'); + $filter->setFilename(dirname(__FILE__) . '/../_files/newencryption.txt'); $this->assertEquals( - dirname(__FILE__).'/../_files/newencryption.txt', - $filter->getFilename()); + dirname(__FILE__) . '/../_files/newencryption.txt', + $filter->getFilename() + ); $filter->setVector('testvect'); - $filter->filter(dirname(__FILE__).'/../_files/encryption.txt'); + $filter->filter(dirname(__FILE__) . '/../_files/encryption.txt'); $filter = new Zend_Filter_File_Decrypt(); $this->assertNotEquals( 'Encryption', - file_get_contents(dirname(__FILE__).'/../_files/newencryption.txt')); + file_get_contents(dirname(__FILE__) . '/../_files/newencryption.txt') + ); $filter->setVector('testvect'); $this->assertEquals( - dirname(__FILE__).'/../_files/newencryption.txt', - $filter->filter(dirname(__FILE__).'/../_files/newencryption.txt')); + dirname(__FILE__) . '/../_files/newencryption.txt', + $filter->filter(dirname(__FILE__) . '/../_files/newencryption.txt') + ); $this->assertEquals( 'Encryption', - trim(file_get_contents(dirname(__FILE__).'/../_files/newencryption.txt'))); + trim(file_get_contents(dirname(__FILE__) . '/../_files/newencryption.txt')) + ); } public function testEncryptionWithDecryption() { $filter = new Zend_Filter_File_Encrypt(); - $filter->setFilename(dirname(__FILE__).'/../_files/newencryption.txt'); + $filter->setFilename(dirname(__FILE__) . '/../_files/newencryption.txt'); $filter->setVector('testvect'); - $this->assertEquals(dirname(__FILE__).'/../_files/newencryption.txt', - $filter->filter(dirname(__FILE__).'/../_files/encryption.txt')); + $this->assertEquals( + dirname(__FILE__) . '/../_files/newencryption.txt', + $filter->filter(dirname(__FILE__) . '/../_files/encryption.txt') + ); $this->assertNotEquals( 'Encryption', - file_get_contents(dirname(__FILE__).'/../_files/newencryption.txt')); + file_get_contents(dirname(__FILE__) . '/../_files/newencryption.txt') + ); $filter = new Zend_Filter_File_Decrypt(); - $filter->setFilename(dirname(__FILE__).'/../_files/newencryption2.txt'); + $filter->setFilename(dirname(__FILE__) . '/../_files/newencryption2.txt'); $this->assertEquals( - dirname(__FILE__).'/../_files/newencryption2.txt', - $filter->getFilename()); + dirname(__FILE__) . '/../_files/newencryption2.txt', + $filter->getFilename() + ); $filter->setVector('testvect'); - $input = $filter->filter(dirname(__FILE__).'/../_files/newencryption.txt'); - $this->assertEquals(dirname(__FILE__).'/../_files/newencryption2.txt', $input); + $input = $filter->filter(dirname(__FILE__) . '/../_files/newencryption.txt'); + $this->assertEquals(dirname(__FILE__) . '/../_files/newencryption2.txt', $input); $this->assertEquals( 'Encryption', - trim(file_get_contents(dirname(__FILE__).'/../_files/newencryption2.txt'))); + trim(file_get_contents(dirname(__FILE__) . '/../_files/newencryption2.txt')) + ); } /** @@ -137,7 +146,7 @@ public function testNonExistingFile() $filter->setVector('testvect'); try { - $filter->filter(dirname(__FILE__).'/../_files/nofile.txt'); + $filter->filter(dirname(__FILE__) . '/../_files/nofile.txt'); $this->fail(); } catch (Zend_Filter_Exception $e) { $this->assertContains('not found', $e->getMessage()); diff --git a/tests/Zend/Filter/File/EncryptTest.php b/tests/Zend/Filter/File/EncryptTest.php index ee8f063..ba7a029 100644 --- a/tests/Zend/Filter/File/EncryptTest.php +++ b/tests/Zend/Filter/File/EncryptTest.php @@ -43,8 +43,8 @@ public function setUp() $this->markTestSkipped('This filter needs the mcrypt extension'); } - if (file_exists(dirname(__FILE__).'/../_files/newencryption.txt')) { - unlink(dirname(__FILE__).'/../_files/newencryption.txt'); + if (file_exists(dirname(__FILE__) . '/../_files/newencryption.txt')) { + unlink(dirname(__FILE__) . '/../_files/newencryption.txt'); } } @@ -54,8 +54,8 @@ public function tearDown() error_reporting($this->errorReporting); } - if (file_exists(dirname(__FILE__).'/../_files/newencryption.txt')) { - unlink(dirname(__FILE__).'/../_files/newencryption.txt'); + if (file_exists(dirname(__FILE__) . '/../_files/newencryption.txt')) { + unlink(dirname(__FILE__) . '/../_files/newencryption.txt'); } } @@ -67,45 +67,54 @@ public function tearDown() public function testBasic() { $filter = new Zend_Filter_File_Encrypt(); - $filter->setFilename(dirname(__FILE__).'/../_files/newencryption.txt'); + $filter->setFilename(dirname(__FILE__) . '/../_files/newencryption.txt'); $this->assertEquals( - dirname(__FILE__).'/../_files/newencryption.txt', - $filter->getFilename()); + dirname(__FILE__) . '/../_files/newencryption.txt', + $filter->getFilename() + ); $filter->setVector('testvect'); - $this->assertEquals(dirname(__FILE__).'/../_files/newencryption.txt', - $filter->filter(dirname(__FILE__).'/../_files/encryption.txt')); + $this->assertEquals( + dirname(__FILE__) . '/../_files/newencryption.txt', + $filter->filter(dirname(__FILE__) . '/../_files/encryption.txt') + ); $this->assertEquals( 'Encryption', - file_get_contents(dirname(__FILE__).'/../_files/encryption.txt')); + file_get_contents(dirname(__FILE__) . '/../_files/encryption.txt') + ); $this->assertNotEquals( 'Encryption', - file_get_contents(dirname(__FILE__).'/../_files/newencryption.txt')); + file_get_contents(dirname(__FILE__) . '/../_files/newencryption.txt') + ); } public function testEncryptionWithDecryption() { $filter = new Zend_Filter_File_Encrypt(); - $filter->setFilename(dirname(__FILE__).'/../_files/newencryption.txt'); + $filter->setFilename(dirname(__FILE__) . '/../_files/newencryption.txt'); $filter->setVector('testvect'); - $this->assertEquals(dirname(__FILE__).'/../_files/newencryption.txt', - $filter->filter(dirname(__FILE__).'/../_files/encryption.txt')); + $this->assertEquals( + dirname(__FILE__) . '/../_files/newencryption.txt', + $filter->filter(dirname(__FILE__) . '/../_files/encryption.txt') + ); $this->assertNotEquals( 'Encryption', - file_get_contents(dirname(__FILE__).'/../_files/newencryption.txt')); + file_get_contents(dirname(__FILE__) . '/../_files/newencryption.txt') + ); $filter = new Zend_Filter_File_Decrypt(); $filter->setVector('testvect'); - $input = $filter->filter(dirname(__FILE__).'/../_files/newencryption.txt'); - $this->assertEquals(dirname(__FILE__).'/../_files/newencryption.txt', $input); + $input = $filter->filter(dirname(__FILE__) . '/../_files/newencryption.txt'); + $this->assertEquals(dirname(__FILE__) . '/../_files/newencryption.txt', $input); $this->assertEquals( 'Encryption', - trim(file_get_contents(dirname(__FILE__).'/../_files/newencryption.txt'))); + trim(file_get_contents(dirname(__FILE__) . '/../_files/newencryption.txt')) + ); } /** @@ -117,7 +126,7 @@ public function testNonExistingFile() $filter->setVector('testvect'); try { - $filter->filter(dirname(__FILE__).'/../_files/nofile.txt'); + $filter->filter(dirname(__FILE__) . '/../_files/nofile.txt'); $this->fail(); } catch (Zend_Filter_Exception $e) { $this->assertContains('not found', $e->getMessage()); @@ -132,11 +141,12 @@ public function testEncryptionInSameFile() $filter = new Zend_Filter_File_Encrypt(); $filter->setVector('testvect'); - copy(dirname(__FILE__).'/../_files/encryption.txt', dirname(__FILE__).'/../_files/newencryption.txt'); - $filter->filter(dirname(__FILE__).'/../_files/newencryption.txt'); + copy(dirname(__FILE__) . '/../_files/encryption.txt', dirname(__FILE__) . '/../_files/newencryption.txt'); + $filter->filter(dirname(__FILE__) . '/../_files/newencryption.txt'); $this->assertNotEquals( 'Encryption', - trim(file_get_contents(dirname(__FILE__).'/../_files/newencryption.txt'))); + trim(file_get_contents(dirname(__FILE__) . '/../_files/newencryption.txt')) + ); } } diff --git a/tests/Zend/Filter/File/LowerCaseTest.php b/tests/Zend/Filter/File/LowerCaseTest.php index eb6b151..8c2d24f 100644 --- a/tests/Zend/Filter/File/LowerCaseTest.php +++ b/tests/Zend/Filter/File/LowerCaseTest.php @@ -61,8 +61,8 @@ public function setUp() { $this->_filesPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR; - $this->_origFile = $this->_filesPath . 'testfile2.txt'; - $this->_newFile = $this->_filesPath . 'newtestfile2.txt'; + $this->_origFile = $this->_filesPath . 'testfile2.txt'; + $this->_newFile = $this->_filesPath . 'newtestfile2.txt'; if (!file_exists($this->_newFile)) { copy($this->_origFile, $this->_newFile); } diff --git a/tests/Zend/Filter/File/RenameTest.php b/tests/Zend/Filter/File/RenameTest.php index 564971d..cac1233 100644 --- a/tests/Zend/Filter/File/RenameTest.php +++ b/tests/Zend/Filter/File/RenameTest.php @@ -82,10 +82,10 @@ public function setUp() { $this->_filesPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR; - $this->_origFile = $this->_filesPath . 'original.file'; - $this->_oldFile = $this->_filesPath . 'testfile.txt'; - $this->_newFile = $this->_filesPath . 'newfile.xml'; - $this->_newDir = $this->_filesPath . DIRECTORY_SEPARATOR . '_testDir2'; + $this->_origFile = $this->_filesPath . 'original.file'; + $this->_oldFile = $this->_filesPath . 'testfile.txt'; + $this->_newFile = $this->_filesPath . 'newfile.xml'; + $this->_newDir = $this->_filesPath . DIRECTORY_SEPARATOR . '_testDir2'; $this->_newDirFile = $this->_newDir . DIRECTORY_SEPARATOR . 'testfile.txt'; if (file_exists($this->_origFile)) { unlink($this->_origFile); @@ -135,11 +135,13 @@ public function testConstructSingleValue() { $filter = new Zend_Filter_File_Rename($this->_newFile); - $this->assertEquals(array(0 => + $this->assertEquals( + array(0 => array('source' => '*', 'target' => $this->_newFile, 'overwrite' => false)), - $filter->getFile()); + $filter->getFile() + ); $this->assertEquals($this->_newFile, $filter->filter($this->_oldFile)); $this->assertEquals('falsefile', $filter->filter('falsefile')); } @@ -171,8 +173,8 @@ public function testConstructSingleArray() public function testConstructFullOptionsArray() { $filter = new Zend_Filter_File_Rename(array( - 'source' => $this->_oldFile, - 'target' => $this->_newFile, + 'source' => $this->_oldFile, + 'target' => $this->_newFile, 'overwrite' => true, 'unknown' => false)); diff --git a/tests/Zend/Filter/File/UpperCaseTest.php b/tests/Zend/Filter/File/UpperCaseTest.php index 7156e25..cc537b8 100644 --- a/tests/Zend/Filter/File/UpperCaseTest.php +++ b/tests/Zend/Filter/File/UpperCaseTest.php @@ -61,8 +61,8 @@ public function setUp() { $this->_filesPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR; - $this->_origFile = $this->_filesPath . 'testfile2.txt'; - $this->_newFile = $this->_filesPath . 'newtestfile2.txt'; + $this->_origFile = $this->_filesPath . 'testfile2.txt'; + $this->_newFile = $this->_filesPath . 'newtestfile2.txt'; if (!file_exists($this->_newFile)) { copy($this->_origFile, $this->_newFile); } diff --git a/tests/Zend/Filter/InflectorTest.php b/tests/Zend/Filter/InflectorTest.php index d875354..c7f2597 100644 --- a/tests/Zend/Filter/InflectorTest.php +++ b/tests/Zend/Filter/InflectorTest.php @@ -68,7 +68,7 @@ public function testGetPluginLoaderReturnsLoaderByDefault() public function testSetPluginLoaderAllowsSettingAlternatePluginLoader() { $defaultLoader = $this->inflector->getPluginLoader(); - $loader = new Zend_Loader_PluginLoader(); + $loader = new Zend_Loader_PluginLoader(); $this->inflector->setPluginLoader($loader); $receivedLoader = $this->inflector->getPluginLoader(); $this->assertNotSame($defaultLoader, $receivedLoader); @@ -328,10 +328,10 @@ public function testTargetExceptionNotThrownOnIdentifierNotFollowedByCharacter() public function getOptions() { $options = array( - 'target' => '$controller/$action.$suffix', - 'throwTargetExceptionsOn' => true, + 'target' => '$controller/$action.$suffix', + 'throwTargetExceptionsOn' => true, 'targetReplacementIdentifier' => '$', - 'rules' => array( + 'rules' => array( ':controller' => array( 'rule1' => 'Word_CamelCaseToUnderscore', 'rule2' => 'StringToLower', @@ -385,14 +385,14 @@ protected function _testOptions($inflector) public function testPassingConfigObjectToConstructorSetsStateAndRules() { - $config = $this->getConfig(); + $config = $this->getConfig(); $inflector = new Zend_Filter_Inflector($config); $this->_testOptions($inflector); } public function testSetConfigSetsStateAndRules() { - $config = $this->getConfig(); + $config = $this->getConfig(); $inflector = new Zend_Filter_Inflector(); $inflector->setConfig($config); $this->_testOptions($inflector); @@ -405,7 +405,6 @@ public function testSetConfigSetsStateAndRules() */ public function testCheckInflectorWithPregBackreferenceLikeParts() { - $this->inflector = new Zend_Filter_Inflector( ':moduleDir' . DIRECTORY_SEPARATOR . ':controller' . DIRECTORY_SEPARATOR . ':action.:suffix', array( @@ -422,7 +421,7 @@ public function testCheckInflectorWithPregBackreferenceLikeParts() try { $filtered = $this->inflector->filter(array( 'controller' => 'FooBar', - 'action' => 'MooToo' + 'action' => 'MooToo' )); $this->assertEquals($filtered, 'C:\htdocs\public\cache\00\01\42\app\modules' . DIRECTORY_SEPARATOR . 'foo-bar' . DIRECTORY_SEPARATOR . 'Moo-Too.phtml'); } catch (Exception $e) { @@ -467,7 +466,7 @@ public function testAddFilterRuleMultipleTimes() $rules = $this->inflector->getRules('controller'); $this->assertEquals(3, count($rules)); $this->_context = 'StringToLower'; - $this->inflector->setStaticRuleReference('context' , $this->_context); + $this->inflector->setStaticRuleReference('context', $this->_context); $this->inflector->addFilterRule('controller', array('Alpha', 'StringToLower')); $rules = $this->inflector->getRules('controller'); $this->assertEquals(5, count($rules)); @@ -478,7 +477,7 @@ public function testAddFilterRuleMultipleTimes() */ public function testPassingArrayToConstructorSetsStateAndRules() { - $options = $this->getOptions(); + $options = $this->getOptions(); $inflector = new Zend_Filter_Inflector($options); $this->_testOptions($inflector); } @@ -488,7 +487,7 @@ public function testPassingArrayToConstructorSetsStateAndRules() */ public function testPassingArrayToSetConfigSetsStateAndRules() { - $options = $this->getOptions(); + $options = $this->getOptions(); $inflector = new Zend_Filter_Inflector(); $inflector->setOptions($options); $this->_testOptions($inflector); @@ -499,7 +498,7 @@ public function testPassingArrayToSetConfigSetsStateAndRules() */ public function testPassingZendConfigObjectToConstructorSetsStateAndRules() { - $config = $this->getConfig(); + $config = $this->getConfig(); $inflector = new Zend_Filter_Inflector($config); $this->_testOptions($inflector); } @@ -509,7 +508,7 @@ public function testPassingZendConfigObjectToConstructorSetsStateAndRules() */ public function testPassingZendConfigObjectToSetConfigSetsStateAndRules() { - $config = $this->getConfig(); + $config = $this->getConfig(); $inflector = new Zend_Filter_Inflector(); $inflector->setOptions($config); $this->_testOptions($inflector); diff --git a/tests/Zend/Filter/LocalizedToNormalizedTest.php b/tests/Zend/Filter/LocalizedToNormalizedTest.php index ec0f613..042e64a 100644 --- a/tests/Zend/Filter/LocalizedToNormalizedTest.php +++ b/tests/Zend/Filter/LocalizedToNormalizedTest.php @@ -38,7 +38,7 @@ class Zend_Filter_LocalizedToNormalizedTest extends PHPUnit\Framework\TestCase */ public function testNumberNormalization() { - $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de')); + $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de')); $valuesExpected = array( '0' => '0', '1.234' => '1234', @@ -60,7 +60,7 @@ public function testNumberNormalization() */ public function testDateNormalizationWithoutParameters() { - $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de')); + $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de')); $valuesExpected = array( '11:22:33' => array( 'date_format' => 'HH:mm:ss', @@ -80,13 +80,13 @@ public function testDateNormalizationWithoutParameters() 'day' => '20', 'month' => '4', 'year' => '2009'), - '20.04.09' => array( + '20.04.09' => array( 'date_format' => 'dd.MM.y', 'locale' => 'de', 'day' => '20', 'month' => '04', 'year' => '2009'), - '20.April.09' => array( + '20.April.09' => array( 'date_format' => 'dd.MM.y', 'locale' => 'de', 'day' => '20', @@ -106,7 +106,7 @@ public function testDateNormalizationWithoutParameters() */ public function testDateNormalizationWithParameters() { - $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de', 'date_format' => 'yyyy.dd.MM')); + $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de', 'date_format' => 'yyyy.dd.MM')); $valuesExpected = array( '2009.20.April' => array( 'date_format' => 'yyyy.dd.MM', @@ -120,13 +120,13 @@ public function testDateNormalizationWithParameters() 'day' => '20', 'month' => '04', 'year' => '2009'), - '09.20.04' => array( + '09.20.04' => array( 'date_format' => 'yyyy.dd.MM', 'locale' => 'de', 'day' => '20', 'month' => '04', 'year' => '2009'), - '09.20.April' => array( + '09.20.April' => array( 'date_format' => 'yyyy.dd.MM', 'locale' => 'de', 'day' => '20', @@ -146,7 +146,7 @@ public function testDateNormalizationWithParameters() */ public function testNormalizationToInteger() { - $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de', 'precision' => 0)); + $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de', 'precision' => 0)); $valuesExpected = array( '1.234,56' => '1234', '1,234' => '1', @@ -165,11 +165,11 @@ public function testNormalizationToInteger() */ public function testNormalizationToFloat() { - $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de', 'precision' => 2)); + $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de', 'precision' => 2)); $valuesExpected = array( '1.234,5678' => '1234.56', - '1,234' => '1.23', - '1.234' => '1234.00' + '1,234' => '1.23', + '1.234' => '1234.00' ); foreach ($valuesExpected as $input => $output) { @@ -188,9 +188,9 @@ public function testLongNumbers() $this->assertEquals(array( 'date_format' => 'dd.MM.y', - 'locale' => 'de', - 'day' => '1', - 'month' => '2', - 'year' => '4'), $filter->filter('1,2.4')); + 'locale' => 'de', + 'day' => '1', + 'month' => '2', + 'year' => '4'), $filter->filter('1,2.4')); } } diff --git a/tests/Zend/Filter/NormalizedToLocalizedTest.php b/tests/Zend/Filter/NormalizedToLocalizedTest.php index 7e2225c..82e5684 100644 --- a/tests/Zend/Filter/NormalizedToLocalizedTest.php +++ b/tests/Zend/Filter/NormalizedToLocalizedTest.php @@ -38,7 +38,7 @@ class Zend_Filter_NormalizedToLocalizedTest extends PHPUnit\Framework\TestCase */ public function testNumberLocalization() { - $filter = new Zend_Filter_NormalizedToLocalized(array('locale' => 'de')); + $filter = new Zend_Filter_NormalizedToLocalized(array('locale' => 'de')); $valuesExpected = array( 1 => '0', 2 => 0, @@ -79,45 +79,45 @@ public function testNumberLocalization() */ public function testDateLocalizationWithoutParameters() { - $filter = new Zend_Filter_NormalizedToLocalized(array('locale' => 'de', 'date_format' => 'HH:mm:ss')); + $filter = new Zend_Filter_NormalizedToLocalized(array('locale' => 'de', 'date_format' => 'HH:mm:ss')); $valuesExpected[1] = array( - 'hour' => '11', - 'minute' => '22', - 'second' => '33'); + 'hour' => '11', + 'minute' => '22', + 'second' => '33'); $valuesReceived[1] = '11:22:33'; foreach ($valuesExpected as $key => $value) { $this->assertEquals($valuesReceived[$key], $filter->filter($value), 'failed filter of ' . var_export($value, 1)); } - $filter = new Zend_Filter_NormalizedToLocalized(array('locale' => 'de', 'date_format' => 'dd.MM.yyyy')); + $filter = new Zend_Filter_NormalizedToLocalized(array('locale' => 'de', 'date_format' => 'dd.MM.yyyy')); $valuesExpected[1] = array( - 'date_format' => 'dd.MM.yyyy', - 'locale' => 'de', - 'day' => '20', - 'month' => '04', - 'year' => '2009'); + 'date_format' => 'dd.MM.yyyy', + 'locale' => 'de', + 'day' => '20', + 'month' => '04', + 'year' => '2009'); $valuesReceived[1] = '20.04.2009'; $valuesExpected[2] = array( - 'date_format' => null, - 'locale' => 'de', - 'day' => '20', - 'month' => '04', - 'year' => '2009'); + 'date_format' => null, + 'locale' => 'de', + 'day' => '20', + 'month' => '04', + 'year' => '2009'); $valuesReceived[2] = '20.04.2009'; $valuesExpected[3] = array( - 'date_format' => 'dd.MM.yyyy', - 'day' => '20', - 'month' => '04', - 'year' => '2009'); + 'date_format' => 'dd.MM.yyyy', + 'day' => '20', + 'month' => '04', + 'year' => '2009'); $valuesReceived[3] = '20.04.2009'; $valuesExpected[4] = array( - 'day' => '20', - 'month' => '04', - 'year' => '2009'); + 'day' => '20', + 'month' => '04', + 'year' => '2009'); $valuesReceived[4] = '20.04.2009'; foreach ($valuesExpected as $key => $value) { @@ -145,16 +145,16 @@ public function testDateLocalizationWithParameters() $valuesReceived[1] = '2009.20.04'; $valuesExpected[2] = array( - 'day' => '20', - 'month' => '04', - 'year' => '2009'); + 'day' => '20', + 'month' => '04', + 'year' => '2009'); $valuesReceived[2] = '2009.20.04'; $valuesExpected[3] = array( - 'locale' => 'de', - 'day' => '20', - 'month' => '04', - 'year' => '2009'); + 'locale' => 'de', + 'day' => '20', + 'month' => '04', + 'year' => '2009'); $valuesReceived[3] = '2009.20.04'; $valuesExpected[4] = array( @@ -176,7 +176,7 @@ public function testDateLocalizationWithParameters() */ public function testLocalizationToInteger() { - $filter = new Zend_Filter_NormalizedToLocalized(array('locale' => 'de', 'precision' => 0)); + $filter = new Zend_Filter_NormalizedToLocalized(array('locale' => 'de', 'precision' => 0)); $valuesExpected = array( 1 => '1234.56', 2 => 1234.56, diff --git a/tests/Zend/Filter/PregReplaceTest.php b/tests/Zend/Filter/PregReplaceTest.php index 7c17af0..a289e88 100644 --- a/tests/Zend/Filter/PregReplaceTest.php +++ b/tests/Zend/Filter/PregReplaceTest.php @@ -107,7 +107,7 @@ public function testFilterThrowsExceptionWhenNoMatchPatternPresent() public function testExtendsPregReplace() { $startMatchPattern = '~(>){3,}~i'; - $filter = new XPregReplace(); + $filter = new XPregReplace(); $this->assertEquals($startMatchPattern, $filter->getMatchPattern()); } } diff --git a/tests/Zend/Filter/RealPathTest.php b/tests/Zend/Filter/RealPathTest.php index b58535b..02ee395 100644 --- a/tests/Zend/Filter/RealPathTest.php +++ b/tests/Zend/Filter/RealPathTest.php @@ -53,7 +53,7 @@ class Zend_Filter_RealPathTest extends PHPUnit\Framework\TestCase public function setUp() { $this->_filesPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files'; - $this->_filter = new Zend_Filter_RealPath(); + $this->_filter = new Zend_Filter_RealPath(); } /** diff --git a/tests/Zend/Filter/StripNewlinesTest.php b/tests/Zend/Filter/StripNewlinesTest.php index 96fca95..218732c 100644 --- a/tests/Zend/Filter/StripNewlinesTest.php +++ b/tests/Zend/Filter/StripNewlinesTest.php @@ -43,7 +43,7 @@ class Zend_Filter_StripNewlinesTest extends PHPUnit\Framework\TestCase * * @return void */ - public function setUp () + public function setUp() { $this->_filter = new Zend_Filter_StripNewlines(); } @@ -53,16 +53,16 @@ public function setUp () * * @return void */ - public function testBasic () + public function testBasic() { $valuesExpected = array( - '' => '', - "\n" => '', - "\r" => '', - "\r\n" => '', - '\n' => '\n', - '\r' => '\r', - '\r\n' => '\r\n', + '' => '', + "\n" => '', + "\r" => '', + "\r\n" => '', + '\n' => '\n', + '\r' => '\r', + '\r\n' => '\r\n', "Some text\nthat we have\r\nstuff in" => 'Some textthat we havestuff in' ); foreach ($valuesExpected as $input => $output) { diff --git a/tests/Zend/Filter/StripTagsTest.php b/tests/Zend/Filter/StripTagsTest.php index 802318f..9a87560 100644 --- a/tests/Zend/Filter/StripTagsTest.php +++ b/tests/Zend/Filter/StripTagsTest.php @@ -415,7 +415,7 @@ public function testSpecifyingCommentsAllowedStripsCommentsContainingTags() public function testSpecifyingCommentsAllowedFiltersCommentsContainingTagsAndLinebreaks() { $input = "
test

text

with and "; - $expected = " test text with and "; + $expected = ' test text with and '; $this->_filter->setCommentsAllowed(true); $this->assertEquals($expected, $this->_filter->filter($input)); } @@ -505,9 +505,9 @@ public function testFilterIsoChars() $expected = 'äöüäöü'; $this->assertEquals($expected, $this->_filter->filter($input)); - $input = 'äöüäöü'; - $input = iconv("UTF-8", "ISO-8859-1", $input); - $output = $this->_filter->filter($input); + $input = 'äöüäöü'; + $input = iconv('UTF-8', 'ISO-8859-1', $input); + $output = $this->_filter->filter($input); $this->assertNotEmpty($output); } @@ -520,9 +520,9 @@ public function testFilterIsoCharsInComment() $expected = 'äöüäöü'; $this->assertEquals($expected, $this->_filter->filter($input)); - $input = 'äöüäöü'; - $input = iconv("UTF-8", "ISO-8859-1", $input); - $output = $this->_filter->filter($input); + $input = 'äöüäöü'; + $input = iconv('UTF-8', 'ISO-8859-1', $input); + $output = $this->_filter->filter($input); $this->assertNotEmpty($output); } @@ -551,7 +551,7 @@ public function testCommentWithTagInSameLine() */ public function testMultiParamArray() { - $filter = new Zend_Filter_StripTags(array("a","b","hr"),array(),true); + $filter = new Zend_Filter_StripTags(array('a','b','hr'), array(), true); $input = 'test test
div-content
'; $expected = 'test
test div-content'; @@ -565,7 +565,7 @@ public function testMultiQuoteInput() { $filter = new Zend_Filter_StripTags( array( - 'allowTags' => 'img', + 'allowTags' => 'img', 'allowAttribs' => array('width', 'height', 'src') ) ); @@ -590,8 +590,8 @@ public function testNotClosedHtmlCommentAtEndOfString() */ public function testFilterCanAllowHyphenatedAttributeNames() { - $input = '
  • '; - $expected = '
  • '; + $input = '
  • '; + $expected = '
  • '; $this->_filter->setTagsAllowed('li'); $this->_filter->setAttributesAllowed(array('data-id','data-name')); diff --git a/tests/Zend/Filter/Word/CamelCaseToUnderscoreTest.php b/tests/Zend/Filter/Word/CamelCaseToUnderscoreTest.php index d21bc27..94c2072 100644 --- a/tests/Zend/Filter/Word/CamelCaseToUnderscoreTest.php +++ b/tests/Zend/Filter/Word/CamelCaseToUnderscoreTest.php @@ -45,21 +45,21 @@ public function testFilterSeparatesCamelCasedWordsWithUnderscores() public function testFilterSeperatingNumbersToUnterscore() { - $string = 'PaTitle'; + $string = 'PaTitle'; $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $filtered = $filter->filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('Pa_Title', $filtered); - $string = 'Pa2Title'; + $string = 'Pa2Title'; $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $filtered = $filter->filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('Pa2_Title', $filtered); - $string = 'Pa2aTitle'; + $string = 'Pa2aTitle'; $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $filtered = $filter->filter($string); diff --git a/tests/Zend/Filter/Word/DashToSeparatorTest.php b/tests/Zend/Filter/Word/DashToSeparatorTest.php index ad40bd9..dfcf140 100644 --- a/tests/Zend/Filter/Word/DashToSeparatorTest.php +++ b/tests/Zend/Filter/Word/DashToSeparatorTest.php @@ -52,5 +52,4 @@ public function testFilterSeparatesDashedWordsWithSomeString() $this->assertNotEquals($string, $filtered); $this->assertEquals('dash:-:separated:-:words', $filtered); } - } diff --git a/tests/Zend/Filter/Word/SeparatorToDashTest.php b/tests/Zend/Filter/Word/SeparatorToDashTest.php index 306fe33..f7c0fa7 100644 --- a/tests/Zend/Filter/Word/SeparatorToDashTest.php +++ b/tests/Zend/Filter/Word/SeparatorToDashTest.php @@ -52,5 +52,4 @@ public function testFilterSeparatesDashedWordsWithSomeString() $this->assertNotEquals($string, $filtered); $this->assertEquals('dash-separated-words', $filtered); } - } diff --git a/tests/Zend/Filter/Word/SeparatorToSeparatorTest.php b/tests/Zend/Filter/Word/SeparatorToSeparatorTest.php index 8dedba4..e225242 100644 --- a/tests/Zend/Filter/Word/SeparatorToSeparatorTest.php +++ b/tests/Zend/Filter/Word/SeparatorToSeparatorTest.php @@ -62,5 +62,4 @@ public function testFilterSeparatesWordsWithSearchAndReplacementSpecified() $this->assertNotEquals($string, $filtered); $this->assertEquals('dash?separated?words', $filtered); } - } diff --git a/tests/Zend/Filter/Word/UnderscoreToCamelCaseTest.php b/tests/Zend/Filter/Word/UnderscoreToCamelCaseTest.php index b62fc5a..eacf03a 100644 --- a/tests/Zend/Filter/Word/UnderscoreToCamelCaseTest.php +++ b/tests/Zend/Filter/Word/UnderscoreToCamelCaseTest.php @@ -48,7 +48,7 @@ public function testFilterSeparatesCamelCasedWordsWithDashes() */ public function testSomeFilterValues() { - $filter = new Zend_Filter_Word_UnderscoreToCamelCase(); + $filter = new Zend_Filter_Word_UnderscoreToCamelCase(); $string = 'zend_framework'; $filtered = $filter->filter($string); diff --git a/tests/Zend/Filter/Word/UnderscoreToSeparatorTest.php b/tests/Zend/Filter/Word/UnderscoreToSeparatorTest.php index 906aea6..6da40c7 100644 --- a/tests/Zend/Filter/Word/UnderscoreToSeparatorTest.php +++ b/tests/Zend/Filter/Word/UnderscoreToSeparatorTest.php @@ -52,5 +52,4 @@ public function testFilterSeparatesCamelCasedWordsProvidedSeparator() $this->assertNotEquals($string, $filtered); $this->assertEquals('underscore:=:separated:=:words', $filtered); } - } diff --git a/tests/Zend/Filter/_files/TestNamespace/StringEquals.php b/tests/Zend/Filter/_files/TestNamespace/StringEquals.php index 2a06ef1..69eed97 100644 --- a/tests/Zend/Filter/_files/TestNamespace/StringEquals.php +++ b/tests/Zend/Filter/_files/TestNamespace/StringEquals.php @@ -32,7 +32,6 @@ */ class TestNamespace_StringEquals extends Zend_Validate_Abstract { - const NOT_EQUALS = 'stringNotEquals'; /** @@ -67,5 +66,4 @@ public function isValid($value) return true; } - } diff --git a/tests/Zend/FilterTest.php b/tests/Zend/FilterTest.php index 9bddb56..5467cf4 100644 --- a/tests/Zend/FilterTest.php +++ b/tests/Zend/FilterTest.php @@ -79,7 +79,7 @@ public function testFilterOrder() { $this->_filter->addFilter(new Zend_FilterTest_LowerCase()) ->addFilter(new Zend_FilterTest_StripUpperCase()); - $value = 'AbC'; + $value = 'AbC'; $valueExpected = 'abc'; $this->assertEquals($valueExpected, $this->_filter->filter($value)); } @@ -92,7 +92,7 @@ public function testFilterPrependOrder() { $this->_filter->appendFilter(new Zend_FilterTest_StripUpperCase()) ->prependFilter(new Zend_FilterTest_LowerCase()); - $value = 'AbC'; + $value = 'AbC'; $valueExpected = 'abc'; $this->assertEquals($valueExpected, $this->_filter->filter($value)); }