From a01a3a9678443928e7b3a1aa82d36e004dc2d3ee Mon Sep 17 00:00:00 2001 From: Alexander Wozniak Date: Fri, 6 Dec 2019 11:00:46 +0100 Subject: [PATCH 1/4] All tests pass on PHP 7.4 There were a bunch a minor changes needed like trimming slashes and octothorpes of strings before passing them into hexdec and removing all array accesses via curly braces. I have no idea how Zend_Crypt_Math::rand ever worked under unixlikes because we expect it to return a number but it outputs directly from /dev/urandom if it exists. Serialization of ReflectionMethods is also illegal since 7.4 A lot of docblocks were updated, assertions changed to more obvious ones and grimey things like dirname(__FILE__) were properly removed whenever I encountered them for most files that I touched. --- .../Zend/Amf/Parse/Amf0/Serializer.php | 27 +-- .../library/Zend/Amf/Util/BinaryStream.php | 16 +- .../library/Zend/Barcode/Object/Code25.php | 6 +- .../library/Zend/Barcode/Object/Ean13.php | 21 +-- .../library/Zend/Barcode/Object/Ean5.php | 5 +- .../library/Zend/Barcode/Object/Ean8.php | 7 +- .../library/Zend/Barcode/Object/Identcode.php | 5 +- .../Zend/Barcode/Object/ObjectAbstract.php | 10 +- .../library/Zend/Barcode/Object/Upca.php | 4 +- .../library/Zend/Barcode/Object/Upce.php | 15 +- .../Infrastructure/Adapter/Rackspace.php | 13 +- .../Zend/Cloud/Infrastructure/Instance.php | 6 +- .../zend-crypt/library/Zend/Crypt/Math.php | 17 +- .../Zend/File/Transfer/Adapter/Abstract.php | 99 ++++++---- .../Zend/File/Transfer/Adapter/Http.php | 39 ++-- .../library/Zend/Filter/Compress/Zip.php | 21 ++- .../zend-json/library/Zend/Json/Decoder.php | 39 ++-- .../zend-json/library/Zend/Json/Encoder.php | 45 ++--- .../zend-ldap/library/Zend/Ldap/Converter.php | 39 ++-- .../library/Zend/Locale/Format.php | 169 +++++++++--------- .../library/Zend/Measure/Abstract.php | 21 ++- .../zend-registry/library/Zend/Registry.php | 12 -- .../Zend/Service/Rackspace/Abstract.php | 6 +- .../Zend/Service/Rackspace/Servers/Server.php | 4 +- .../Context/Zf/ApplicationConfigFile.php | 14 +- .../library/Zend/Validate/Barcode/Upce.php | 2 +- .../library/Zend/Validate/Isbn.php | 12 +- .../Zend/View/Helper/Navigation/Sitemap.php | 23 ++- .../library/Zend/Wildfire/Plugin/FirePhp.php | 4 +- tests/Zend/Cache/AllTests.php | 1 + tests/Zend/Cache/CommonBackendTest.php | 4 +- .../Infrastructure/Adapter/RackspaceTest.php | 10 +- tests/Zend/CodeGenerator/Php/FileTest.php | 2 +- tests/Zend/Config/JsonTest.php | 32 +++- .../Action/Helper/AjaxContextTest.php | 8 +- tests/Zend/Crypt/MathTest.php | 4 +- tests/Zend/Feed/AbstractFeedTest.php | 6 +- .../File/Transfer/Adapter/AbstractTest.php | 22 +-- tests/Zend/Form/Element/FileTest.php | 43 ++--- tests/Zend/JsonTest.php | 54 +++--- tests/Zend/LoaderTest.php | 98 +++++----- tests/Zend/Paginator/_files/test.sqlite | Bin 10240 -> 10240 bytes tests/Zend/Queue/Adapter/AdapterTest.php | 2 +- tests/Zend/Server/Reflection/ClassTest.php | 11 +- tests/Zend/Server/Reflection/FunctionTest.php | 35 ++-- tests/Zend/Server/Reflection/MethodTest.php | 5 +- tests/Zend/Wildfire/WildfireTest.php | 22 +-- tests/bootstrap.php | 2 +- 48 files changed, 587 insertions(+), 475 deletions(-) diff --git a/packages/zend-amf/library/Zend/Amf/Parse/Amf0/Serializer.php b/packages/zend-amf/library/Zend/Amf/Parse/Amf0/Serializer.php index 873a531f8..83ac62474 100644 --- a/packages/zend-amf/library/Zend/Amf/Parse/Amf0/Serializer.php +++ b/packages/zend-amf/library/Zend/Amf/Parse/Amf0/Serializer.php @@ -187,9 +187,10 @@ public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false) * Check if the given object is in the reference table, write the reference if it exists, * otherwise add the object to the reference table * - * @param mixed $object object reference to check for reference + * @param mixed $object object reference to check for reference * @param string $markerType AMF type of the object to write - * @param mixed $objectByVal object to check for reference + * @param mixed $objectByVal object to check for reference + * @throws Zend_Amf_Exception * @return Boolean true, if the reference was written, false otherwise */ protected function writeObjectReference(&$object, $markerType, $objectByVal = false) @@ -221,7 +222,8 @@ protected function writeObjectReference(&$object, $markerType, $objectByVal = fa /** * Write a PHP array with string or mixed keys. * - * @param object $data + * @param $object + * @throws Zend_Amf_Exception * @return Zend_Amf_Parse_Amf0_Serializer */ public function writeObject($object) @@ -229,7 +231,7 @@ public function writeObject($object) // Loop each element and write the name of the property. foreach ($object as $key => &$value) { // skip variables starting with an _ private transient - if( $key[0] == "_") continue; + if(is_string($key) && strpos($key, '_') === 0) continue; $this->_stream->writeUTF($key); $this->writeTypeMarker($value); } @@ -245,12 +247,13 @@ public function writeObject($object) * is encountered call writeTypeMarker with mixed array. * * @param array $array + * @throws Zend_Amf_Exception * @return Zend_Amf_Parse_Amf0_Serializer */ public function writeArray(&$array) { $length = count($array); - if (!$length < 0) { + if ($length === 0) { // write the length of the array $this->_stream->writeLong(0); } else { @@ -267,7 +270,8 @@ public function writeArray(&$array) /** * Convert the DateTime into an AMF Date * - * @param DateTime|Zend_Date $data + * @param DateTime|Zend_Date $data + * @throws Zend_Amf_Exception * @return Zend_Amf_Parse_Amf0_Serializer */ public function writeDate($data) @@ -294,7 +298,8 @@ public function writeDate($data) /** * Write a class mapped object to the output stream. * - * @param object $data + * @param object $data + * @throws Zend_Amf_Exception * @return Zend_Amf_Parse_Amf0_Serializer */ public function writeTypedObject($data) @@ -308,7 +313,8 @@ public function writeTypedObject($data) * Encountered and AMF3 Type Marker use AMF3 serializer. Once AMF3 is * encountered it will not return to AMf0. * - * @param string $data + * @param string $data + * @throws Zend_Amf_Exception * @return Zend_Amf_Parse_Amf0_Serializer */ public function writeAmf3TypeMarker(&$data) @@ -330,7 +336,6 @@ protected function getClassName($object) { // require_once 'Zend/Amf/Parse/TypeLoader.php'; //Check to see if the object is a typed object and we need to change - $className = ''; switch (true) { // the return class mapped name back to actionscript class name. case Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object)): @@ -350,10 +355,10 @@ protected function getClassName($object) break; // By default, use object's class name default: - $className = get_class($object); + $className = get_class($object); break; } - if(!$className == '') { + if($className !== '') { return $className; } else { return false; diff --git a/packages/zend-amf/library/Zend/Amf/Util/BinaryStream.php b/packages/zend-amf/library/Zend/Amf/Util/BinaryStream.php index 08ba916bc..0a8f0d6dc 100644 --- a/packages/zend-amf/library/Zend/Amf/Util/BinaryStream.php +++ b/packages/zend-amf/library/Zend/Amf/Util/BinaryStream.php @@ -62,7 +62,8 @@ class Zend_Amf_Util_BinaryStream * by the methods in the class. Detect if the class should use big or * little Endian encoding. * - * @param string $stream use '' if creating a new stream or pass a string if reading. + * @param string $stream use '' if creating a new stream or pass a string if reading. + * @throws Zend_Amf_Exception * @return void */ public function __construct($stream) @@ -140,7 +141,7 @@ public function readByte() ); } - return ord($this->_stream{$this->_needle++}); + return ord($this->_stream[$this->_needle++]); } /** @@ -158,6 +159,7 @@ public function writeByte($stream) /** * Reads a signed 32-bit integer from the data stream. * + * @throws Zend_Amf_Exception * @return int Value is in the range of -2147483648 to 2147483647 */ public function readInt() @@ -180,6 +182,7 @@ public function writeInt($stream) /** * Reads a UTF-8 string from the data stream * + * @throws Zend_Amf_Exception * @return string A UTF-8 string produced by the byte representation of characters */ public function readUtf() @@ -205,6 +208,7 @@ public function writeUtf($stream) /** * Read a long UTF string * + * @throws Zend_Amf_Exception * @return string */ public function readLongUtf() @@ -216,8 +220,8 @@ public function readLongUtf() /** * Write a long UTF string to the buffer * - * @param string $stream - * @return Zend_Amf_Util_BinaryStream + * @param string $stream + * @return void */ public function writeLongUtf($stream) { @@ -228,6 +232,7 @@ public function writeLongUtf($stream) /** * Read a long numeric value * + * @throws Zend_Amf_Exception * @return double */ public function readLong() @@ -249,8 +254,9 @@ public function writeLong($stream) /** * Read a 16 bit unsigned short. - * * @todo This could use the unpack() w/ S,n, or v + * + * @throws Zend_Amf_Exception * @return double */ public function readUnsignedShort() diff --git a/packages/zend-barcode/library/Zend/Barcode/Object/Code25.php b/packages/zend-barcode/library/Zend/Barcode/Object/Code25.php index 07ec63a25..5c62044e8 100644 --- a/packages/zend-barcode/library/Zend/Barcode/Object/Code25.php +++ b/packages/zend-barcode/library/Zend/Barcode/Object/Code25.php @@ -76,6 +76,7 @@ protected function _calculateBarcodeWidth() /** * Partial check of interleaved 2 of 5 barcode + * @throws Zend_Barcode_Object_Exception * @return void */ protected function _checkParams() @@ -122,7 +123,8 @@ protected function _prepareBarcode() /** * Get barcode checksum * - * @param string $text + * @param string $text + * @throws Zend_Barcode_Object_Exception * @return int */ public function getChecksum($text) @@ -132,7 +134,7 @@ public function getChecksum($text) $checksum = 0; for ($i = strlen($text); $i > 0; $i --) { - $checksum += intval($text{$i - 1}) * $factor; + $checksum += (int)$text[$i - 1] * $factor; $factor = 4 - $factor; } diff --git a/packages/zend-barcode/library/Zend/Barcode/Object/Ean13.php b/packages/zend-barcode/library/Zend/Barcode/Object/Ean13.php index 26edaeb5a..d34063d6d 100644 --- a/packages/zend-barcode/library/Zend/Barcode/Object/Ean13.php +++ b/packages/zend-barcode/library/Zend/Barcode/Object/Ean13.php @@ -49,16 +49,16 @@ class Zend_Barcode_Object_Ean13 extends Zend_Barcode_Object_ObjectAbstract */ protected $_codingMap = array( 'A' => array( - 0 => "0001101", 1 => "0011001", 2 => "0010011", 3 => "0111101", 4 => "0100011", - 5 => "0110001", 6 => "0101111", 7 => "0111011", 8 => "0110111", 9 => "0001011" + 0 => '0001101', 1 => '0011001', 2 => '0010011', 3 => '0111101', 4 => '0100011', + 5 => '0110001', 6 => '0101111', 7 => '0111011', 8 => '0110111', 9 => '0001011' ), 'B' => array( - 0 => "0100111", 1 => "0110011", 2 => "0011011", 3 => "0100001", 4 => "0011101", - 5 => "0111001", 6 => "0000101", 7 => "0010001", 8 => "0001001", 9 => "0010111" + 0 => '0100111', 1 => '0110011', 2 => '0011011', 3 => '0100001', 4 => '0011101', + 5 => '0111001', 6 => '0000101', 7 => '0010001', 8 => '0001001', 9 => '0010111' ), 'C' => array( - 0 => "1110010", 1 => "1100110", 2 => "1101100", 3 => "1000010", 4 => "1011100", - 5 => "1001110", 6 => "1010000", 7 => "1000100", 8 => "1001000", 9 => "1110100" + 0 => '1110010', 1 => '1100110', 2 => '1101100', 3 => '1000010', 4 => '1011100', + 5 => '1001110', 6 => '1010000', 7 => '1000100', 8 => '1001000', 9 => '1110100' )); protected $_parities = array( @@ -156,7 +156,8 @@ protected function _prepareBarcode() /** * Get barcode checksum * - * @param string $text + * @param string $text + * @throws Zend_Barcode_Object_Exception * @return int */ public function getChecksum($text) @@ -166,7 +167,7 @@ public function getChecksum($text) $checksum = 0; for ($i = strlen($text); $i > 0; $i --) { - $checksum += intval($text{$i - 1}) * $factor; + $checksum += (int)$text[$i - 1] * $factor; $factor = 4 - $factor; } @@ -196,7 +197,7 @@ protected function _drawEan13Text() $leftPosition = $this->getQuietZone() - $characterWidth; for ($i = 0; $i < $this->_barcodeLength; $i ++) { $this->_addText( - $text{$i}, + $text[$i], $this->_fontSize * $this->_factor, $this->_rotate( $leftPosition, @@ -218,7 +219,7 @@ protected function _drawEan13Text() default: $factor = 0; } - $leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor); + $leftPosition += $characterWidth + ($factor * $this->_barThinWidth * $this->_factor); } } } diff --git a/packages/zend-barcode/library/Zend/Barcode/Object/Ean5.php b/packages/zend-barcode/library/Zend/Barcode/Object/Ean5.php index 51c19348f..44f39909a 100644 --- a/packages/zend-barcode/library/Zend/Barcode/Object/Ean5.php +++ b/packages/zend-barcode/library/Zend/Barcode/Object/Ean5.php @@ -115,7 +115,8 @@ protected function _prepareBarcode() /** * Get barcode checksum * - * @param string $text + * @param string $text + * @throws Zend_Barcode_Object_Exception * @return int */ public function getChecksum($text) @@ -124,7 +125,7 @@ public function getChecksum($text) $checksum = 0; for ($i = 0 ; $i < $this->_barcodeLength; $i ++) { - $checksum += intval($text{$i}) * ($i % 2 ? 9 : 3); + $checksum += (int)$text[$i] * (($i % 2) ? 9 : 3); } return ($checksum % 10); diff --git a/packages/zend-barcode/library/Zend/Barcode/Object/Ean8.php b/packages/zend-barcode/library/Zend/Barcode/Object/Ean8.php index 2ea41b0b4..4cd7fc53b 100644 --- a/packages/zend-barcode/library/Zend/Barcode/Object/Ean8.php +++ b/packages/zend-barcode/library/Zend/Barcode/Object/Ean8.php @@ -123,7 +123,7 @@ protected function _drawText() $leftPosition = $this->getQuietZone() + (3 * $this->_barThinWidth) * $this->_factor; for ($i = 0; $i < $this->_barcodeLength; $i ++) { $this->_addText( - $text{$i}, + $text[$i], $this->_fontSize * $this->_factor, $this->_rotate( $leftPosition, @@ -142,7 +142,7 @@ protected function _drawText() default: $factor = 0; } - $leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor); + $leftPosition += $characterWidth + ($factor * $this->_barThinWidth * $this->_factor); } } } @@ -152,8 +152,9 @@ protected function _drawText() * (to suppress checksum character substitution) * * @param string $value - * @param array $options + * @param array $options * @throws Zend_Barcode_Object_Exception + * @throws Zend_Validate_Exception */ protected function _validateText($value, $options = array()) { diff --git a/packages/zend-barcode/library/Zend/Barcode/Object/Identcode.php b/packages/zend-barcode/library/Zend/Barcode/Object/Identcode.php index 6826e1e32..046e8bef9 100644 --- a/packages/zend-barcode/library/Zend/Barcode/Object/Identcode.php +++ b/packages/zend-barcode/library/Zend/Barcode/Object/Identcode.php @@ -76,7 +76,8 @@ public function validateText($value) /** * Get barcode checksum * - * @param string $text + * @param string $text + * @throws Zend_Barcode_Object_Exception * @return int */ public function getChecksum($text) @@ -85,7 +86,7 @@ public function getChecksum($text) $checksum = 0; for ($i = strlen($text); $i > 0; $i --) { - $checksum += intval($text{$i - 1}) * (($i % 2) ? 4 : 9); + $checksum += (int)$text[$i - 1] * (($i % 2) ? 4 : 9); } $checksum = (10 - ($checksum % 10)) % 10; diff --git a/packages/zend-barcode/library/Zend/Barcode/Object/ObjectAbstract.php b/packages/zend-barcode/library/Zend/Barcode/Object/ObjectAbstract.php index 741539543..d8b9592c1 100644 --- a/packages/zend-barcode/library/Zend/Barcode/Object/ObjectAbstract.php +++ b/packages/zend-barcode/library/Zend/Barcode/Object/ObjectAbstract.php @@ -461,9 +461,9 @@ public function getFactor() public function setForeColor($value) { if (preg_match('`\#[0-9A-F]{6}`', $value)) { - $this->_foreColor = hexdec($value); + $this->_foreColor = hexdec(ltrim($value, '#')); } elseif (is_numeric($value) && $value >= 0 && $value <= 16777125) { - $this->_foreColor = intval($value); + $this->_foreColor = (int)$value; } else { // require_once 'Zend/Barcode/Object/Exception.php'; throw new Zend_Barcode_Object_Exception( @@ -493,9 +493,9 @@ public function getForeColor() public function setBackgroundColor($value) { if (preg_match('`\#[0-9A-F]{6}`', $value)) { - $this->_backgroundColor = hexdec($value); + $this->_backgroundColor = hexdec(ltrim($value, '#')); } elseif (is_numeric($value) && $value >= 0 && $value <= 16777125) { - $this->_backgroundColor = intval($value); + $this->_backgroundColor = (int)$value; } else { // require_once 'Zend/Barcode/Object/Exception.php'; throw new Zend_Barcode_Object_Exception( @@ -1322,7 +1322,7 @@ protected function _drawText() for ($i = 0; $i < $textLength; $i ++) { $leftPosition = $this->getQuietZone() + $space * ($i + 0.5); $this->_addText( - $text{$i}, + $text[$i], $this->_fontSize * $this->_factor, $this->_rotate( $leftPosition, diff --git a/packages/zend-barcode/library/Zend/Barcode/Object/Upca.php b/packages/zend-barcode/library/Zend/Barcode/Object/Upca.php index eb69cd0f8..4304b6ede 100644 --- a/packages/zend-barcode/library/Zend/Barcode/Object/Upca.php +++ b/packages/zend-barcode/library/Zend/Barcode/Object/Upca.php @@ -140,7 +140,7 @@ protected function _drawText() $fontSize *= 0.8; } $this->_addText( - $text{$i}, + $text[$i], $fontSize * $this->_factor, $this->_rotate( $leftPosition, @@ -165,7 +165,7 @@ protected function _drawText() default: $factor = 0; } - $leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor); + $leftPosition += $characterWidth + ($factor * $this->_barThinWidth * $this->_factor); } } } diff --git a/packages/zend-barcode/library/Zend/Barcode/Object/Upce.php b/packages/zend-barcode/library/Zend/Barcode/Object/Upce.php index f6468e451..0f04f7024 100644 --- a/packages/zend-barcode/library/Zend/Barcode/Object/Upce.php +++ b/packages/zend-barcode/library/Zend/Barcode/Object/Upce.php @@ -84,8 +84,8 @@ protected function _getDefaultOptions() public function getText() { $text = parent::getText(); - if ($text{0} != 1) { - $text{0} = 0; + if ($text[0] != 1) { + $text[0] = 0; } return $text; } @@ -158,7 +158,7 @@ protected function _drawText() $fontSize *= 0.8; } $this->_addText( - $text{$i}, + $text[$i], $fontSize * $this->_factor, $this->_rotate( $leftPosition, @@ -180,7 +180,7 @@ protected function _drawText() default: $factor = 0; } - $leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor); + $leftPosition += $characterWidth + ($factor * $this->_barThinWidth * $this->_factor); } } } @@ -190,8 +190,9 @@ protected function _drawText() * (to suppress checksum character substitution) * * @param string $value - * @param array $options + * @param array $options * @throws Zend_Barcode_Object_Exception + * @throws Zend_Validate_Exception */ protected function _validateText($value, $options = array()) { @@ -222,8 +223,8 @@ protected function _validateText($value, $options = array()) public function getChecksum($text) { $text = $this->_addLeadingZeros($text, true); - if ($text{0} != 1) { - $text{0} = 0; + if ($text[0] != 1) { + $text[0] = 0; } return parent::getChecksum($text); } diff --git a/packages/zend-cloud/library/Zend/Cloud/Infrastructure/Adapter/Rackspace.php b/packages/zend-cloud/library/Zend/Cloud/Infrastructure/Adapter/Rackspace.php index 687bfc6c4..ec1e19882 100644 --- a/packages/zend-cloud/library/Zend/Cloud/Infrastructure/Adapter/Rackspace.php +++ b/packages/zend-cloud/library/Zend/Cloud/Infrastructure/Adapter/Rackspace.php @@ -124,7 +124,7 @@ public function __construct($options = array()) if (isset($options[self::RACKSPACE_REGION])) { switch ($options[self::RACKSPACE_REGION]) { case self::RACKSPACE_ZONE_UK: - $this->region= Zend_Service_Rackspace_Servers::UK_AUTH_URL; + $this->region = Zend_Service_Rackspace_Servers::UK_AUTH_URL; break; case self::RACKSPACE_ZONE_USA: $this->region = Zend_Service_Rackspace_Servers::US_AUTH_URL; @@ -168,8 +168,8 @@ protected function convertAttributes($attr) } else { $result[Zend_Cloud_Infrastructure_Instance::INSTANCE_ZONE] = self::RACKSPACE_ZONE_UK; } - $result[Zend_Cloud_Infrastructure_Instance::INSTANCE_RAM] = $this->flavors[$attr['flavorId']]['ram']; - $result[Zend_Cloud_Infrastructure_Instance::INSTANCE_STORAGE] = $this->flavors[$attr['flavorId']]['disk']; + $result[Zend_Cloud_Infrastructure_Instance::INSTANCE_RAM] = isset($this->flavors[$attr['flavorId']]['ram']) ? $this->flavors[$attr['flavorId']]['ram'] : null; + $result[Zend_Cloud_Infrastructure_Instance::INSTANCE_STORAGE] = isset($this->flavors[$attr['flavorId']]['disk']) ? $this->flavors[$attr['flavorId']]['disk'] : null; } return $result; } @@ -230,13 +230,16 @@ public function rebootInstance($id) { return $this->rackspace->rebootServer($id,true); } + /** * Create a new instance * * @param string $name * @param array $options + * @throws Zend_Cloud_Infrastructure_Exception + * @throws Zend_Service_Rackspace_Exception * @return Instance|boolean - */ + */ public function createInstance($name, $options) { if (empty($name)) { @@ -260,7 +263,7 @@ public function createInstance($name, $options) } $options['name']= $name; $this->adapterResult = $this->rackspace->createServer($options,$metadata,$files); - if ($this->adapterResult===false) { + if ($this->adapterResult === false) { return false; } return new Zend_Cloud_Infrastructure_Instance($this, $this->convertAttributes($this->adapterResult->toArray())); diff --git a/packages/zend-cloud/library/Zend/Cloud/Infrastructure/Instance.php b/packages/zend-cloud/library/Zend/Cloud/Infrastructure/Instance.php index 8ce8f31c4..b1a4a01c1 100644 --- a/packages/zend-cloud/library/Zend/Cloud/Infrastructure/Instance.php +++ b/packages/zend-cloud/library/Zend/Cloud/Infrastructure/Instance.php @@ -84,7 +84,7 @@ public function __construct($adapter, $data = null) { if (!($adapter instanceof Zend_Cloud_Infrastructure_Adapter)) { // require_once 'Zend/Cloud/Infrastructure/Exception.php'; - throw new Zend_Cloud_Infrastructure_Exception("You must pass a Zend_Cloud_Infrastructure_Adapter instance"); + throw new Zend_Cloud_Infrastructure_Exception('You must pass a Zend_Cloud_Infrastructure_Adapter instance'); } if (is_object($data)) { @@ -97,7 +97,7 @@ public function __construct($adapter, $data = null) if (empty($data) || !is_array($data)) { // require_once 'Zend/Cloud/Infrastructure/Exception.php'; - throw new Zend_Cloud_Infrastructure_Exception("You must pass an array of parameters"); + throw new Zend_Cloud_Infrastructure_Exception('You must pass an array of parameters'); } foreach ($this->attributeRequired as $key) { @@ -118,7 +118,7 @@ public function __construct($adapter, $data = null) /** * Get Attribute with a specific key * - * @param array $data + * @param string $key * @return misc|false */ public function getAttribute($key) diff --git a/packages/zend-crypt/library/Zend/Crypt/Math.php b/packages/zend-crypt/library/Zend/Crypt/Math.php index cda7ae53d..8717c959a 100644 --- a/packages/zend-crypt/library/Zend/Crypt/Math.php +++ b/packages/zend-crypt/library/Zend/Crypt/Math.php @@ -49,7 +49,8 @@ public function rand($minimum, $maximum) if (file_exists('/dev/urandom')) { $frandom = fopen('/dev/urandom', 'r'); if ($frandom !== false) { - return fread($frandom, strlen($maximum) - 1); + # I don't know how this could've ever worked if you're expecting an integer output + #return fread($frandom, strlen($maximum) - 1); } } if (strlen($maximum) < 4) { @@ -67,8 +68,9 @@ public function rand($minimum, $maximum) /** * Return a random strings of $length bytes * - * @param integer $length - * @param boolean $strong + * @param integer $length + * @param boolean $strong + * @throws Zend_Crypt_Exception * @return string */ public static function randBytes($length, $strong = false) @@ -109,9 +111,10 @@ public static function randBytes($length, $strong = false) /** * Return a random integer between $min and $max * - * @param integer $min - * @param integer $max - * @param boolean $strong + * @param integer $min + * @param integer $max + * @param boolean $strong + * @throws Zend_Crypt_Exception * @return integer */ public static function randInteger($min, $max, $strong = false) @@ -123,7 +126,7 @@ public static function randInteger($min, $max, $strong = false) ); } $range = $max - $min; - if ($range == 0) { + if ($range === 0) { return $max; } elseif ($range > PHP_INT_MAX || is_float($range)) { // require_once 'Zend/Crypt/Exception.php'; diff --git a/packages/zend-file-transfer/library/Zend/File/Transfer/Adapter/Abstract.php b/packages/zend-file-transfer/library/Zend/File/Transfer/Adapter/Abstract.php index be60da6e6..d6cd5ea90 100644 --- a/packages/zend-file-transfer/library/Zend/File/Transfer/Adapter/Abstract.php +++ b/packages/zend-file-transfer/library/Zend/File/Transfer/Adapter/Abstract.php @@ -247,11 +247,12 @@ public function getPluginLoader($type) * * Otherwise, the path prefix is set on the appropriate plugin loader. * - * @param string $prefix - * @param string $path - * @param string $type - * @return Zend_File_Transfer_Adapter_Abstract + * @param string $prefix + * @param string $path + * @param string $type * @throws Zend_File_Transfer_Exception for invalid type + * @throws Zend_Loader_PluginLoader_Exception + * @return Zend_File_Transfer_Adapter_Abstract */ public function addPrefixPath($prefix, $path, $type = null) { @@ -282,8 +283,10 @@ public function addPrefixPath($prefix, $path, $type = null) /** * Add many prefix paths at once * - * @param array $spec - * @return Zend_File_Transfer_Exception + * @param array $spec + * @throws Zend_File_Transfer_Exception + * @throws Zend_Loader_PluginLoader_Exception + * @return Zend_File_Transfer_Adapter_Abstract */ public function addPrefixPaths(array $spec) { @@ -324,11 +327,13 @@ public function addPrefixPaths(array $spec) /** * Adds a new validator for this class * - * @param string|array $validator Type of validator to add - * @param boolean $breakChainOnFailure If the validation chain should stop an failure - * @param string|array $options Options to set for the validator - * @param string|array $files Files to limit this validator to - * @return Zend_File_Transfer_Adapter + * @param string|array $validator Type of validator to add + * @param boolean $breakChainOnFailure If the validation chain should stop an failure + * @param string|array $options Options to set for the validator + * @param string|array $files Files to limit this validator to + * @throws Zend_File_Transfer_Exception + * @throws Zend_Loader_Exception + * @return Zend_File_Transfer_Adapter_Abstract */ public function addValidator($validator, $breakChainOnFailure = false, $options = null, $files = null) { @@ -372,8 +377,10 @@ public function addValidator($validator, $breakChainOnFailure = false, $options /** * Add Multiple validators at once * - * @param array $validators - * @param string|array $files + * @param array $validators + * @param string|array $files + * @throws Zend_File_Transfer_Exception + * @throws Zend_Loader_Exception * @return Zend_File_Transfer_Adapter_Abstract */ public function addValidators(array $validators, $files = null) @@ -440,9 +447,11 @@ public function addValidators(array $validators, $files = null) /** * Sets a validator for the class, erasing all previous set * - * @param string|array $validator Validator to set - * @param string|array $files Files to limit this validator to - * @return Zend_File_Transfer_Adapter + * @param array $validators + * @param string|array $files Files to limit this validator to + * @throws Zend_File_Transfer_Exception + * @throws Zend_Loader_Exception + * @return Zend_File_Transfer_Adapter_Abstract */ public function setValidators(array $validators, $files = null) { @@ -478,7 +487,8 @@ public function getValidator($name) /** * Returns all set validators * - * @param string|array $files (Optional) Returns the validator for this files + * @param string|array $files (Optional) Returns the validator for this files + * @throws Zend_File_Transfer_Exception * @return null|array List of set validators */ public function getValidators($files = null) @@ -554,7 +564,8 @@ public function clearValidators() * Sets Options for adapters * * @param array $options Options to set - * @param array $files (Optional) Files to set the options for + * @param array $files (Optional) Files to set the options for + * @throws Zend_File_Transfer_Exception * @return Zend_File_Transfer_Adapter_Abstract */ public function setOptions($options = array(), $files = null) { @@ -592,7 +603,8 @@ public function setOptions($options = array(), $files = null) { /** * Returns set options for adapters or files * - * @param array $files (Optional) Files to return the options for + * @param array $files (Optional) Files to return the options for + * @throws Zend_File_Transfer_Exception * @return array Options for given files */ public function getOptions($files = null) { @@ -612,7 +624,8 @@ public function getOptions($files = null) { /** * Checks if the files are valid * - * @param string|array $files (Optional) Files to check + * @param string|array $files (Optional) Files to check + * @throws Zend_File_Transfer_Exception * @return boolean True if all checks are valid */ public function isValid($files = null) @@ -742,10 +755,12 @@ public function hasErrors() /** * Adds a new filter for this class * - * @param string|array $filter Type of filter to add - * @param string|array $options Options to set for the filter - * @param string|array $files Files to limit this filter to - * @return Zend_File_Transfer_Adapter + * @param string|array $filter Type of filter to add + * @param string|array $options Options to set for the filter + * @param string|array $files Files to limit this filter to + * @throws Zend_File_Transfer_Exception + * @throws Zend_Loader_Exception + * @return Zend_File_Transfer_Adapter_Abstract */ public function addFilter($filter, $options = null, $files = null) { @@ -771,8 +786,10 @@ public function addFilter($filter, $options = null, $files = null) /** * Add Multiple filters at once * - * @param array $filters - * @param string|array $files + * @param array $filters + * @param string|array $files + * @throws Zend_File_Transfer_Exception + * @throws Zend_Loader_Exception * @return Zend_File_Transfer_Adapter_Abstract */ public function addFilters(array $filters, $files = null) @@ -815,9 +832,11 @@ public function addFilters(array $filters, $files = null) /** * Sets a filter for the class, erasing all previous set * - * @param string|array $filter Filter to set - * @param string|array $files Files to limit this filter to - * @return Zend_File_Transfer_Adapter + * @param array $filters + * @param string|array $files Files to limit this filter to + * @throws Zend_File_Transfer_Exception + * @throws Zend_Loader_Exception + * @return Zend_File_Transfer_Adapter_Abstract */ public function setFilters(array $filters, $files = null) { @@ -937,8 +956,9 @@ public function getFile() /** * Retrieves the filename of transferred files. * - * @param string|null $file - * @param boolean $path (Optional) Should the path also be returned ? + * @param string|null $file + * @param boolean $path (Optional) Should the path also be returned ? + * @throws Zend_File_Transfer_Exception * @return string|array */ public function getFileName($file = null, $path = true) @@ -968,7 +988,8 @@ public function getFileName($file = null, $path = true) /** * Retrieve additional internal file informations for files * - * @param string $file (Optional) File to get informations for + * @param string $file (Optional) File to get informations for + * @throws Zend_File_Transfer_Exception * @return array */ public function getFileInfo($file = null) @@ -1022,10 +1043,10 @@ public function addType($type, $validator = null, $filter = null) * Sets a new destination for the given files * * @deprecated Will be changed to be a filter!!! - * @param string $destination New destination directory - * @param string|array $files Files to set the new destination for - * @return Zend_File_Transfer_Abstract + * @param string $destination New destination directory + * @param string|array $files Files to set the new destination for * @throws Zend_File_Transfer_Exception when the given destination is not a directory or does not exist + * @return Zend_File_Transfer_Adapter_Abstract */ public function setDestination($destination, $files = null) { @@ -1106,9 +1127,9 @@ public function getDestination($files = null) /** * Set translator object for localization * - * @param Zend_Translate|null $translator - * @return Zend_File_Transfer_Abstract + * @param Zend_Translate|null $translator * @throws Zend_File_Transfer_Exception + * @return Zend_File_Transfer_Adapter_Abstract */ public function setTranslator($translator = null) { @@ -1143,8 +1164,8 @@ public function getTranslator() /** * Indicate whether or not translation should be disabled * - * @param bool $flag - * @return Zend_File_Transfer_Abstract + * @param bool $flag + * @return Zend_File_Transfer_Adapter_Abstract */ public function setDisableTranslator($flag) { diff --git a/packages/zend-file-transfer/library/Zend/File/Transfer/Adapter/Http.php b/packages/zend-file-transfer/library/Zend/File/Transfer/Adapter/Http.php index fd43d2918..2d9bbda12 100644 --- a/packages/zend-file-transfer/library/Zend/File/Transfer/Adapter/Http.php +++ b/packages/zend-file-transfer/library/Zend/File/Transfer/Adapter/Http.php @@ -40,6 +40,8 @@ class Zend_File_Transfer_Adapter_Http extends Zend_File_Transfer_Adapter_Abstrac /** * Constructor for Http File Transfers * + * @throws Zend_File_Transfer_Exception + * @throws Zend_Loader_Exception * @param array $options OPTIONAL Options to set */ public function __construct($options = array()) @@ -57,9 +59,11 @@ public function __construct($options = array()) /** * Sets a validator for the class, erasing all previous set * - * @param string|array $validator Validator to set - * @param string|array $files Files to limit this validator to - * @return Zend_File_Transfer_Adapter + * @param array $validators + * @param string|array $files Files to limit this validator to + * @throws Zend_File_Transfer_Exception + * @throws Zend_Loader_Exception + * @return Zend_File_Transfer_Adapter_Abstract */ public function setValidators(array $validators, $files = null) { @@ -85,7 +89,8 @@ public function removeValidator($name) /** * Remove an individual validator * - * @param string $name + * @throws Zend_File_Transfer_Exception + * @throws Zend_Loader_Exception * @return Zend_File_Transfer_Adapter_Abstract */ public function clearValidators() @@ -112,7 +117,8 @@ public function send($options = null) /** * Checks if the files are valid * - * @param string|array $files (Optional) Files to check + * @param string|array $files (Optional) Files to check + * @throws Zend_File_Transfer_Exception * @return boolean True if all checks are valid */ public function isValid($files = null) @@ -151,7 +157,8 @@ public function isValid($files = null) /** * Receive the file from the client (Upload) * - * @param string|array $files (Optional) Files to receive + * @param string|array $files (Optional) Files to receive + * @throws Zend_File_Transfer_Exception * @return bool */ public function receive($files = null) @@ -222,9 +229,9 @@ public function receive($files = null) /** * Checks if the file was already sent * - * @param string|array $file Files to check - * @return bool + * @param string|array $files Files to check * @throws Zend_File_Transfer_Exception Not implemented + * @return bool */ public function isSent($files = null) { @@ -235,7 +242,8 @@ public function isSent($files = null) /** * Checks if the file was already received * - * @param string|array $files (Optional) Files to check + * @param string|array $files (Optional) Files to check + * @throws Zend_File_Transfer_Exception * @return bool */ public function isReceived($files = null) @@ -257,7 +265,8 @@ public function isReceived($files = null) /** * Checks if the file was already filtered * - * @param string|array $files (Optional) Files to check + * @param string|array $files (Optional) Files to check + * @throws Zend_File_Transfer_Exception * @return bool */ public function isFiltered($files = null) @@ -279,7 +288,8 @@ public function isFiltered($files = null) /** * Has a file been uploaded ? * - * @param array|string|null $file + * @param array|string|null $files + * @throws Zend_File_Transfer_Exception * @return bool */ public function isUploaded($files = null) @@ -301,7 +311,9 @@ public function isUploaded($files = null) /** * Returns the actual progress of file up-/downloads * - * @param string $id The upload to get the progress for + * @param string $id The upload to get the progress for + * @throws Zend_File_Transfer_Exception + * @throws Zend_ProgressBar_Exception * @return array|null */ public static function getProgress($id = null) @@ -429,8 +441,7 @@ public static function isUploadProgressAvailable() /** * Prepare the $_FILES array to match the internal syntax of one file per entry * - * @param array $files - * @return array + * @return Zend_File_Transfer_Adapter_Http */ protected function _prepareFiles() { diff --git a/packages/zend-filter/library/Zend/Filter/Compress/Zip.php b/packages/zend-filter/library/Zend/Filter/Compress/Zip.php index 470548d4d..8ac940fea 100644 --- a/packages/zend-filter/library/Zend/Filter/Compress/Zip.php +++ b/packages/zend-filter/library/Zend/Filter/Compress/Zip.php @@ -52,6 +52,7 @@ class Zend_Filter_Compress_Zip extends Zend_Filter_Compress_CompressAbstract /** * Class constructor * + * @throws Zend_Filter_Exception * @param string|array $options (Optional) Options to set */ public function __construct($options = null) @@ -77,7 +78,7 @@ public function getArchive() * Sets the archive to use for de-/compression * * @param string $archive Archive to use - * @return Zend_Filter_Compress_Rar + * @return Zend_Filter_Compress_Zip */ public function setArchive($archive) { @@ -101,7 +102,8 @@ public function getTarget() * Sets the target to use * * @param string $target - * @return Zend_Filter_Compress_Rar + * @throws Zend_Filter_Exception + * @return Zend_Filter_Compress_Zip */ public function setTarget($target) { @@ -118,7 +120,8 @@ public function setTarget($target) /** * Compresses the given content * - * @param string $content + * @param string $content + * @throws Zend_Filter_Exception * @return string Compressed archive */ public function compress($content) @@ -180,7 +183,7 @@ public function compress($content) if (!is_dir($file)) { $file = basename($file); } else { - $file = "zip.tmp"; + $file = 'zip.tmp'; } $res = $zip->addFromString($file, $content); @@ -197,7 +200,8 @@ public function compress($content) /** * Decompresses the given content * - * @param string $content + * @param string $content + * @throws Zend_Filter_Exception * @return string */ public function decompress($content) @@ -237,9 +241,9 @@ public function decompress($content) for ($i = 0; $i < $zip->numFiles; $i++) { $statIndex = $zip->statIndex($i); $currName = $statIndex['name']; - if (($currName{0} == '/') || - (substr($currName, 0, 2) == '..') || - (substr($currName, 0, 4) == './..') + if (($currName[0] == '/') || + (strpos($currName, '..') === 0) || + (strpos($currName, './..') === 0) ) { // require_once 'Zend/Filter/Exception.php'; @@ -265,6 +269,7 @@ public function decompress($content) * Returns the proper string based on the given error constant * * @param string $error + * @return string */ protected function _errorString($error) { diff --git a/packages/zend-json/library/Zend/Json/Decoder.php b/packages/zend-json/library/Zend/Json/Decoder.php index 2c5d02896..77261c371 100644 --- a/packages/zend-json/library/Zend/Json/Decoder.php +++ b/packages/zend-json/library/Zend/Json/Decoder.php @@ -92,6 +92,7 @@ class Zend_Json_Decoder * @param int $decodeType How objects should be decoded -- see * {@link Zend_Json::TYPE_ARRAY} and {@link Zend_Json::TYPE_OBJECT} for * valid values + * @throws Zend_Json_Exception * @return void */ protected function __construct($source, $decodeType) @@ -160,6 +161,7 @@ public static function decode($source = null, $objectDecodeType = Zend_Json::TYP /** * Recursive driving rountine for supported toplevel tops * + * @throws Zend_Json_Exception * @return mixed */ protected function _decodeValue() @@ -194,6 +196,7 @@ protected function _decodeValue() * {@link $_decodeType}. If invalid $_decodeType present, returns as an * array. * + * @throws Zend_Json_Exception * @return array|StdClass */ protected function _decodeObject() @@ -256,12 +259,13 @@ protected function _decodeObject() * Decodes a JSON array format: * [element, element2,...,elementN] * + * @throws Zend_Json_Exception * @return array */ protected function _decodeArray() { $result = array(); - $starttok = $tok = $this->_getNextToken(); // Move past the '[' + $tok = $this->_getNextToken(); // Move past the '[' $index = 0; while ($tok && $tok != self::RBRACKET) { @@ -287,7 +291,7 @@ protected function _decodeArray() /** - * Removes whitepsace characters from the source input + * Removes whitespace characters from the source input */ protected function _eatWhitespace() { @@ -307,6 +311,7 @@ protected function _eatWhitespace() /** * Retrieves the next token from the source stream * + * @throws Zend_Json_Exception * @return int Token constant value specified in class definition */ protected function _getNextToken() @@ -324,7 +329,7 @@ protected function _getNextToken() $i = $this->_offset; $start = $i; - switch ($str{$i}) { + switch ($str[$i]) { case '{': $this->_token = self::LBRACE; break; @@ -351,14 +356,14 @@ protected function _getNextToken() break; } - $chr = $str{$i}; + $chr = $str[$i]; if ($chr == '\\') { $i++; if ($i >= $str_length) { break; } - $chr = $str{$i}; + $chr = $str[$i]; switch ($chr) { case '"' : $result .= '"'; @@ -389,7 +394,7 @@ protected function _getNextToken() break; default: // require_once 'Zend/Json/Exception.php'; - throw new Zend_Json_Exception("Illegal escape " + throw new Zend_Json_Exception('Illegal escape ' . "sequence '" . $chr . "'"); } } elseif($chr == '"') { @@ -404,21 +409,21 @@ protected function _getNextToken() $this->_tokenValue = $result; break; case 't': - if (($i+ 3) < $str_length && substr($str, $start, 4) == "true") { + if (($i+ 3) < $str_length && substr($str, $start, 4) === "true") { $this->_token = self::DATUM; } $this->_tokenValue = true; $i += 3; break; case 'f': - if (($i+ 4) < $str_length && substr($str, $start, 5) == "false") { + if (($i+ 4) < $str_length && substr($str, $start, 5) === "false") { $this->_token = self::DATUM; } $this->_tokenValue = false; $i += 4; break; case 'n': - if (($i+ 3) < $str_length && substr($str, $start, 4) == "null") { + if (($i+ 3) < $str_length && substr($str, $start, 4) === "null") { $this->_token = self::DATUM; } $this->_tokenValue = NULL; @@ -431,7 +436,7 @@ protected function _getNextToken() return($this->_token); } - $chr = $str{$i}; + $chr = $str[$i]; if ($chr == '-' || $chr == '.' || ($chr >= '0' && $chr <= '9')) { if (preg_match('/-?([0-9])*(\.[0-9]*)?((e|E)((-|\+)?)[0-9]+)?/s', $str, $matches, PREG_OFFSET_CAPTURE, $start) && $matches[0][1] == $start) { @@ -443,8 +448,8 @@ protected function _getNextToken() // require_once 'Zend/Json/Exception.php'; throw new Zend_Json_Exception("Octal notation not supported by JSON (value: $datum)"); } else { - $val = intval($datum); - $fVal = floatval($datum); + $val = (int)$datum; + $fVal = (float)$datum; $this->_tokenValue = ($val == $fVal ? $val : $fVal); } } else { @@ -471,18 +476,16 @@ protected function _getNextToken() * * @link http://solarphp.com/ * @link http://svn.solarphp.com/core/trunk/Solar/Json.php - * @param string $value + * @param string $chrs * @return string */ public static function decodeUnicodeString($chrs) { - $delim = substr($chrs, 0, 1); $utf8 = ''; $strlen_chrs = strlen($chrs); for($i = 0; $i < $strlen_chrs; $i++) { - $substr_chrs_c_2 = substr($chrs, $i, 2); $ord_chrs_c = ord($chrs[$i]); switch (true) { @@ -494,7 +497,7 @@ public static function decodeUnicodeString($chrs) $i += 5; break; case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): - $utf8 .= $chrs{$i}; + $utf8 .= $chrs[$i]; break; case ($ord_chrs_c & 0xE0) == 0xC0: // characters U-00000080 - U-000007FF, mask 110XXXXX @@ -537,7 +540,7 @@ public static function decodeUnicodeString($chrs) * * Normally should be handled by mb_convert_encoding, but * provides a slower PHP-only method for installations - * that lack the multibye string extension. + * that lack the multibyte string extension. * * This method is from the Solar Framework by Paul M. Jones * @@ -552,7 +555,7 @@ protected static function _utf162utf8($utf16) return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); } - $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); + $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]); switch (true) { case ((0x7F & $bytes) == $bytes): diff --git a/packages/zend-json/library/Zend/Json/Encoder.php b/packages/zend-json/library/Zend/Json/Encoder.php index f3abec90a..451f94617 100644 --- a/packages/zend-json/library/Zend/Json/Encoder.php +++ b/packages/zend-json/library/Zend/Json/Encoder.php @@ -85,6 +85,7 @@ public static function encode($value, $cycleCheck = false, $options = array()) * - basic datums (e.g. numbers or strings) (returns from {@link _encodeDatum()}) * * @param mixed $value The value to be encoded + * @throws Zend_Json_Exception * @return string Encoded value */ protected function _encodeValue(&$value) @@ -187,6 +188,7 @@ protected function _wasVisited(&$value) * considered an associative array, and will be encoded as such. * * @param array& $array + * @throws Zend_Json_Exception * @return string */ protected function _encodeArray(&$array) @@ -235,7 +237,7 @@ protected function _encodeDatum(&$value) if (is_int($value) || is_float($value)) { $result = (string) $value; - $result = str_replace(",", ".", $result); + $result = str_replace(',', '.', $result); } elseif (is_string($value)) { $result = $this->_encodeString($value); } elseif (is_bool($value)) { @@ -249,7 +251,7 @@ protected function _encodeDatum(&$value) /** * JSON encode a string value by escaping characters as necessary * - * @param string& $value + * @param $string * @return string */ protected function _encodeString(&$string) @@ -279,7 +281,7 @@ protected function _encodeString(&$string) */ private static function _encodeConstants(ReflectionClass $cls) { - $result = "constants : {"; + $result = 'constants : {'; $constants = $cls->getConstants(); $tmpArray = array(); @@ -291,7 +293,7 @@ private static function _encodeConstants(ReflectionClass $cls) $result .= implode(', ', $tmpArray); } - return $result . "}"; + return $result . '}'; } @@ -326,7 +328,7 @@ private static function _encodeMethods(ReflectionClass $cls) $paramCount = count($parameters); $argsStarted = false; - $argNames = "var argNames=["; + $argNames = 'var argNames=['; foreach ($parameters as $param) { if ($argsStarted) { $result .= ','; @@ -342,20 +344,20 @@ private static function _encodeMethods(ReflectionClass $cls) $argsStarted = true; } - $argNames .= "];"; + $argNames .= '];'; - $result .= "){" + $result .= '){' . $argNames . 'var result = ZAjaxEngine.invokeRemoteMethod(' . "this, '" . $method->getName() . "',argNames,arguments);" . 'return(result);}'; } else { - $result .= "){}"; + $result .= '){}'; } } - return $result . "}"; + return $result . '}'; } @@ -371,7 +373,7 @@ private static function _encodeVariables(ReflectionClass $cls) { $properties = $cls->getProperties(); $propValues = get_class_vars($cls->getName()); - $result = "variables:{"; + $result = 'variables:{'; $cnt = 0; $tmpArray = array(); @@ -386,7 +388,7 @@ private static function _encodeVariables(ReflectionClass $cls) } $result .= implode(',', $tmpArray); - return $result . "}"; + return $result . '}'; } /** @@ -399,8 +401,9 @@ private static function _encodeVariables(ReflectionClass $cls) * instantiable using a null constructor * @param string $package Optional package name appended to JavaScript * proxy class name - * @return string The class2 (JavaScript) encoding of the class * @throws Zend_Json_Exception + * @throws ReflectionException + * @return string The class2 (JavaScript) encoding of the class */ public static function encodeClass($className, $package = '') { @@ -424,6 +427,8 @@ public static function encodeClass($className, $package = '') * * @param array $classNames * @param string $package + * @throws ReflectionException + * @throws Zend_Json_Exception * @return string */ public static function encodeClasses(array $classNames, $package = '') @@ -534,7 +539,7 @@ public static function encodeUnicodeString($value) * * Normally should be handled by mb_convert_encoding, but * provides a slower PHP-only method for installations - * that lack the multibye string extension. + * that lack the multibyte string extension. * * This method is from the Solar Framework by Paul M. Jones * @@ -558,17 +563,17 @@ protected static function _utf82utf16($utf8) case 2: // return a UTF-16 character from a 2-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8{0}) >> 2)) - . chr((0xC0 & (ord($utf8{0}) << 6)) - | (0x3F & ord($utf8{1}))); + return chr(0x07 & (ord($utf8[0]) >> 2)) + . chr((0xC0 & (ord($utf8[0]) << 6)) + | (0x3F & ord($utf8[1]))); case 3: // return a UTF-16 character from a 3-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8{0}) << 4)) - | (0x0F & (ord($utf8{1}) >> 2))) - . chr((0xC0 & (ord($utf8{1}) << 6)) - | (0x7F & ord($utf8{2}))); + return chr((0xF0 & (ord($utf8[0]) << 4)) + | (0x0F & (ord($utf8[1]) >> 2))) + . chr((0xC0 & (ord($utf8[1]) << 6)) + | (0x7F & ord($utf8[2]))); } // ignoring UTF-32 for now, sorry diff --git a/packages/zend-ldap/library/Zend/Ldap/Converter.php b/packages/zend-ldap/library/Zend/Ldap/Converter.php index e8677e1f1..81e3f8144 100644 --- a/packages/zend-ldap/library/Zend/Ldap/Converter.php +++ b/packages/zend-ldap/library/Zend/Ldap/Converter.php @@ -45,11 +45,13 @@ class Zend_Ldap_Converter */ public static function ascToHex32($string) { - for ($i = 0; $i$date can be either a timestamp, a - * DateTime Object, a string that is parseable by strtotime() or a Zend_Date + * DateTime Object, a string that is parsable by strtotime() or a Zend_Date * Object. * - * @param integer|string|DateTimt|Zend_Date $date The date-entity - * @param boolean $asUtc Whether to return the LDAP-compatible date-string + * @param integer|string|DateTimt|Zend_Date $date The date-entity + * @param boolean $asUtc Whether to return the LDAP-compatible date-string * as UTC or as local value - * @return string - * @throws InvalidArgumentException + * @throws InvalidArgumentException + * @throws Zend_Date_Exception + * @return string */ public static function toLdapDateTime($date, $asUtc = true) { @@ -216,7 +220,7 @@ public static function toLdapSerialize($value) * type can be forced * . * @param string $value The value to convert - * @param int $ytpe The conversion type to use + * @param int $type The conversion type to use * @param boolean $dateTimeAsUtc Return DateTime values in UTC timezone * @return mixed * @throws Zend_Ldap_Converter_Exception @@ -251,12 +255,13 @@ public static function fromLdap($value, $type = self::STANDARD, $dateTimeAsUtc = /** * Convert an LDAP-Generalized-Time-entry into a DateTime-Object * - * CAVEAT: The DateTime-Object returned will alwasy be set to UTC-Timezone. + * CAVEAT: The DateTime-Object returned will always be set to UTC-Timezone. * - * @param string $date The generalized-Time - * @param boolean $asUtc Return the DateTime with UTC timezone - * @return DateTime - * @throws InvalidArgumentException if a non-parseable-format is given + * @param string $date The generalized-Time + * @param boolean $asUtc Return the DateTime with UTC timezone + * @throws InvalidArgumentException if a non-parsable-format is given + * @throws Exception + * @return DateTime */ public static function fromLdapDateTime($date, $asUtc = true) { diff --git a/packages/zend-locale/library/Zend/Locale/Format.php b/packages/zend-locale/library/Zend/Locale/Format.php index dbc4ed409..9bde6abc5 100644 --- a/packages/zend-locale/library/Zend/Locale/Format.php +++ b/packages/zend-locale/library/Zend/Locale/Format.php @@ -129,7 +129,7 @@ private static function _checkOptions(array $options = array()) if (($value != 'php') && ($value != 'iso')) { // require_once 'Zend/Locale/Exception.php'; throw new Zend_Locale_Exception("Unknown date format type '$value'. Only 'iso' and 'php'" - . " are supported."); + . ' are supported.'); } break; @@ -181,7 +181,7 @@ private static function _checkOptions(array $options = array()) /** * Changes the numbers/digits within a given string from one script to another - * 'Decimal' representated the stardard numbers 0-9, if a script does not exist + * 'Decimal' represented the standard numbers 0-9, if a script does not exist * an exception will be thrown. * * Examples for conversion from Arabic to Latin numerals: @@ -198,7 +198,7 @@ private static function _checkOptions(array $options = array()) public static function convertNumerals($input, $from, $to = null) { if (!self::_getUniCodeSupport()) { - trigger_error("Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core", E_USER_NOTICE); + trigger_error('Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core', E_USER_NOTICE); } $from = strtolower($from); @@ -220,7 +220,7 @@ public static function convertNumerals($input, $from, $to = null) } for ($x = 0; $x < 10; ++$x) { - $asource[$x] = "/" . iconv_substr($source, $x, 1, 'UTF-8') . "/u"; + $asource[$x] = '/' . iconv_substr($source, $x, 1, 'UTF-8') . '/u'; $atarget[$x] = iconv_substr($target, $x, 1, 'UTF-8'); } @@ -265,7 +265,7 @@ public static function getNumber($input, array $options = array()) $input = str_replace($symbols['group'],'', $input); if (strpos($input, $symbols['decimal']) !== false) { if ($symbols['decimal'] != '.') { - $input = str_replace($symbols['decimal'], ".", $input); + $input = str_replace($symbols['decimal'], '.', $input); } $pre = substr($input, strpos($input, '.') + 1); @@ -287,7 +287,7 @@ public static function getNumber($input, array $options = array()) /** * Returns a locale formatted number depending on the given options. - * The seperation and fraction sign is used from the set locale. + * The separation and fraction sign is used from the set locale. * ##0.# -> 12345.12345 -> 12345.12345 * ##0.00 -> 12345.12345 -> 12345.12 * ##,##0.00 -> 12345.12345 -> 12,345.12 @@ -356,12 +356,12 @@ public static function toNumber($value, array $options = array()) } else { $precstr = iconv_substr($value, $pos + 1, $options['precision']); if (iconv_strlen($precstr) < $options['precision']) { - $precstr = $precstr . str_pad("0", ($options['precision'] - iconv_strlen($precstr)), "0"); + $precstr .= str_pad('0', ($options['precision'] - iconv_strlen($precstr)), '0'); } } } else { if ($options['precision'] > 0) { - $precstr = str_pad("0", ($options['precision']), "0"); + $precstr = str_pad('0', ($options['precision']), '0'); } } @@ -387,11 +387,11 @@ public static function toNumber($value, array $options = array()) } if (($prec == 0) and ($options['precision'] > 0)) { - $prec = "0.0"; + $prec = '0.0'; } if (($options['precision'] + 2) > iconv_strlen($prec)) { - $prec = str_pad((string) $prec, $options['precision'] + 2, "0", STR_PAD_RIGHT); + $prec = str_pad((string) $prec, $options['precision'] + 2, '0', STR_PAD_RIGHT); } if (iconv_strpos($number, '-') !== false) { @@ -401,7 +401,7 @@ public static function toNumber($value, array $options = array()) $group2 = iconv_strpos ($format, ','); $point = iconv_strpos ($format, '0'); // Add fraction - $rest = ""; + $rest = ''; if (iconv_strpos($format, '.')) { $rest = iconv_substr($format, iconv_strpos($format, '.') + 1); $length = iconv_strlen($rest); @@ -426,33 +426,33 @@ public static function toNumber($value, array $options = array()) } $format .= $rest; - // Add seperation + // Add separation if ($group == 0) { - // no seperation + // no separation $format = $number . iconv_substr($format, $point); } else if ($group == $group2) { - // only 1 seperation - $seperation = ($point - $group); - for ($x = iconv_strlen($number); $x > $seperation; $x -= $seperation) { - if (iconv_substr($number, 0, $x - $seperation) !== "") { - $number = iconv_substr($number, 0, $x - $seperation) . $symbols['group'] - . iconv_substr($number, $x - $seperation); + // only 1 separation + $separation = ($point - $group); + for ($x = iconv_strlen($number); $x > $separation; $x -= $separation) { + if (iconv_substr($number, 0, $x - $separation) !== "") { + $number = iconv_substr($number, 0, $x - $separation) . $symbols['group'] + . iconv_substr($number, $x - $separation); } } $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point); } else { - // 2 seperations + // 2 separations if (iconv_strlen($number) > ($point - $group)) { - $seperation = ($point - $group); - $number = iconv_substr($number, 0, iconv_strlen($number) - $seperation) . $symbols['group'] - . iconv_substr($number, iconv_strlen($number) - $seperation); + $separation = ($point - $group); + $number = iconv_substr($number, 0, iconv_strlen($number) - $separation) . $symbols['group'] + . iconv_substr($number, iconv_strlen($number) - $separation); if ((iconv_strlen($number) - 1) > ($point - $group + 1)) { - $seperation2 = ($group - $group2 - 1); - for ($x = iconv_strlen($number) - $seperation2 - 2; $x > $seperation2; $x -= $seperation2) { - $number = iconv_substr($number, 0, $x - $seperation2) . $symbols['group'] - . iconv_substr($number, $x - $seperation2); + $separation2 = ($group - $group2 - 1); + for ($x = iconv_strlen($number) - $separation2 - 2; $x > $separation2; $x -= $separation2) { + $number = iconv_substr($number, 0, $x - $separation2) . $symbols['group'] + . iconv_substr($number, $x - $separation2); } } @@ -500,14 +500,16 @@ private static function _seperateFormat($format, $value, $precision) /** * Checks if the input contains a normalized or localized number * - * @param string $input Localized number string - * @param array $options Options: locale. See {@link setOptions()} for details. + * @param string $input Localized number string + * @param array $options Options: locale. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return boolean Returns true if a number was found */ public static function isNumber($input, array $options = array()) { + $input = (string)$input; if (!self::_getUniCodeSupport()) { - trigger_error("Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core", E_USER_NOTICE); + trigger_error('Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core', E_USER_NOTICE); } $options = self::_checkOptions($options) + self::$_options; @@ -515,8 +517,8 @@ public static function isNumber($input, array $options = array()) // Get correct signs for this locale $symbols = Zend_Locale_Data::getList($options['locale'],'symbols'); - $regexs = Zend_Locale_Format::_getRegexForType('decimalnumber', $options); - $regexs = array_merge($regexs, Zend_Locale_Format::_getRegexForType('scientificnumber', $options)); + $regexs = self::_getRegexForType('decimalnumber', $options); + $regexs = array_merge($regexs, self::_getRegexForType('scientificnumber', $options)); if (!empty($input) && ($input[0] == $symbols['decimal'])) { $input = 0 . $input; } @@ -544,7 +546,7 @@ private static function _getRegexForType($type, $options) $decimal = preg_replace('/[^#0,;\.\-Ee]/u', '',$decimal); $patterns = explode(';', $decimal); - if (count($patterns) == 1) { + if (count($patterns) === 1) { $patterns[1] = '-' . $patterns[0]; } @@ -552,7 +554,6 @@ private static function _getRegexForType($type, $options) foreach($patterns as $pkey => $pattern) { $regex[$pkey] = '/^'; - $rest = 0; $end = null; if (strpos($pattern, '.') !== false) { $end = substr($pattern, strpos($pattern, '.') + 1); @@ -561,12 +562,11 @@ private static function _getRegexForType($type, $options) if (strpos($pattern, ',') !== false) { $parts = explode(',', $pattern); - $count = count($parts); foreach($parts as $key => $part) { switch ($part) { case '#': case '-#': - if ($part[0] == '-') { + if ($part[0] === '-') { $regex[$pkey] .= '[' . $symbols['minus'] . '-]{0,1}'; } else { $regex[$pkey] .= '[' . $symbols['plus'] . '+]{0,1}'; @@ -636,21 +636,23 @@ private static function _getRegexForType($type, $options) /** * Alias for getNumber * - * @param string $input Number to localize - * @param array $options Options: locale, precision. See {@link setOptions()} for details. + * @param string $input Number to localize + * @param array $options Options: locale, precision. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return float */ public static function getFloat($input, array $options = array()) { - return floatval(self::getNumber($input, $options)); + return (float)self::getNumber($input, $options); } /** * Returns a locale formatted integer number * Alias for toNumber() * - * @param string $value Number to normalize - * @param array $options Options: locale, precision. See {@link setOptions()} for details. + * @param string $value Number to normalize + * @param array $options Options: locale, precision. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return string Locale formatted number */ public static function toFloat($value, array $options = array()) @@ -663,8 +665,9 @@ public static function toFloat($value, array $options = array()) * Returns if a float was found * Alias for isNumber() * - * @param string $value Localized number string - * @param array $options Options: locale. See {@link setOptions()} for details. + * @param string $value Localized number string + * @param array $options Options: locale. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return boolean Returns true if a number was found */ public static function isFloat($value, array $options = array()) @@ -684,21 +687,23 @@ public static function isFloat($value, array $options = array()) * '0' = 0 * '(-){0,1}(\d+(\.){0,1})*(\,){0,1})\d+' * - * @param string $input Input string to parse for numbers - * @param array $options Options: locale. See {@link setOptions()} for details. + * @param string $input Input string to parse for numbers + * @param array $options Options: locale. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return integer Returns the extracted number */ public static function getInteger($input, array $options = array()) { $options['precision'] = 0; - return intval(self::getFloat($input, $options)); + return (int)self::getFloat($input, $options); } /** * Returns a localized number * - * @param string $value Number to normalize - * @param array $options Options: locale. See {@link setOptions()} for details. + * @param string $value Number to normalize + * @param array $options Options: locale. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return string Locale formatted number */ public static function toInteger($value, array $options = array()) @@ -711,8 +716,9 @@ public static function toInteger($value, array $options = array()) /** * Returns if a integer was found * - * @param string $value Localized number string - * @param array $options Options: locale. See {@link setOptions()} for details. + * @param string $value Localized number string + * @param array $options Options: locale. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return boolean Returns true if a integer was found */ public static function isInteger($value, array $options = array()) @@ -807,7 +813,7 @@ public static function convertPhpToIsoFormat($format) private static function _parseDate($date, $options) { if (!self::_getUniCodeSupport()) { - trigger_error("Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core", E_USER_NOTICE); + trigger_error('Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core', E_USER_NOTICE); } $options = self::_checkOptions($options) + self::$_options; @@ -904,12 +910,12 @@ private static function _parseDate($date, $options) $split = false; preg_match_all('/\d+/u', $number, $splitted); - if (count($splitted[0]) == 0) { + if (count($splitted[0]) === 0) { self::_setEncoding($oenc); // require_once 'Zend/Locale/Exception.php'; throw new Zend_Locale_Exception("No date part in '$date' found."); } - if (count($splitted[0]) == 1) { + if (count($splitted[0]) === 1) { $split = 0; } $cnt = 0; @@ -1024,9 +1030,9 @@ private static function _parseDate($date, $options) // AM/PM correction if ($hour !== false) { - if (($am === true) and ($result['hour'] == 12)){ + if (($am === true) && ($result['hour'] == 12)){ $result['hour'] = 0; - } else if (($am === false) and ($result['hour'] != 12)) { + } else if (($am === false) && ($result['hour'] != 12)) { $result['hour'] += 12; } } @@ -1037,9 +1043,9 @@ private static function _parseDate($date, $options) if ($day !== false) { // fix false month - if (isset($result['day']) and isset($result['month'])) { - if (($position !== false) and ((iconv_strpos($date, $result['day']) === false) or - (isset($result['year']) and (iconv_strpos($date, $result['year']) === false)))) { + if (isset($result['day']) && isset($result['month'])) { + if (($position !== false) && ((iconv_strpos($date, $result['day']) === false) || + (isset($result['year']) && (iconv_strpos($date, $result['year']) === false)))) { if ($options['fix_date'] !== true) { self::_setEncoding($oenc); // require_once 'Zend/Locale/Exception.php'; @@ -1054,23 +1060,21 @@ private static function _parseDate($date, $options) } // fix switched values d <> y - if (isset($result['day']) and isset($result['year'])) { - if ($result['day'] > 31) { - if ($options['fix_date'] !== true) { - self::_setEncoding($oenc); - // require_once 'Zend/Locale/Exception.php'; - throw new Zend_Locale_Exception("Unable to parse date '$date' using '" - . $format . "' (d <> y)"); - } - $temp = $result['year']; - $result['year'] = $result['day']; - $result['day'] = $temp; - $result['fixed'] = 2; + if (isset($result['day'], $result['year']) && $result['day'] > 31) { + if ($options['fix_date'] !== true) { + self::_setEncoding($oenc); + // require_once 'Zend/Locale/Exception.php'; + throw new Zend_Locale_Exception("Unable to parse date '$date' using '" + . $format . "' (d <> y)"); } + $temp = $result['year']; + $result['year'] = $result['day']; + $result['day'] = $temp; + $result['fixed'] = 2; } // fix switched values M <> y - if (isset($result['month']) and isset($result['year'])) { + if (isset($result['month'], $result['year'])) { if ($result['month'] > 31) { if ($options['fix_date'] !== true) { self::_setEncoding($oenc); @@ -1103,7 +1107,7 @@ private static function _parseDate($date, $options) } if (isset($result['year'])) { - if (((iconv_strlen($result['year']) == 2) && ($result['year'] < 10)) || + if (((iconv_strlen($result['year']) === 2) && ($result['year'] < 10)) || (((iconv_strpos($format, 'yy') !== false) && (iconv_strpos($format, 'yyyy') === false)) || ((iconv_strpos($format, 'YY') !== false) && (iconv_strpos($format, 'YYYY') === false)))) { if (($result['year'] >= 0) && ($result['year'] < 100)) { @@ -1134,7 +1138,6 @@ protected static function _replaceMonth(&$number, $monthlist) // mapping for each month number from 1 to 12. // If no $locale was given, or $locale was invalid, do not use this identity mapping to normalize. // Otherwise, translate locale aware month names in $number to their numeric equivalents. - $position = false; if ($monthlist && $monthlist[1] != 1) { foreach($monthlist as $key => $name) { if (($position = iconv_strpos($number, $name, 0, 'UTF-8')) !== false) { @@ -1174,8 +1177,9 @@ public static function getDateFormat($locale = null) * The 'format' option allows specification of self-defined date formats, * when not using the default format for the 'locale'. * - * @param string $date Date string - * @param array $options Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. + * @param string $date Date string + * @param array $options Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return array Possible array members: day, month, year, hour, minute, second, fixed, format */ public static function getDate($date, array $options = array()) @@ -1194,8 +1198,9 @@ public static function getDate($date, array $options = array()) * If no format is given, the default date format from the locale is used * If you want to check if the date is a proper date you should use Zend_Date::isDate() * - * @param string $date Date string - * @param array $options Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. + * @param string $date Date string + * @param array $options Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return boolean */ public static function checkDateFormat($date, array $options = array()) @@ -1272,8 +1277,9 @@ public static function getTimeFormat($locale = null) * The optional $locale parameter may be used to help extract times from strings * containing both a time and a day or month name. * - * @param string $time Time string - * @param array $options Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. + * @param string $time Time string + * @param array $options Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return array Possible array members: day, month, year, hour, minute, second, fixed, format */ public static function getTime($time, array $options = array()) @@ -1311,8 +1317,9 @@ public static function getDateTimeFormat($locale = null) * The optional $locale parameter may be used to help extract times from strings * containing both a time and a day or month name. * - * @param string $datetime DateTime string - * @param array $options Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. + * @param string $datetime DateTime string + * @param array $options Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. + * @throws Zend_Locale_Exception * @return array Possible array members: day, month, year, hour, minute, second, fixed, format */ public static function getDateTime($datetime, array $options = array()) diff --git a/packages/zend-measure/library/Zend/Measure/Abstract.php b/packages/zend-measure/library/Zend/Measure/Abstract.php index a8177eb3d..c50fca95a 100644 --- a/packages/zend-measure/library/Zend/Measure/Abstract.php +++ b/packages/zend-measure/library/Zend/Measure/Abstract.php @@ -113,7 +113,10 @@ public function getLocale() * Sets a new locale for the value representation * * @param string|Zend_Locale $locale (Optional) New locale to set - * @param boolean $check False, check but don't set; True, set the new locale + * @param boolean $check False, check but don't set; True, set the new locale + * @throws Zend_Exception + * @throws Zend_Locale_Exception + * @throws Zend_Measure_Exception * @return Zend_Measure_Abstract */ public function setLocale($locale = null, $check = false) @@ -147,9 +150,12 @@ public function setLocale($locale = null, $check = false) /** * Returns the internal value * - * @param integer $round (Optional) Rounds the value to an given precision, + * @param integer $round (Optional) Rounds the value to an given precision, * Default is -1 which returns without rounding * @param string|Zend_Locale $locale (Optional) Locale for number representation + * @throws Zend_Exception + * @throws Zend_Locale_Exception + * @throws Zend_Measure_Exception * @return integer|string */ public function getValue($round = -1, $locale = null) @@ -171,9 +177,11 @@ public function getValue($round = -1, $locale = null) /** * Set a new value * - * @param integer|string $value Value as string, integer, real or float - * @param string $type OPTIONAL A measure type f.e. Zend_Measure_Length::METER - * @param string|Zend_Locale $locale OPTIONAL Locale for parsing numbers + * @param integer|string $value Value as string, integer, real or float + * @param string $type OPTIONAL A measure type f.e. Zend_Measure_Length::METER + * @param string|Zend_Locale $locale OPTIONAL Locale for parsing numbers + * @throws Zend_Exception + * @throws Zend_Locale_Exception * @throws Zend_Measure_Exception * @return Zend_Measure_Abstract */ @@ -286,10 +294,11 @@ public function setType($type) $value = call_user_func(Zend_Locale_Math::$div, $value, $this->_units[$type][0], 25); } + $sValue = (string) $value; $slength = strlen($value); $length = 0; for($i = 1; $i <= $slength; ++$i) { - if ($value[$slength - $i] != '0') { + if ($sValue[$slength - $i] != '0') { $length = 26 - $i; break; } diff --git a/packages/zend-registry/library/Zend/Registry.php b/packages/zend-registry/library/Zend/Registry.php index 63b448220..5f75bfaee 100644 --- a/packages/zend-registry/library/Zend/Registry.php +++ b/packages/zend-registry/library/Zend/Registry.php @@ -194,16 +194,4 @@ public function __construct($array = array(), $flags = parent::ARRAY_AS_PROPS) { parent::__construct($array, $flags); } - - /** - * @param string $index - * @returns mixed - * - * Workaround for http://bugs.php.net/bug.php?id=40442 (ZF-960). - */ - public function offsetExists($index) - { - return array_key_exists($index, $this); - } - } diff --git a/packages/zend-service-rackspace/library/Zend/Service/Rackspace/Abstract.php b/packages/zend-service-rackspace/library/Zend/Service/Rackspace/Abstract.php index 8e1e30772..4bd47f134 100644 --- a/packages/zend-service-rackspace/library/Zend/Service/Rackspace/Abstract.php +++ b/packages/zend-service-rackspace/library/Zend/Service/Rackspace/Abstract.php @@ -191,10 +191,8 @@ public function getCdnUrl() */ public function getManagementUrl() { - if (empty($this->managementUrl)) { - if (!$this->authenticate()) { - return false; - } + if (empty($this->managementUrl) && !$this->authenticate()) { + return false; } return $this->managementUrl; } diff --git a/packages/zend-service-rackspace/library/Zend/Service/Rackspace/Servers/Server.php b/packages/zend-service-rackspace/library/Zend/Service/Rackspace/Servers/Server.php index 149023d93..b956082e2 100644 --- a/packages/zend-service-rackspace/library/Zend/Service/Rackspace/Servers/Server.php +++ b/packages/zend-service-rackspace/library/Zend/Service/Rackspace/Servers/Server.php @@ -104,11 +104,11 @@ public function __construct($service, $data) // require_once 'Zend/Service/Rackspace/Servers/Exception.php'; throw new Zend_Service_Rackspace_Servers_Exception(self::ERROR_PARAM_CONSTRUCT); } - if (!array_key_exists('name', $data)) { + if (!isset($data['name'])) { // require_once 'Zend/Service/Rackspace/Servers/Exception.php'; throw new Zend_Service_Rackspace_Servers_Exception(self::ERROR_PARAM_NO_NAME); } - if (!array_key_exists('id', $data)) { + if (!isset($data['id'])) { // require_once 'Zend/Service/Rackspace/Servers/Exception.php'; throw new Zend_Service_Rackspace_Servers_Exception(self::ERROR_PARAM_NO_ID); } diff --git a/packages/zend-tool/library/Zend/Tool/Project/Context/Zf/ApplicationConfigFile.php b/packages/zend-tool/library/Zend/Tool/Project/Context/Zf/ApplicationConfigFile.php index 437098478..998f44571 100644 --- a/packages/zend-tool/library/Zend/Tool/Project/Context/Zf/ApplicationConfigFile.php +++ b/packages/zend-tool/library/Zend/Tool/Project/Context/Zf/ApplicationConfigFile.php @@ -48,6 +48,10 @@ class Zend_Tool_Project_Context_Zf_ApplicationConfigFile extends Zend_Tool_Proje * @var string */ protected $_content = null; + /** + * @var Zend_Tool_Project_Profile_Resource_Container + */ + private $_type; /** * getName() @@ -139,7 +143,7 @@ public function addStringItem($key, $value, $section = 'production', $quoteValue $newLines[] = $contentLine; if ($insideSection) { // if its blank, or a section heading - if (isset($contentLines[$contentLineIndex + 1]{0}) && $contentLines[$contentLineIndex + 1]{0} == '[') { + if (isset($contentLines[$contentLineIndex + 1][0]) && $contentLines[$contentLineIndex + 1][0] == '[') { $newLines[] = $key . ' = ' . $value; $insideSection = null; } else if (!isset($contentLines[$contentLineIndex + 1])){ @@ -171,12 +175,8 @@ public function addItem($item, $section = 'production', $quoteValue = true) RecursiveIteratorIterator::SELF_FIRST ); - $lastDepth = 0; - // loop through array structure recursively to create proper keys foreach ($rii as $name => $value) { - $lastDepth = $rii->getDepth(); - if (is_array($value)) { array_push($configKeyNames, $name); } else { @@ -231,12 +231,8 @@ public function removeItem($item, $section = 'production') RecursiveIteratorIterator::SELF_FIRST ); - $lastDepth = 0; - // loop through array structure recursively to create proper keys foreach ($rii as $name => $value) { - $lastDepth = $rii->getDepth(); - if (is_array($value)) { array_push($configKeyNames, $name); } else { diff --git a/packages/zend-validate/library/Zend/Validate/Barcode/Upce.php b/packages/zend-validate/library/Zend/Validate/Barcode/Upce.php index df8e80b5f..0ac1b0dd7 100644 --- a/packages/zend-validate/library/Zend/Validate/Barcode/Upce.php +++ b/packages/zend-validate/library/Zend/Validate/Barcode/Upce.php @@ -58,7 +58,7 @@ class Zend_Validate_Barcode_Upce extends Zend_Validate_Barcode_AdapterAbstract */ public function checkLength($value) { - if (strlen($value) != 8) { + if (strlen($value) !== 8) { $this->setCheck(false); } else { $this->setCheck(true); diff --git a/packages/zend-validate/library/Zend/Validate/Isbn.php b/packages/zend-validate/library/Zend/Validate/Isbn.php index 546771eba..4df4dce48 100644 --- a/packages/zend-validate/library/Zend/Validate/Isbn.php +++ b/packages/zend-validate/library/Zend/Validate/Isbn.php @@ -44,7 +44,7 @@ class Zend_Validate_Isbn extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::INVALID => "Invalid type given. String or integer expected", + self::INVALID => 'Invalid type given. String or integer expected', self::NO_ISBN => "'%value%' is not a valid ISBN number", ); @@ -167,7 +167,7 @@ public function isValid($value) $isbn10 = str_replace($this->_separator, '', $value); $sum = 0; for ($i = 0; $i < 9; $i++) { - $sum += (10 - $i) * $isbn10{$i}; + $sum += (10 - $i) * $isbn10[$i]; } // checksum @@ -184,15 +184,15 @@ public function isValid($value) $isbn13 = str_replace($this->_separator, '', $value); $sum = 0; for ($i = 0; $i < 12; $i++) { - if ($i % 2 == 0) { - $sum += $isbn13{$i}; + if ($i % 2 === 0) { + $sum += $isbn13[$i]; } else { - $sum += 3 * $isbn13{$i}; + $sum += 3 * $isbn13[$i]; } } // checksum $checksum = 10 - ($sum % 10); - if ($checksum == 10) { + if ($checksum === 10) { $checksum = '0'; } break; diff --git a/packages/zend-view/library/Zend/View/Helper/Navigation/Sitemap.php b/packages/zend-view/library/Zend/View/Helper/Navigation/Sitemap.php index c4ffcf5f9..287054014 100644 --- a/packages/zend-view/library/Zend/View/Helper/Navigation/Sitemap.php +++ b/packages/zend-view/library/Zend/View/Helper/Navigation/Sitemap.php @@ -253,10 +253,10 @@ public function url(Zend_Navigation_Page $page) { $href = $page->getHref(); - if (!isset($href{0})) { + if (!isset($href[0])) { // no href return ''; - } elseif ($href{0} == '/') { + } elseif ($href[0] == '/') { // href is relative to root; use serverUrl helper $url = $this->getServerUrl() . $href; } elseif (preg_match('/^[a-z]+:/im', (string) $href)) { @@ -404,15 +404,13 @@ public function getDomSitemap(Zend_Navigation_Container $container = null) } // validate using schema if specified - if ($this->getUseSchemaValidation()) { - if (!@$dom->schemaValidate(self::SITEMAP_XSD)) { - // require_once 'Zend/View/Exception.php'; - $e = new Zend_View_Exception(sprintf( - 'Sitemap is invalid according to XML Schema at "%s"', - self::SITEMAP_XSD)); - $e->setView($this->view); - throw $e; - } + if ($this->getUseSchemaValidation() && !@$dom->schemaValidate(self::SITEMAP_XSD)) { + // require_once 'Zend/View/Exception.php'; + $e = new Zend_View_Exception(sprintf( + 'Sitemap is invalid according to XML Schema at "%s"', + self::SITEMAP_XSD)); + $e->setView($this->view); + throw $e; } return $dom; @@ -425,10 +423,11 @@ public function getDomSitemap(Zend_Navigation_Container $container = null) * * Implements {@link Zend_View_Helper_Navigation_Helper::render()}. * - * @param Zend_Navigation_Container $container [optional] container to + * @param Zend_Navigation_Container $container [optional] container to * render. Default is to * render the container * registered in the helper. + * @throws Zend_View_Exception * @return string helper output */ public function render(Zend_Navigation_Container $container = null) diff --git a/packages/zend-wildfire/library/Zend/Wildfire/Plugin/FirePhp.php b/packages/zend-wildfire/library/Zend/Wildfire/Plugin/FirePhp.php index 01038137e..343e1a8c7 100644 --- a/packages/zend-wildfire/library/Zend/Wildfire/Plugin/FirePhp.php +++ b/packages/zend-wildfire/library/Zend/Wildfire/Plugin/FirePhp.php @@ -740,9 +740,9 @@ protected function _encodeObject($object, $objectDepth = 1, $arrayDepth = 1) // but exist in the object foreach($members as $just_name => $value) { - $name = $raw_name = $just_name; + $name = (string)$raw_name = $just_name; - if ($name{0} == "\0") { + if ($name[0] == "\0") { $parts = explode("\0", $name); $name = $parts[2]; } diff --git a/tests/Zend/Cache/AllTests.php b/tests/Zend/Cache/AllTests.php index 3d6065e22..79a5b343b 100644 --- a/tests/Zend/Cache/AllTests.php +++ b/tests/Zend/Cache/AllTests.php @@ -79,6 +79,7 @@ public static function suite() /* * Check if SQLite tests are enabled, and if extension and driver are available. */ + if (!defined('TESTS_ZEND_CACHE_SQLITE_ENABLED') || constant('TESTS_ZEND_CACHE_SQLITE_ENABLED') === false) { $skipTest = new Zend_Cache_SqliteBackendTest_SkipTests(); diff --git a/tests/Zend/Cache/CommonBackendTest.php b/tests/Zend/Cache/CommonBackendTest.php index f3616f052..ee15eeea3 100644 --- a/tests/Zend/Cache/CommonBackendTest.php +++ b/tests/Zend/Cache/CommonBackendTest.php @@ -40,7 +40,7 @@ abstract class Zend_Cache_CommonBackendTest extends PHPUnit_Framework_TestCase { public function __construct($name = null, array $data = array(), $dataName = '') { $this->_className = $name; - $this->_root = dirname(__FILE__); + $this->_root = __DIR__; date_default_timezone_set('UTC'); parent::__construct($name, $data, $dataName); } @@ -79,7 +79,7 @@ public function getTmpDir($date = true) if ($date) { $suffix = date('mdyHis'); } - if (is_writeable($this->_root)) { + if (is_writable($this->_root)) { return $this->_root . DIRECTORY_SEPARATOR . 'zend_cache_tmp_dir_' . $suffix; } else { if (getenv('TMPDIR')){ diff --git a/tests/Zend/Cloud/Infrastructure/Adapter/RackspaceTest.php b/tests/Zend/Cloud/Infrastructure/Adapter/RackspaceTest.php index 4c05c5de5..aefeb00c8 100644 --- a/tests/Zend/Cloud/Infrastructure/Adapter/RackspaceTest.php +++ b/tests/Zend/Cloud/Infrastructure/Adapter/RackspaceTest.php @@ -70,11 +70,11 @@ public function setUp() // load the HTTP response (from a file) $shortClassName = 'RackspaceTest'; - $filename= dirname(__FILE__) . '/_files/' . $shortClassName . '_'. $this->getName().'.response'; + $filename= __DIR__ . '/_files/' . $shortClassName . '_'. $this->getName().'.response'; if (file_exists($filename)) { // authentication (from file) - $content = dirname(__FILE__) . '/_files/'.$shortClassName . '_testAuthenticate.response'; + $content = __DIR__ . '/_files/'.$shortClassName . '_testAuthenticate.response'; $this->httpClientAdapterTest->setResponse($this->loadResponse($content)); $this->assertTrue($this->infrastructure->getAdapter()->authenticate(),'Authentication failed'); @@ -158,9 +158,9 @@ public function testCreateInstance() 'foo' => 'bar' ) ); - $instance = $this->infrastructure->createInstance(constant('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGE_NAME'), $options); - self::$instanceId= $instance->getId(); - $this->assertEquals(constant('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGEID'), $instance->getImageId()); + $instance = $this->infrastructure->createInstance(TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGE_NAME, $options); + self::$instanceId = $instance->getId(); + $this->assertEquals(TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGEID, $instance->getImageId()); } /** * Test list of an instance diff --git a/tests/Zend/CodeGenerator/Php/FileTest.php b/tests/Zend/CodeGenerator/Php/FileTest.php index 9ec0b403d..211f815cc 100644 --- a/tests/Zend/CodeGenerator/Php/FileTest.php +++ b/tests/Zend/CodeGenerator/Php/FileTest.php @@ -287,7 +287,7 @@ public function testFileLineEndingsAreAlwaysLineFeed() $targetLength = strlen('require_once \'SampleClass.php\';'); $this->assertEquals($targetLength, strlen($lines[2])); - $this->assertEquals(';', $lines[2]{$targetLength-1}); + $this->assertEquals(';', $lines[2][$targetLength-1]); } /** diff --git a/tests/Zend/Config/JsonTest.php b/tests/Zend/Config/JsonTest.php index 2e97c772c..004cb97dc 100644 --- a/tests/Zend/Config/JsonTest.php +++ b/tests/Zend/Config/JsonTest.php @@ -37,16 +37,32 @@ class Zend_Config_JsonTest extends PHPUnit_Framework_TestCase protected $_iniFileConfig; protected $_iniFileAllSectionsConfig; protected $_iniFileCircularConfig; + /** + * @var string + */ + private $_nonReadableConfig; + /** + * @var string + */ + private $_iniFileMultipleInheritanceConfig; + /** + * @var string + */ + private $_iniFileNoSectionsConfig; + /** + * @var string + */ + private $_iniFileInvalid; public function setUp() { - $this->_iniFileConfig = dirname(__FILE__) . '/_files/config.json'; - $this->_iniFileAllSectionsConfig = dirname(__FILE__) . '/_files/allsections.json'; - $this->_iniFileCircularConfig = dirname(__FILE__) . '/_files/circular.json'; - $this->_iniFileMultipleInheritanceConfig = dirname(__FILE__) . '/_files/multipleinheritance.json'; - $this->_nonReadableConfig = dirname(__FILE__) . '/_files/nonreadable.json'; - $this->_iniFileNoSectionsConfig = dirname(__FILE__) . '/_files/nosections.json'; - $this->_iniFileInvalid = dirname(__FILE__) . '/_files/invalid.json'; + $this->_iniFileConfig = __DIR__ . '/_files/config.json'; + $this->_iniFileAllSectionsConfig = __DIR__ . '/_files/allsections.json'; + $this->_iniFileCircularConfig = __DIR__ . '/_files/circular.json'; + $this->_iniFileMultipleInheritanceConfig = __DIR__ . '/_files/multipleinheritance.json'; + $this->_nonReadableConfig = __DIR__ . '/_files/nonreadable.json'; + $this->_iniFileNoSectionsConfig = __DIR__ . '/_files/nosections.json'; + $this->_iniFileInvalid = __DIR__ . '/_files/invalid.json'; } public function testLoadSingleSection() @@ -268,7 +284,7 @@ public function testIgnoringConstantsCanLeadToParseErrors() define('ZEND_CONFIG_JSON_ENV', 'testing'); } if (!defined('ZEND_CONFIG_JSON_ENV_PATH')) { - define('ZEND_CONFIG_JSON_ENV_PATH', dirname(__FILE__)); + define('ZEND_CONFIG_JSON_ENV_PATH', __DIR__); } if (!defined('ZEND_CONFIG_JSON_ENV_INT')) { define('ZEND_CONFIG_JSON_ENV_INT', 42); diff --git a/tests/Zend/Controller/Action/Helper/AjaxContextTest.php b/tests/Zend/Controller/Action/Helper/AjaxContextTest.php index 3397351d2..9821a511f 100644 --- a/tests/Zend/Controller/Action/Helper/AjaxContextTest.php +++ b/tests/Zend/Controller/Action/Helper/AjaxContextTest.php @@ -69,6 +69,8 @@ public static function main() * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * + * @throws Zend_Controller_Exception + * @throws Zend_Controller_Request_Exception * @return void */ public function setUp() @@ -82,7 +84,7 @@ public function setUp() $this->front = Zend_Controller_Front::getInstance(); $this->front->resetInstance(); - $this->front->addModuleDirectory(dirname(__FILE__) . '/../../_files/modules'); + $this->front->addModuleDirectory(__DIR__ . '/../../_files/modules'); $this->layout = Zend_Layout::startMvc(); @@ -92,8 +94,8 @@ public function setUp() $this->response = new Zend_Controller_Response_Cli(); $this->front->setRequest($this->request)->setResponse($this->response); - $this->view = new Zend_VIew(); - $this->view->addHelperPath(dirname(__FILE__) . '/../../../../../library/Zend/View/Helper/'); + $this->view = new Zend_View(); + $this->view->addHelperPath(__DIR__ . '/../../../../../library/Zend/View/Helper/'); $this->viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $this->viewRenderer->setView($this->view); diff --git a/tests/Zend/Crypt/MathTest.php b/tests/Zend/Crypt/MathTest.php index a540c6075..c784f6dd3 100644 --- a/tests/Zend/Crypt/MathTest.php +++ b/tests/Zend/Crypt/MathTest.php @@ -54,8 +54,8 @@ public function testRand() $higher = '155172898181473697471232257763715539915724801966915404479707795314057629378541917580651227423698188993727816152646631438561595825688188889951272158842675419950341258706556549803580104870537681476726513255747040765857479291291572334510643245094715007229621094194349783925984760375594985848253359305585439638443'; $lower = '155172898181473697471232257763715539915724801966915404479707795314057629378541917580651227423698188993727816152646631438561595825688188889951272158842675419950341258706556549803580104870537681476726513255747040765857479291291572334510643245094715007229621094194349783925984760375594985848253359305585439638442'; $result = $math->rand($lower, $higher); - $this->assertTrue(bccomp($result, $higher) !== '1'); - $this->assertTrue(bccomp($result, $lower) !== '-1'); + $this->assertNotSame(bccomp($result, $higher), '1'); + $this->assertNotSame(bccomp($result, $lower), '-1'); } public function testRandBytes() diff --git a/tests/Zend/Feed/AbstractFeedTest.php b/tests/Zend/Feed/AbstractFeedTest.php index 69501703f..ce3c5105e 100644 --- a/tests/Zend/Feed/AbstractFeedTest.php +++ b/tests/Zend/Feed/AbstractFeedTest.php @@ -38,7 +38,7 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Feed */ -class Zend_Feed_AbstractFeedTest extends PHPUnit_Framework_TestCase +abstract class Zend_Feed_AbstractFeedTest extends PHPUnit_Framework_TestCase { public $baseUri; @@ -61,7 +61,7 @@ public function tearDown() return parent::tearDown(); } - $basePath = dirname(__FILE__) . '/_files/'; + $basePath = __DIR__ . '/_files/'; foreach ($this->remoteFeedNames as $file) { $filename = $basePath . $file; if (!file_exists($filename)) { @@ -73,7 +73,7 @@ public function tearDown() public function prepareFeed($filename) { - $basePath = dirname(__FILE__) . '/_files/'; + $basePath = __DIR__ . '/_files/'; $path = $basePath . $filename; $remote = str_replace('.xml', '.remote.xml', $filename); $string = file_get_contents($path); diff --git a/tests/Zend/File/Transfer/Adapter/AbstractTest.php b/tests/Zend/File/Transfer/Adapter/AbstractTest.php index 6297a75b1..94459f418 100644 --- a/tests/Zend/File/Transfer/Adapter/AbstractTest.php +++ b/tests/Zend/File/Transfer/Adapter/AbstractTest.php @@ -633,7 +633,7 @@ public function testAddTypeIsNotImplemented() public function testAdapterShouldAllowRetrievingFileName() { - $path = dirname(__FILE__) + $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' @@ -644,7 +644,7 @@ public function testAdapterShouldAllowRetrievingFileName() public function testAdapterShouldAllowRetrievingFileNameWithoutPath() { - $path = dirname(__FILE__) + $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' @@ -655,27 +655,27 @@ public function testAdapterShouldAllowRetrievingFileNameWithoutPath() public function testAdapterShouldAllowRetrievingAllFileNames() { - $path = dirname(__FILE__) + $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files'; $this->adapter->setDestination($path); $files = $this->adapter->getFileName(); - $this->assertTrue(is_array($files)); + $this->assertInternalType('array', $files); $this->assertEquals($path . DIRECTORY_SEPARATOR . 'bar.png', $files['bar']); } public function testAdapterShouldAllowRetrievingAllFileNamesWithoutPath() { - $path = dirname(__FILE__) + $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files'; $this->adapter->setDestination($path); $files = $this->adapter->getFileName(null, false); - $this->assertTrue(is_array($files)); + $this->assertInternalType('array', $files); $this->assertEquals('bar.png', $files['bar']); } @@ -699,19 +699,19 @@ public function testIgnoreHashValue() public function testEmptyTempDirectoryDetection() { $this->adapter->_tmpDir = ""; - $this->assertTrue(empty($this->adapter->_tmpDir), "Empty temporary directory"); + $this->assertEmpty($this->adapter->_tmpDir, 'Empty temporary directory'); } public function testTempDirectoryDetection() { $this->adapter->getTmpDir(); - $this->assertTrue(!empty($this->adapter->_tmpDir), "Temporary directory filled"); + $this->assertNotEmpty($this->adapter->_tmpDir, 'Temporary directory filled'); } public function testTemporaryDirectoryAccessDetection() { - $this->adapter->_tmpDir = "."; - $path = "/NoPath/To/File"; + $this->adapter->_tmpDir = '.'; + $path = '/NoPath/To/File'; $this->assertFalse($this->adapter->isPathWriteable($path)); $this->assertTrue($this->adapter->isPathWriteable($this->adapter->_tmpDir)); } @@ -872,7 +872,7 @@ public function testSetDestinationWithNonExistingPathShouldThrowException() } // Create temporary directory - $directory = dirname(__FILE__) . '/_files/destination'; + $directory = __DIR__ . '/_files/destination'; if (!is_dir($directory)) { @mkdir($directory); } diff --git a/tests/Zend/Form/Element/FileTest.php b/tests/Zend/Form/Element/FileTest.php index 04a822a98..a214de135 100644 --- a/tests/Zend/Form/Element/FileTest.php +++ b/tests/Zend/Form/Element/FileTest.php @@ -70,6 +70,7 @@ public static function main() * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * + * @throws Zend_Form_Exception * @return void */ public function setUp() @@ -93,7 +94,7 @@ public function testElementShouldProxyToParentForDecoratorPluginLoader() { $loader = $this->element->getPluginLoader('decorator'); $paths = $loader->getPaths('Zend_Form_Decorator'); - $this->assertTrue(is_array($paths)); + $this->assertInternalType('array', $paths); $loader = new Zend_Loader_PluginLoader; $this->element->setPluginLoader($loader, 'decorator'); @@ -106,7 +107,7 @@ public function testElementShouldProxyToParentWhenSettingDecoratorPrefixPaths() $this->element->addPrefixPath('Foo_Decorator', 'Foo/Decorator/', 'decorator'); $loader = $this->element->getPluginLoader('decorator'); $paths = $loader->getPaths('Foo_Decorator'); - $this->assertTrue(is_array($paths)); + $this->assertInternalType('array', $paths); } public function testElementShouldAddToAllPluginLoadersWhenAddingNullPrefixPath() @@ -119,7 +120,7 @@ public function testElementShouldAddToAllPluginLoadersWhenAddingNullPrefixPath() $string = str_replace(' ', '_', $string); $prefix = 'Foo_' . $string; $paths = $loader->getPaths($prefix); - $this->assertTrue(is_array($paths), "Failed asserting paths found for prefix $prefix"); + $this->assertInternalType('array', $paths, "Failed asserting paths found for prefix $prefix"); } } @@ -150,12 +151,12 @@ public function testShouldRegisterPluginLoaderWithFileTransferAdapterPathByDefau $loader = $this->element->getPluginLoader('transfer_adapter'); $this->assertTrue($loader instanceof Zend_Loader_PluginLoader_Interface); $paths = $loader->getPaths('Zend_File_Transfer_Adapter'); - $this->assertTrue(is_array($paths)); + $this->assertInternalType('array', $paths); } public function testElementShouldAllowSpecifyingAdapterUsingPluginLoader() { - $this->element->addPrefixPath('Zend_Form_Element_FileTest_Adapter', dirname(__FILE__) . '/_files/TransferAdapter', 'transfer_adapter'); + $this->element->addPrefixPath('Zend_Form_Element_FileTest_Adapter', __DIR__ . '/_files/TransferAdapter', 'transfer_adapter'); $this->element->setTransferAdapter('Foo'); $test = $this->element->getTransferAdapter(); $this->assertTrue($test instanceof Zend_Form_Element_FileTest_Adapter_Foo); @@ -172,8 +173,8 @@ public function testValidatorAccessAndMutationShouldProxyToAdapter() $validators = $this->element->getValidators(); $test = $this->element->getTransferAdapter()->getValidators(); $this->assertEquals($validators, $test); - $this->assertTrue(is_array($test)); - $this->assertEquals(3, count($test)); + $this->assertInternalType('array', $test); + $this->assertCount(3, $test); $validator = $this->element->getValidator('count'); $test = $this->element->getTransferAdapter()->getValidator('count'); @@ -191,13 +192,13 @@ public function testValidatorAccessAndMutationShouldProxyToAdapter() $validators = $this->element->getValidators(); $test = $this->element->getTransferAdapter()->getValidators(); $this->assertSame($validators, $test); - $this->assertTrue(is_array($test)); - $this->assertEquals(3, count($test), var_export($test, 1)); + $this->assertInternalType('array', $test); + $this->assertCount(3, $test, var_export($test, 1)); $this->element->clearValidators(); $validators = $this->element->getValidators(); - $this->assertTrue(is_array($validators)); - $this->assertEquals(0, count($validators)); + $this->assertInternalType('array', $validators); + $this->assertCount(0, $validators); $test = $this->element->getTransferAdapter()->getValidators(); $this->assertSame($validators, $test); } @@ -216,9 +217,9 @@ public function testDestinationMutatorsShouldProxyToTransferAdapter() $adapter = new Zend_Form_Element_FileTest_MockAdapter(); $this->element->setTransferAdapter($adapter); - $this->element->setDestination(dirname(__FILE__)); - $this->assertEquals(dirname(__FILE__), $this->element->getDestination()); - $this->assertEquals(dirname(__FILE__), $this->element->getTransferAdapter()->getDestination('foo')); + $this->element->setDestination(__DIR__); + $this->assertEquals(__DIR__, $this->element->getDestination()); + $this->assertEquals(__DIR__, $this->element->getTransferAdapter()->getDestination('foo')); } public function testSettingMultipleFiles() @@ -337,16 +338,16 @@ public function testTranslatingValidatorErrors() public function testFileNameWithoutPath() { $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter()); - $this->element->setDestination(dirname(__FILE__)); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo.jpg', $this->element->getFileName('foo', true)); + $this->element->setDestination(__DIR__); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo.jpg', $this->element->getFileName('foo', true)); $this->assertEquals('foo.jpg', $this->element->getFileName('foo', false)); } public function testEmptyFileName() { $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter()); - $this->element->setDestination(dirname(__FILE__)); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo.jpg', $this->element->getFileName()); + $this->element->setDestination(__DIR__); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo.jpg', $this->element->getFileName()); } public function testIsReceived() @@ -390,7 +391,7 @@ public function testValueGetAndSet() public function testMarkerInterfaceForFileElement() { $this->element->setDecorators(array('ViewHelper')); - $this->assertEquals(1, count($this->element->getDecorators())); + $this->assertCount(1, $this->element->getDecorators()); try { $content = $this->element->render(new Zend_View()); @@ -513,7 +514,7 @@ public function testElementShouldAllowAdapterWithBackslahes() } $this->element->addPrefixPath( 'Zend\Form\Element\FileTest\Adapter', - dirname(__FILE__) . '/_files/TransferAdapter', + __DIR__ . '/_files/TransferAdapter', 'transfer_adapter' ); $this->element->setTransferAdapter('Bar'); @@ -586,7 +587,7 @@ class Zend_Form_Element_FileTest_MockAdapter extends Zend_File_Transfer_Adapter_ public function __construct() { - $testfile = dirname(__FILE__) . '/../../File/Transfer/Adapter/_files/test.txt'; + $testfile = __DIR__ . '/../../File/Transfer/Adapter/_files/test.txt'; $this->_files = array( 'foo' => array( 'name' => 'foo.jpg', diff --git a/tests/Zend/JsonTest.php b/tests/Zend/JsonTest.php index 847dd4a78..7908adb56 100644 --- a/tests/Zend/JsonTest.php +++ b/tests/Zend/JsonTest.php @@ -79,7 +79,8 @@ public function testJsonWithBuiltins() /** * Test encoding and decoding in a single step - * @param array $values array of values to test against encode/decode + * @throws Zend_Json_Exception + * @param array $values array of values to test against encode/decode */ protected function _testJson($values) { @@ -140,7 +141,7 @@ public function testJsonPrettyPrintWorksWithArrayNotationInStringLiteral() ) ) ); - $pretty = Zend_Json::prettyPrint(Zend_Json::encode($test), array("indent" => " ")); + $pretty = Zend_Json::prettyPrint(Zend_Json::encode($test), array('indent' => ' ')); $expected = <<assertTrue(is_object($decoded), 'Not decoded as an object'); + $this->assertInternalType('object', $decoded, 'Not decoded as an object'); $this->assertTrue($decoded instanceof StdClass, 'Not a StdClass object'); $this->assertTrue(isset($decoded->one), 'Expected property not set'); $this->assertEquals($value->one, $decoded->one, 'Unexpected value'); @@ -321,7 +322,8 @@ public function testDecodeObjectOfArrays() /** * Test encoding and decoding in a single step - * @param array $values array of values to test against encode/decode + * @throws Zend_Json_Exception + * @param array $values array of values to test against encode/decode */ protected function _testEncodeDecode($values) { @@ -566,16 +568,16 @@ public function testEncodingMultipleNestedSwitchingSameNameKeysWithDifferentJson { $data = array( 0 => array( - "alpha" => new Zend_Json_Expr("function(){}"), - "beta" => "gamma", + 'alpha' => new Zend_Json_Expr('function(){}'), + 'beta' => 'gamma', ), 1 => array( - "alpha" => "gamma", - "beta" => new Zend_Json_Expr("function(){}"), + 'alpha' => 'gamma', + 'beta' => new Zend_Json_Expr('function(){}'), ), 2 => array( - "alpha" => "gamma", - "beta" => "gamma", + 'alpha' => 'gamma', + 'beta' => 'gamma', ) ); $result = Zend_Json::encode($data, false, array('enableJsonExprFinder' => true)); @@ -595,19 +597,19 @@ public function testEncodingMultipleNestedIteratedSameNameKeysWithDifferentJsonE { $data = array( 0 => array( - "alpha" => "alpha" + 'alpha' => 'alpha' ), 1 => array( - "alpha" => "beta", + 'alpha' => 'beta', ), 2 => array( - "alpha" => new Zend_Json_Expr("gamma"), + 'alpha' => new Zend_Json_Expr('gamma'), ), 3 => array( - "alpha" => "delta", + 'alpha' => 'delta', ), 4 => array( - "alpha" => new Zend_Json_Expr("epsilon"), + 'alpha' => new Zend_Json_Expr('epsilon'), ) ); $result = Zend_Json::encode($data, false, array('enableJsonExprFinder' => true)); @@ -621,8 +623,8 @@ public function testDisabledJsonExprFinder() $data = array( 0 => array( - "alpha" => new Zend_Json_Expr("function(){}"), - "beta" => "gamma", + 'alpha' => new Zend_Json_Expr('function(){}'), + 'beta' => 'gamma', ), ); $result = Zend_Json::encode($data); @@ -638,7 +640,7 @@ public function testDisabledJsonExprFinder() */ public function testEncodeWithUtf8IsTransformedToPackedSyntax() { - $data = array("Отмена"); + $data = array('Отмена'); $result = Zend_Json_Encoder::encode($data); $this->assertEquals('["\u041e\u0442\u043c\u0435\u043d\u0430"]', $result); @@ -705,7 +707,7 @@ public function testDecodeUnicodeStringSolarRegression() */ public function testEncodeWithUtf8IsTransformedSolarRegressionEqualsJsonExt() { - if(function_exists('json_encode') == false) { + if(function_exists('json_encode') === false) { $this->markTestSkipped('Test can only be run, when ext/json is installed.'); } @@ -725,7 +727,7 @@ public function testEncodeWithUtf8IsTransformedSolarRegressionEqualsJsonExt() */ public function testUtf8JsonExprFinder() { - $data = array("Отмена" => new Zend_Json_Expr("foo")); + $data = array('Отмена' => new Zend_Json_Expr('foo')); Zend_Json::$useBuiltinEncoderDecoder = true; $result = Zend_Json::encode($data, false, array('enableJsonExprFinder' => true)); @@ -743,12 +745,12 @@ public function testKommaDecimalIsConvertedToCorrectJsonWithDot() { $localeInfo = localeconv(); if($localeInfo['decimal_point'] != ",") { - $this->markTestSkipped("This test only works for platforms where , is the decimal point separator."); + $this->markTestSkipped('This test only works for platforms where , is the decimal point separator.'); } Zend_Json::$useBuiltinEncoderDecoder = true; - $this->assertEquals("[1.20, 1.68]", Zend_Json_Encoder::encode(array( - (float)"1,20", (float)"1,68" + $this->assertEquals('[1.20, 1.68]', Zend_Json_Encoder::encode(array( + (float)'1,20', (float)'1,68' ))); } @@ -782,7 +784,7 @@ public function testEncodeObjectImplementingIteratorAggregate() */ public function testNativeJsonEncoderWillProperlyEncodeSolidusInStringValues() { - $source = "bar"; + $source = 'bar'; $target = '"<\\/foo>bar<\\/foo>"'; // first test ext/json @@ -795,7 +797,7 @@ public function testNativeJsonEncoderWillProperlyEncodeSolidusInStringValues() */ public function testBuiltinJsonEncoderWillProperlyEncodeSolidusInStringValues() { - $source = "bar"; + $source = 'bar'; $target = '"<\\/foo>bar<\\/foo>"'; // first test ext/json @@ -833,7 +835,7 @@ public function testEncoderEscapesNamespacedClassNamesProperly() $this->markTestSkipped('Namespaces not available in PHP < 5.3.0'); } - require_once dirname(__FILE__ ) . "/Json/_files/ZF11356-NamespacedClass.php"; + require_once __DIR__ . '/Json/_files/ZF11356-NamespacedClass.php'; $className = '\Zend\JsonTest\ZF11356\NamespacedClass'; $inputValue = new $className(array('foo')); diff --git a/tests/Zend/LoaderTest.php b/tests/Zend/LoaderTest.php index 5b717c27f..da044dbc7 100644 --- a/tests/Zend/LoaderTest.php +++ b/tests/Zend/LoaderTest.php @@ -45,6 +45,17 @@ */ class Zend_LoaderTest extends PHPUnit_Framework_TestCase { + /** + * @var array + */ + private $loaders; + /** + * @var string + */ + private $includePath; + private $error; + private $errorHandler; + /** * Runs the test methods of this class. * @@ -118,7 +129,7 @@ public function handleErrors($errno, $errstr) */ public function testLoaderClassValid() { - $dir = implode(array(dirname(__FILE__), '_files', '_testDir1'), DIRECTORY_SEPARATOR); + $dir = implode(DIRECTORY_SEPARATOR, array(__DIR__, '_files', '_testDir1')); Zend_Loader::loadClass('Class1', $dir); } @@ -126,15 +137,15 @@ public function testLoaderClassValid() public function testLoaderInterfaceViaLoadClass() { $includePath = get_include_path(); - set_include_path(implode(array( + set_include_path(implode(PATH_SEPARATOR, array( $includePath, - implode(array( - dirname(dirname(dirname(__FILE__))), + implode(DIRECTORY_SEPARATOR, array( + dirname(dirname(__DIR__)), 'packages', 'zend-controller', 'library', - ), DIRECTORY_SEPARATOR) - ), PATH_SEPARATOR)); + )) + ))); try { Zend_Loader::loadClass('Zend_Controller_Dispatcher_Interface'); @@ -162,7 +173,7 @@ public function testLoaderLoadClassWithDotDir() */ public function testLoaderClassNonexistent() { - $dir = implode(array(dirname(__FILE__), '_files', '_testDir1'), DIRECTORY_SEPARATOR); + $dir = implode(DIRECTORY_SEPARATOR, array(__DIR__, '_files', '_testDir1')); try { Zend_Loader::loadClass('ClassNonexistent', $dir); @@ -193,7 +204,7 @@ public function testLoaderClassSearchDirs() { $dirs = array(); foreach (array('_testDir1', '_testDir2') as $dir) { - $dirs[] = implode(array(dirname(__FILE__), '_files', $dir), DIRECTORY_SEPARATOR); + $dirs[] = implode(DIRECTORY_SEPARATOR, array(__DIR__, '_files', $dir)); } // throws exception on failure @@ -202,13 +213,13 @@ public function testLoaderClassSearchDirs() } /** - * Tests that a class locatedin a subdirectory can be loaded from the search directories + * Tests that a class located in a subdirectory can be loaded from the search directories */ public function testLoaderClassSearchSubDirs() { $dirs = array(); foreach (array('_testDir1', '_testDir2') as $dir) { - $dirs[] = implode(array(dirname(__FILE__), '_files', $dir), DIRECTORY_SEPARATOR); + $dirs[] = implode(DIRECTORY_SEPARATOR, array(__DIR__, '_files', $dir)); } // throws exception on failure @@ -234,7 +245,7 @@ public function testLoaderClassIllegalFilename() public function testLoaderFileIncludePathEmptyDirs() { $saveIncludePath = get_include_path(); - set_include_path(implode(array($saveIncludePath, implode(array(dirname(__FILE__), '_files', '_testDir1'), DIRECTORY_SEPARATOR)), PATH_SEPARATOR)); + set_include_path(implode(PATH_SEPARATOR, array($saveIncludePath, implode(DIRECTORY_SEPARATOR, array(__DIR__, '_files', '_testDir1'))))); $this->assertTrue(Zend_Loader::loadFile('Class3.php', null)); @@ -248,7 +259,7 @@ public function testLoaderFileIncludePathEmptyDirs() public function testLoaderFileIncludePathNonEmptyDirs() { $saveIncludePath = get_include_path(); - set_include_path(implode(array($saveIncludePath, implode(array(dirname(__FILE__), '_files', '_testDir1'), DIRECTORY_SEPARATOR)), PATH_SEPARATOR)); + set_include_path(implode(PATH_SEPARATOR, array($saveIncludePath, implode(DIRECTORY_SEPARATOR, array(__DIR__, '_files', '_testDir1'))))); $this->assertTrue(Zend_Loader::loadFile('Class4.php', implode(PATH_SEPARATOR, array('foo', 'bar')))); @@ -261,15 +272,15 @@ public function testLoaderFileIncludePathNonEmptyDirs() public function testLoaderIsReadable() { $includePath = get_include_path(); - set_include_path(implode(array( + set_include_path(implode(PATH_SEPARATOR, array( $includePath, - implode(array( - dirname(dirname(dirname(__FILE__))), + implode(DIRECTORY_SEPARATOR, array( + dirname(dirname(__DIR__)), 'packages', 'zend-controller', 'library', - ), DIRECTORY_SEPARATOR) - ), PATH_SEPARATOR)); + )) + ))); $this->assertTrue(Zend_Loader::isReadable(__FILE__)); $this->assertFalse(Zend_Loader::isReadable(__FILE__ . '.foobaar')); @@ -284,21 +295,21 @@ public function testLoaderIsReadable() public function testLoaderAutoloadLoadsValidClasses() { $includePath = get_include_path(); - set_include_path(implode(array( + set_include_path(implode(PATH_SEPARATOR, array( $includePath, - implode(array( - dirname(dirname(dirname(__FILE__))), + implode(DIRECTORY_SEPARATOR, array( + dirname(dirname(__DIR__)), 'packages', 'zend-db', 'library', - ), DIRECTORY_SEPARATOR), - implode(array( - dirname(dirname(dirname(__FILE__))), + )), + implode(DIRECTORY_SEPARATOR, array( + dirname(dirname(__DIR__)), 'packages', 'zend-auth', 'library', - ), DIRECTORY_SEPARATOR), - ), PATH_SEPARATOR)); + )), + ))); $this->setErrorHandler(); $this->assertEquals('Zend_Db_Profiler_Exception', Zend_Loader::autoload('Zend_Db_Profiler_Exception')); @@ -321,7 +332,7 @@ public function testLoaderAutoloadFailsOnInvalidClasses() public function testLoaderRegisterAutoloadRegisters() { if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload not installed on this PHP installation"); + $this->markTestSkipped('spl_autoload not installed on this PHP installation'); } $this->setErrorHandler(); @@ -340,13 +351,13 @@ public function testLoaderRegisterAutoloadRegisters() } } } - $this->assertTrue($found, "Failed to register Zend_Loader_Autoloader with spl_autoload"); + $this->assertTrue($found, 'Failed to register Zend_Loader_Autoloader with spl_autoload'); } public function testLoaderRegisterAutoloadExtendedClassNeedsAutoloadMethod() { if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload not installed on this PHP installation"); + $this->markTestSkipped('spl_autoload not installed on this PHP installation'); } $this->setErrorHandler(); @@ -362,7 +373,7 @@ public function testLoaderRegisterAutoloadExtendedClassNeedsAutoloadMethod() break; } } - $this->assertFalse($found, "Failed to register Zend_Loader_MyLoader::autoload() with spl_autoload"); + $this->assertFalse($found, 'Failed to register Zend_Loader_MyLoader::autoload() with spl_autoload'); spl_autoload_unregister($expected); } @@ -370,7 +381,7 @@ public function testLoaderRegisterAutoloadExtendedClassNeedsAutoloadMethod() public function testLoaderRegisterAutoloadExtendedClassWithAutoloadMethod() { if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload not installed on this PHP installation"); + $this->markTestSkipped('spl_autoload not installed on this PHP installation'); } $this->setErrorHandler(); @@ -388,12 +399,11 @@ public function testLoaderRegisterAutoloadExtendedClassWithAutoloadMethod() } } } - $this->assertTrue($found, "Failed to register Zend_Loader_Autoloader with spl_autoload"); + $this->assertTrue($found, 'Failed to register Zend_Loader_Autoloader with spl_autoload'); $autoloaders = Zend_Loader_Autoloader::getInstance()->getAutoloaders(); - $found = false; $expected = array('Zend_Loader_MyOverloader', 'autoload'); - $this->assertTrue(in_array($expected, $autoloaders, true), 'Failed to register My_Loader_MyOverloader with Zend_Loader_Autoloader: ' . var_export($autoloaders, 1)); + $this->assertContains($expected, $autoloaders, 'Failed to register My_Loader_MyOverloader with Zend_Loader_Autoloader: ' . var_export($autoloaders, 1)); // try to instantiate a class that is known not to be loaded $obj = new Zend_Loader_AutoloadableClass(); @@ -412,7 +422,7 @@ public function testLoaderRegisterAutoloadExtendedClassWithAutoloadMethod() public function testLoaderRegisterAutoloadFailsWithoutSplAutoload() { if (function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload() is installed on this PHP installation; cannot test for failure"); + $this->markTestSkipped('spl_autoload() is installed on this PHP installation; cannot test for failure'); } try { @@ -425,7 +435,7 @@ public function testLoaderRegisterAutoloadFailsWithoutSplAutoload() public function testLoaderRegisterAutoloadInvalidClass() { if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload() not installed on this PHP installation"); + $this->markTestSkipped('spl_autoload() not installed on this PHP installation'); } $this->setErrorHandler(); @@ -441,7 +451,7 @@ public function testLoaderRegisterAutoloadInvalidClass() public function testLoaderUnregisterAutoload() { if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload() not installed on this PHP installation"); + $this->markTestSkipped('spl_autoload() not installed on this PHP installation'); } $this->setErrorHandler(); @@ -450,11 +460,11 @@ public function testLoaderUnregisterAutoload() $expected = array('Zend_Loader_MyOverloader', 'autoload'); $autoloaders = Zend_Loader_Autoloader::getInstance()->getAutoloaders(); - $this->assertTrue(in_array($expected, $autoloaders, true), 'Failed to register autoloader'); + $this->assertContains($expected, $autoloaders, 'Failed to register autoloader'); Zend_Loader::registerAutoload('Zend_Loader_MyOverloader', false); $autoloaders = Zend_Loader_Autoloader::getInstance()->getAutoloaders(); - $this->assertFalse(in_array($expected, $autoloaders, true), 'Failed to unregister autoloader'); + $this->assertNotContains($expected, $autoloaders, 'Failed to unregister autoloader'); foreach (spl_autoload_functions() as $function) { if (is_array($function)) { @@ -473,7 +483,7 @@ public function testLoaderUnregisterAutoload() public function testRegisterAutoloadShouldEnableZendLoaderAutoloaderAsFallbackAutoloader() { if (!function_exists('spl_autoload_register')) { - $this->markTestSkipped("spl_autoload() not installed on this PHP installation"); + $this->markTestSkipped('spl_autoload() not installed on this PHP installation'); } $this->setErrorHandler(); @@ -502,7 +512,7 @@ public function testLoadClassShouldAllowLoadingPhpNamespacedClasses() if (version_compare(PHP_VERSION, '5.3.0') < 0) { $this->markTestSkipped('PHP < 5.3.0 does not support namespaces'); } - Zend_Loader::loadClass('\Zfns\Foo', array(dirname(__FILE__) . '/Loader/_files')); + Zend_Loader::loadClass('\Zfns\Foo', array(__DIR__ . '/Loader/_files')); } /** @@ -515,7 +525,7 @@ public function testIsReadableShouldHonorStreamDefinitions() $this->markTestSkipped(); } - $pharFile = dirname(__FILE__) . '/Loader/_files/Zend_LoaderTest.phar'; + $pharFile = __DIR__ . '/Loader/_files/Zend_LoaderTest.phar'; $phar = new Phar($pharFile, 0, 'zlt.phar'); $incPath = 'phar://zlt.phar' . PATH_SEPARATOR . $this->includePath; @@ -533,7 +543,7 @@ public function testIsReadableShouldNotLockWhenTestingForNonExistantFileInPhar() $this->markTestSkipped(); } - $pharFile = dirname(__FILE__) . '/Loader/_files/Zend_LoaderTest.phar'; + $pharFile = __DIR__ . '/Loader/_files/Zend_LoaderTest.phar'; $phar = new Phar($pharFile, 0, 'zlt.phar'); $incPath = 'phar://zlt.phar' . PATH_SEPARATOR . $this->includePath; @@ -566,8 +576,8 @@ public function testExplodeIncludePathProperlyIdentifiesStreamSchemes() */ public function testIsReadableShouldReturnTrueForAbsolutePaths() { - set_include_path(dirname(__FILE__) . '../../'); - $path = dirname(__FILE__); + set_include_path(__DIR__ . '../../'); + $path = __DIR__; $this->assertTrue(Zend_Loader::isReadable($path)); } diff --git a/tests/Zend/Paginator/_files/test.sqlite b/tests/Zend/Paginator/_files/test.sqlite index dcc8551842eafc19edcdb4ad90c869d195a2caab..483687c679ef7d84e48c489302c225ee303f6080 100644 GIT binary patch delta 47 vcmZn&Xb6}fCB)&%z`(!-#8AMjHBrZi4JfK7vteUOfbzr%2AiKK%dh|d!_EoN delta 48 wcmZn&Xb6}fCB%M|fq{Vwh@pV#)kGa5HlV2PBl(Rf0m_rNs2gm4qAbG#001ov4gdfE diff --git a/tests/Zend/Queue/Adapter/AdapterTest.php b/tests/Zend/Queue/Adapter/AdapterTest.php index 2a32c3b06..b8661825a 100644 --- a/tests/Zend/Queue/Adapter/AdapterTest.php +++ b/tests/Zend/Queue/Adapter/AdapterTest.php @@ -689,7 +689,7 @@ public function testVisibility() // keep in mind that some queue services are on forigen machines and need network time. if (false) { // easy comment/uncomment, set to true or false - $this->markTestSkipped('Visibility testing takes ' . $default_timeout+$extra_delay . ' seconds per adapter, if you wish to test this, uncomment the test case in ' . __FILE__ . ' line ' . __LINE__); + $this->markTestSkipped('Visibility testing takes ' . ($default_timeout + $extra_delay) . ' seconds per adapter, if you wish to test this, uncomment the test case in ' . __FILE__ . ' line ' . __LINE__); return; } diff --git a/tests/Zend/Server/Reflection/ClassTest.php b/tests/Zend/Server/Reflection/ClassTest.php index 7bd028533..264019059 100644 --- a/tests/Zend/Server/Reflection/ClassTest.php +++ b/tests/Zend/Server/Reflection/ClassTest.php @@ -55,7 +55,7 @@ public function test__construct() $this->assertEquals('', $r->getNamespace()); $methods = $r->getMethods(); - $this->assertTrue(is_array($methods)); + $this->assertInternalType('array', $methods); foreach ($methods as $m) { $this->assertTrue($m instanceof Zend_Server_Reflection_Method); } @@ -78,7 +78,7 @@ public function test__construct() public function test__call() { $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection')); - $this->assertTrue(is_string($r->getName())); + $this->assertInternalType('string', $r->getName()); $this->assertEquals('Zend_Server_Reflection', $r->getName()); } @@ -104,7 +104,7 @@ public function testGetMethods() $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection')); $methods = $r->getMethods(); - $this->assertTrue(is_array($methods)); + $this->assertInternalType('array', $methods); foreach ($methods as $m) { $this->assertTrue($m instanceof Zend_Server_Reflection_Method); } @@ -131,6 +131,9 @@ public function testGetNamespace() public function test__wakeup() { $r = new Zend_Server_Reflection_Class(new ReflectionClass('Zend_Server_Reflection')); + if (PHP_VERSION_ID >= 70400) { + $this->setExpectedException('Exception', "Serialization of 'ReflectionMethod' is not allowed"); + } $s = serialize($r); $u = unserialize($s); @@ -140,6 +143,6 @@ public function test__wakeup() $rMethods = $r->getMethods(); $uMethods = $r->getMethods(); - $this->assertEquals(count($rMethods), count($uMethods)); + $this->assertCount(count($rMethods), $uMethods); } } diff --git a/tests/Zend/Server/Reflection/FunctionTest.php b/tests/Zend/Server/Reflection/FunctionTest.php index 8ee202b13..d266f0a9a 100644 --- a/tests/Zend/Server/Reflection/FunctionTest.php +++ b/tests/Zend/Server/Reflection/FunctionTest.php @@ -53,11 +53,11 @@ public function test__construct() $argv = array('string1', 'string2'); $r = new Zend_Server_Reflection_Function($function, 'namespace', $argv); - $this->assertTrue(is_array($r->getInvokeArguments())); - $this->assertTrue($argv === $r->getInvokeArguments()); + $this->assertInternalType('array', $r->getInvokeArguments()); + $this->assertSame($argv, $r->getInvokeArguments()); $prototypes = $r->getPrototypes(); - $this->assertTrue(is_array($prototypes)); + $this->assertInternalType('array', $prototypes); $this->assertTrue(0 < count($prototypes)); } @@ -95,9 +95,9 @@ public function testGetPrototypes() $r = new Zend_Server_Reflection_Function($function); $prototypes = $r->getPrototypes(); - $this->assertTrue(is_array($prototypes)); + $this->assertInternalType('array', $prototypes); $this->assertTrue(0 < count($prototypes)); - $this->assertEquals(8, count($prototypes)); + $this->assertCount(8, $prototypes); foreach ($prototypes as $p) { $this->assertTrue($p instanceof Zend_Server_Reflection_Prototype); @@ -110,9 +110,9 @@ public function testGetPrototypes2() $r = new Zend_Server_Reflection_Function($function); $prototypes = $r->getPrototypes(); - $this->assertTrue(is_array($prototypes)); + $this->assertInternalType('array', $prototypes); $this->assertTrue(0 < count($prototypes)); - $this->assertEquals(1, count($prototypes)); + $this->assertCount(1, $prototypes); foreach ($prototypes as $p) { $this->assertTrue($p instanceof Zend_Server_Reflection_Prototype); @@ -125,21 +125,24 @@ public function testGetInvokeArguments() $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function'); $r = new Zend_Server_Reflection_Function($function); $args = $r->getInvokeArguments(); - $this->assertTrue(is_array($args)); - $this->assertEquals(0, count($args)); + $this->assertInternalType('array', $args); + $this->assertCount(0, $args); $argv = array('string1', 'string2'); $r = new Zend_Server_Reflection_Function($function, null, $argv); $args = $r->getInvokeArguments(); - $this->assertTrue(is_array($args)); - $this->assertEquals(2, count($args)); - $this->assertTrue($argv === $args); + $this->assertInternalType('array', $args); + $this->assertCount(2, $args); + $this->assertSame($argv, $args); } public function test__wakeup() { $function = new ReflectionFunction('Zend_Server_Reflection_FunctionTest_function'); $r = new Zend_Server_Reflection_Function($function); + if (PHP_VERSION_ID >= 70400) { + $this->setExpectedException('Exception', "Serialization of 'ReflectionFunction' is not allowed"); + } $s = serialize($r); $u = unserialize($s); $this->assertTrue($u instanceof Zend_Server_Reflection_Function); @@ -152,14 +155,14 @@ public function testMultipleWhitespaceBetweenDoctagsAndTypes() $r = new Zend_Server_Reflection_Function($function); $prototypes = $r->getPrototypes(); - $this->assertTrue(is_array($prototypes)); + $this->assertInternalType('array', $prototypes); $this->assertTrue(0 < count($prototypes)); - $this->assertEquals(1, count($prototypes)); + $this->assertCount(1, $prototypes); $proto = $prototypes[0]; $params = $proto->getParameters(); - $this->assertTrue(is_array($params)); - $this->assertEquals(1, count($params)); + $this->assertInternalType('array', $params); + $this->assertCount(1, $params); $this->assertEquals('string', $params[0]->getType()); } diff --git a/tests/Zend/Server/Reflection/MethodTest.php b/tests/Zend/Server/Reflection/MethodTest.php index 8ff0e5077..97bdb4d4d 100644 --- a/tests/Zend/Server/Reflection/MethodTest.php +++ b/tests/Zend/Server/Reflection/MethodTest.php @@ -84,7 +84,7 @@ public function testGetDeclaringClass() $class = $r->getDeclaringClass(); $this->assertTrue($class instanceof Zend_Server_Reflection_Class); - $this->assertTrue($this->_class === $class); + $this->assertSame($this->_class, $class); } /** @@ -97,6 +97,9 @@ public function testGetDeclaringClass() public function test__wakeup() { $r = new Zend_Server_Reflection_Method($this->_class, $this->_method); + if (PHP_VERSION_ID >= 70400) { + $this->setExpectedException('Exception', "Serialization of 'ReflectionMethod' is not allowed"); + } $s = serialize($r); $u = unserialize($s); diff --git a/tests/Zend/Wildfire/WildfireTest.php b/tests/Zend/Wildfire/WildfireTest.php index fb833ee2a..40b3b2bed 100644 --- a/tests/Zend/Wildfire/WildfireTest.php +++ b/tests/Zend/Wildfire/WildfireTest.php @@ -65,9 +65,9 @@ class Zend_Wildfire_WildfireTest extends PHPUnit_Framework_TestCase { - protected $_controller = null; - protected $_request = null; - protected $_response = null; + protected $_controller; + protected $_request; + protected $_response; /** * Runs the test methods of this class. @@ -77,7 +77,7 @@ class Zend_Wildfire_WildfireTest extends PHPUnit_Framework_TestCase */ public static function main() { - $suite = new PHPUnit_Framework_TestSuite("Zend_Wildfire_WildfireTest"); + $suite = new PHPUnit_Framework_TestSuite('Zend_Wildfire_WildfireTest'); $result = PHPUnit_TextUI_TestRunner::run($suite); } @@ -101,7 +101,7 @@ protected function _setupWithFrontController() $this->_response = new Zend_Wildfire_WildfireTest_Response(); $this->_controller = Zend_Controller_Front::getInstance(); $this->_controller->resetInstance(); - $this->_controller->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files') + $this->_controller->setControllerDirectory(__DIR__ . DIRECTORY_SEPARATOR . '_files') ->setRequest($this->_request) ->setResponse($this->_response) ->setParam('noErrorHandler', true) @@ -568,10 +568,10 @@ public function testTableMessage2() Zend_Wildfire_Plugin_FirePhp::send($table); $cell = new ArrayObject(); - $cell->append("item1"); - $cell->append("item2"); + $cell->append('item1'); + $cell->append('item2'); - $table->addRow(array("row1", $cell)); + $table->addRow(array('row1', $cell)); Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush(); @@ -742,7 +742,7 @@ public function testChannelInstanciation() $this->_setupWithoutFrontController(); try { Zend_Wildfire_Channel_HttpHeaders::getInstance(); - Zend_Wildfire_Channel_HttpHeaders::init(null); + Zend_Wildfire_Channel_HttpHeaders::init(); $this->fail('Should not be able to re-initialize'); } catch (Exception $e) { // success @@ -1079,9 +1079,9 @@ public function testFileLineOffsets() $messages = $protocol->getMessages(); $messages = $messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI]; - for( $i=0 ; $ifail("File and line does not match for message number: " . ($i+1)); + $this->fail('File and line does not match for message number: ' . ($i+1)); } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index c179e84af..cc3e62d2a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,7 +4,7 @@ */ error_reporting(E_ALL | E_STRICT); -$rootDir = dirname(dirname(__FILE__)); +$rootDir = dirname(__DIR__); /** * Setup autoloading From f7b09a705276d08f0052e4b3599663cbb90f139c Mon Sep 17 00:00:00 2001 From: Alexander Wozniak Date: Fri, 13 Dec 2019 09:01:03 +0100 Subject: [PATCH 2/4] Switched Travis to stable PHP7.4 --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index af165b0ab..20f66c8a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,7 @@ jobs: - php: 7.1 - php: 7.2 - php: 7.3 - - php: 7.4snapshot - allow_failures: - - php: 7.4snapshot + - php: 7.4 fast_finish: true env: From f347cce110be33be968e33de038cf28e5adaccc3 Mon Sep 17 00:00:00 2001 From: Alexander Wozniak Date: Sat, 14 Dec 2019 01:49:10 +0100 Subject: [PATCH 3/4] Removed nonsense from Zend_Crypt_Math::rand The method returned random bytes if /dev/urandom exists even though a random integer was expected. --- packages/zend-crypt/library/Zend/Crypt/Math.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/zend-crypt/library/Zend/Crypt/Math.php b/packages/zend-crypt/library/Zend/Crypt/Math.php index 8717c959a..183490d14 100644 --- a/packages/zend-crypt/library/Zend/Crypt/Math.php +++ b/packages/zend-crypt/library/Zend/Crypt/Math.php @@ -46,13 +46,6 @@ class Zend_Crypt_Math extends Zend_Crypt_Math_BigInteger */ public function rand($minimum, $maximum) { - if (file_exists('/dev/urandom')) { - $frandom = fopen('/dev/urandom', 'r'); - if ($frandom !== false) { - # I don't know how this could've ever worked if you're expecting an integer output - #return fread($frandom, strlen($maximum) - 1); - } - } if (strlen($maximum) < 4) { return mt_rand($minimum, $maximum - 1); } From 0a90bec1eea528462fd9100a0f8fa4749b1679af Mon Sep 17 00:00:00 2001 From: Alexander Wozniak Date: Sat, 14 Dec 2019 10:57:52 +0100 Subject: [PATCH 4/4] Fixed test as PHP7.4 produces a different error message --- tests/Zend/Db/Statement/TestCommon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Zend/Db/Statement/TestCommon.php b/tests/Zend/Db/Statement/TestCommon.php index 73da6d105..0500f6541 100644 --- a/tests/Zend/Db/Statement/TestCommon.php +++ b/tests/Zend/Db/Statement/TestCommon.php @@ -847,7 +847,7 @@ public function testStatementGetSetAttribute() try { $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #1"); } catch (Zend_Exception $e) { - $this->assertContains('This driver doesn\'t support getting attributes', $e->getMessage()); + $this->assertContains('driver doesn\'t support getting', $e->getMessage()); return; }