diff --git a/composer.json b/composer.json
index 1fbb9fcf43..1607de5b15 100644
--- a/composer.json
+++ b/composer.json
@@ -1,16 +1,16 @@
{
"name": "mobtitude/zendframework1",
- "description": "Zend Framework 1 fork compatible with PHP 7.2 by Mobtitude",
+ "description": "Zend Framework 1 fork compatible with PHP 8.1 by Mobtitude",
"type": "library",
"keywords": [
"framework",
"zf1",
- "php-7.2"
+ "php-8.1"
],
"homepage": "https://github.com/mobtitude/zendframework1",
"license": "BSD-3-Clause",
"require": {
- "php": ">=5.2.2"
+ "php": "^8.1"
},
"autoload": {
"psr-0": {
@@ -29,6 +29,7 @@
}
},
"require-dev": {
+ "rector/rector": "^0.12.17",
"phpunit/phpunit": "3.7.*",
"phpunit/dbunit": "1.3.*"
},
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000000..451e0638f9
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,14 @@
+version: '3'
+services:
+ php-qa:
+ image: psfoundation/code-quality
+ working_dir: /project
+ volumes:
+ - ./:/project
+ - ~/.ssh:/root/.ssh
+ builder:
+ image: psfoundation/webapp-builder:1.0.13-php8.1
+ working_dir: /project
+ volumes:
+ - ./:/project
+ - ~/.ssh:/root/.ssh
diff --git a/library/Zend/Acl.php b/library/Zend/Acl.php
index a5d169f56a..8052641a71 100644
--- a/library/Zend/Acl.php
+++ b/library/Zend/Acl.php
@@ -223,11 +223,7 @@ public function removeRole($role)
{
$this->_getRoleRegistry()->remove($role);
- if ($role instanceof Zend_Acl_Role_Interface) {
- $roleId = $role->getRoleId();
- } else {
- $roleId = $role;
- }
+ $roleId = $role instanceof Zend_Acl_Role_Interface ? $role->getRoleId() : $role;
foreach ($this->_rules['allResources']['byRoleId'] as $roleIdCurrent => $rules) {
if ($roleId === $roleIdCurrent) {
@@ -302,11 +298,7 @@ public function addResource($resource, $parent = null)
if (null !== $parent) {
try {
- if ($parent instanceof Zend_Acl_Resource_Interface) {
- $resourceParentId = $parent->getResourceId();
- } else {
- $resourceParentId = $parent;
- }
+ $resourceParentId = $parent instanceof Zend_Acl_Resource_Interface ? $parent->getResourceId() : $parent;
$resourceParent = $this->get($resourceParentId);
} catch (Zend_Acl_Exception $e) {
require_once 'Zend/Acl/Exception.php';
@@ -354,11 +346,7 @@ public function add(Zend_Acl_Resource_Interface $resource, $parent = null)
*/
public function get($resource)
{
- if ($resource instanceof Zend_Acl_Resource_Interface) {
- $resourceId = $resource->getResourceId();
- } else {
- $resourceId = (string) $resource;
- }
+ $resourceId = $resource instanceof Zend_Acl_Resource_Interface ? $resource->getResourceId() : (string) $resource;
if (!$this->has($resource)) {
require_once 'Zend/Acl/Exception.php';
@@ -378,11 +366,7 @@ public function get($resource)
*/
public function has($resource)
{
- if ($resource instanceof Zend_Acl_Resource_Interface) {
- $resourceId = $resource->getResourceId();
- } else {
- $resourceId = (string) $resource;
- }
+ $resourceId = $resource instanceof Zend_Acl_Resource_Interface ? $resource->getResourceId() : (string) $resource;
return isset($this->_resources[$resourceId]);
}
@@ -416,7 +400,7 @@ public function inherits($resource, $inherit, $onlyParent = false)
$parentId = $this->_resources[$resourceId]['parent']->getResourceId();
if ($inheritId === $parentId) {
return true;
- } else if ($onlyParent) {
+ } elseif ($onlyParent) {
return false;
}
} else {
@@ -480,7 +464,7 @@ public function remove($resource)
*/
public function removeAll()
{
- foreach ($this->_resources as $resourceId => $resource) {
+ foreach (array_keys($this->_resources) as $resourceId) {
foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $rules) {
if ($resourceId === $resourceIdCurrent) {
unset($this->_rules['byResourceId'][$resourceIdCurrent]);
@@ -617,17 +601,13 @@ public function setRule($operation, $type, $roles = null, $resources = null, $pr
// ensure that all specified Roles exist; normalize input to array of Role objects or null
if (!is_array($roles)) {
$roles = array($roles);
- } else if (0 === count($roles)) {
+ } elseif ([] === $roles) {
$roles = array(null);
}
$rolesTemp = $roles;
$roles = array();
foreach ($rolesTemp as $role) {
- if (null !== $role) {
- $roles[] = $this->_getRoleRegistry()->get($role);
- } else {
- $roles[] = null;
- }
+ $roles[] = null !== $role ? $this->_getRoleRegistry()->get($role) : null;
}
unset($rolesTemp);
@@ -635,17 +615,13 @@ public function setRule($operation, $type, $roles = null, $resources = null, $pr
if ($resources !== null) {
if (!is_array($resources)) {
$resources = array($resources);
- } else if (0 === count($resources)) {
+ } elseif ([] === $resources) {
$resources = array(null);
}
$resourcesTemp = $resources;
$resources = array();
foreach ($resourcesTemp as $resource) {
- if (null !== $resource) {
- $resources[] = $this->get($resource);
- } else {
- $resources[] = null;
- }
+ $resources[] = null !== $resource ? $this->get($resource) : null;
}
unset($resourcesTemp, $resource);
} else {
@@ -659,7 +635,7 @@ public function setRule($operation, $type, $roles = null, $resources = null, $pr
// normalize privileges to array
if (null === $privileges) {
$privileges = array();
- } else if (!is_array($privileges)) {
+ } elseif (!is_array($privileges)) {
$privileges = array($privileges);
}
@@ -672,7 +648,7 @@ public function setRule($operation, $type, $roles = null, $resources = null, $pr
foreach ($resources as $resource) {
foreach ($roles as $role) {
$rules =& $this->_getRules($resource, $role, true);
- if (0 === count($privileges)) {
+ if ([] === $privileges) {
$rules['allPrivileges']['type'] = $type;
$rules['allPrivileges']['assert'] = $assert;
if (!isset($rules['byPrivilegeId'])) {
@@ -690,7 +666,7 @@ public function setRule($operation, $type, $roles = null, $resources = null, $pr
// this block will apply to all resources in a global rule
foreach ($roles as $role) {
$rules =& $this->_getRules(null, $role, true);
- if (0 === count($privileges)) {
+ if ([] === $privileges) {
$rules['allPrivileges']['type'] = $type;
$rules['allPrivileges']['assert'] = $assert;
} else {
@@ -713,7 +689,7 @@ public function setRule($operation, $type, $roles = null, $resources = null, $pr
if (null === $rules) {
continue;
}
- if (0 === count($privileges)) {
+ if ([] === $privileges) {
if (null === $resource && null === $role) {
if ($type === $rules['allPrivileges']['type']) {
$rules = array(
@@ -756,7 +732,7 @@ public function setRule($operation, $type, $roles = null, $resources = null, $pr
if (null === $rules) {
continue;
}
- if (0 === count($privileges)) {
+ if ([] === $privileges) {
if (null === $role) {
if ($type === $rules['allPrivileges']['type']) {
$rules = array(
@@ -853,7 +829,7 @@ public function isAllowed($role = null, $resource = null, $privilege = null)
// query on all privileges
do {
// depth-first search on $role if it is not 'allRoles' pseudo-parent
- if (null !== $role && null !== ($result = $this->_roleDFSAllPrivileges($role, $resource, $privilege))) {
+ if (null !== $role && null !== ($result = $this->_roleDFSAllPrivileges($role, $resource))) {
return $result;
}
@@ -885,7 +861,7 @@ public function isAllowed($role = null, $resource = null, $privilege = null)
// look for rule on 'allRoles' pseudo-parent
if (null !== ($ruleType = $this->_getRuleType($resource, null, $privilege))) {
return self::TYPE_ALLOW === $ruleType;
- } else if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, null, null))) {
+ } elseif (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, null, null))) {
return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
}
@@ -935,10 +911,8 @@ protected function _roleDFSAllPrivileges(Zend_Acl_Role_Interface $role, Zend_Acl
}
while (null !== ($role = array_pop($dfs['stack']))) {
- if (!isset($dfs['visited'][$role->getRoleId()])) {
- if (null !== ($result = $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs))) {
- return $result;
- }
+ if (!isset($dfs['visited'][$role->getRoleId()]) && null !== ($result = $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs))) {
+ return $result;
}
}
@@ -1023,10 +997,8 @@ protected function _roleDFSOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_
}
while (null !== ($role = array_pop($dfs['stack']))) {
- if (!isset($dfs['visited'][$role->getRoleId()])) {
- if (null !== ($result = $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs))) {
- return $result;
- }
+ if (!isset($dfs['visited'][$role->getRoleId()]) && null !== ($result = $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs))) {
+ return $result;
}
}
@@ -1069,7 +1041,7 @@ protected function _roleDFSVisitOnePrivilege(Zend_Acl_Role_Interface $role, Zend
if (null !== ($ruleTypeOnePrivilege = $this->_getRuleType($resource, $role, $privilege))) {
return self::TYPE_ALLOW === $ruleTypeOnePrivilege;
- } else if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, $role, null))) {
+ } elseif (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, $role, null))) {
return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
}
@@ -1117,7 +1089,7 @@ protected function _getRuleType(Zend_Acl_Resource_Interface $resource = null, Ze
} else {
return null;
}
- } else if (!isset($rules['byPrivilegeId'][$privilege])) {
+ } elseif (!isset($rules['byPrivilegeId'][$privilege])) {
return null;
} else {
$rule = $rules['byPrivilegeId'][$privilege];
@@ -1136,9 +1108,9 @@ protected function _getRuleType(Zend_Acl_Resource_Interface $resource = null, Ze
if (null === $rule['assert'] || $assertionValue) {
return $rule['type'];
- } else if (null !== $resource || null !== $role || null !== $privilege) {
+ } elseif (null !== $resource || null !== $role || null !== $privilege) {
return null;
- } else if (self::TYPE_ALLOW === $rule['type']) {
+ } elseif (self::TYPE_ALLOW === $rule['type']) {
return self::TYPE_DENY;
} else {
return self::TYPE_ALLOW;
diff --git a/library/Zend/Acl/Role/Registry.php b/library/Zend/Acl/Role/Registry.php
index d9d57f3379..e3ec45c199 100644
--- a/library/Zend/Acl/Role/Registry.php
+++ b/library/Zend/Acl/Role/Registry.php
@@ -84,11 +84,7 @@ public function add(Zend_Acl_Role_Interface $role, $parents = null)
require_once 'Zend/Acl/Role/Registry/Exception.php';
foreach ($parents as $parent) {
try {
- if ($parent instanceof Zend_Acl_Role_Interface) {
- $roleParentId = $parent->getRoleId();
- } else {
- $roleParentId = $parent;
- }
+ $roleParentId = $parent instanceof Zend_Acl_Role_Interface ? $parent->getRoleId() : $parent;
$roleParent = $this->get($roleParentId);
} catch (Zend_Acl_Role_Registry_Exception $e) {
throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist", 0, $e);
@@ -118,11 +114,7 @@ public function add(Zend_Acl_Role_Interface $role, $parents = null)
*/
public function get($role)
{
- if ($role instanceof Zend_Acl_Role_Interface) {
- $roleId = $role->getRoleId();
- } else {
- $roleId = (string) $role;
- }
+ $roleId = $role instanceof Zend_Acl_Role_Interface ? $role->getRoleId() : (string) $role;
if (!$this->has($role)) {
/**
@@ -145,11 +137,7 @@ public function get($role)
*/
public function has($role)
{
- if ($role instanceof Zend_Acl_Role_Interface) {
- $roleId = $role->getRoleId();
- } else {
- $roleId = (string) $role;
- }
+ $roleId = $role instanceof Zend_Acl_Role_Interface ? $role->getRoleId() : (string) $role;
return isset($this->_roles[$roleId]);
}
diff --git a/library/Zend/Amf/Parse/Amf0/Deserializer.php b/library/Zend/Amf/Parse/Amf0/Deserializer.php
index 6d8fa7f55d..a8e5090e02 100644
--- a/library/Zend/Amf/Parse/Amf0/Deserializer.php
+++ b/library/Zend/Amf/Parse/Amf0/Deserializer.php
@@ -238,8 +238,7 @@ public function readDate()
$offset = $this->_stream->readInt();
require_once 'Zend/Date.php';
- $date = new Zend_Date($timestamp);
- return $date;
+ return new Zend_Date($timestamp);
}
/**
@@ -272,7 +271,7 @@ public function readTypedObject()
$returnObject = new $loader();
$properties = get_object_vars($this->readObject());
foreach($properties as $key=>$value) {
- if($key) {
+ if($key !== '' && $key !== '0') {
$returnObject->$key = $value;
}
}
diff --git a/library/Zend/Amf/Parse/Amf0/Serializer.php b/library/Zend/Amf/Parse/Amf0/Serializer.php
index 0a578c1291..e5e6fb3fd2 100644
--- a/library/Zend/Amf/Parse/Amf0/Serializer.php
+++ b/library/Zend/Amf/Parse/Amf0/Serializer.php
@@ -157,14 +157,14 @@ public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
$i = 0;
foreach (array_keys($data) as $key) {
// check if it contains non-integer keys
- if (!is_numeric($key) || intval($key) != $key) {
+ if (!is_numeric($key) || (int) $key != $key) {
$markerType = Zend_Amf_Constants::AMF0_OBJECT;
break;
// check if it is a sparse indexed array
- } else if ($key != $i) {
- $markerType = Zend_Amf_Constants::AMF0_MIXEDARRAY;
- break;
- }
+ } elseif ($key != $i) {
+ $markerType = Zend_Amf_Constants::AMF0_MIXEDARRAY;
+ break;
+ }
$i++;
}
// Dealing with a standard numeric array
@@ -337,7 +337,7 @@ protected function getClassName($object)
$className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object));
break;
// Check to see if the user has defined an explicit Action Script type.
- case isset($object->_explicitType):
+ case property_exists($object, '_explicitType') && $object->_explicitType !== null:
$className = $object->_explicitType;
break;
// Check if user has defined a method for accessing the Action Script type
diff --git a/library/Zend/Amf/Parse/Amf3/Deserializer.php b/library/Zend/Amf/Parse/Amf3/Deserializer.php
index 9bcc272af3..20d9e74056 100644
--- a/library/Zend/Amf/Parse/Amf3/Deserializer.php
+++ b/library/Zend/Amf/Parse/Amf3/Deserializer.php
@@ -183,7 +183,7 @@ public function readString()
//Check if this is a reference string
if (($stringReference & 0x01) == 0) {
// reference string
- $stringReference = $stringReference >> 1;
+ $stringReference >>= 1;
if ($stringReference >= count($this->_referenceStrings)) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Undefined string reference: ' . $stringReference);
@@ -193,7 +193,7 @@ public function readString()
}
$length = $stringReference >> 1;
- if ($length) {
+ if ($length !== 0) {
$string = $this->_stream->readBytes($length);
$this->_referenceStrings[] = $string;
} else {
@@ -217,7 +217,7 @@ public function readDate()
{
$dateReference = $this->readInteger();
if (($dateReference & 0x01) == 0) {
- $dateReference = $dateReference >> 1;
+ $dateReference >>= 1;
if ($dateReference>=count($this->_referenceObjects)) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Undefined date reference: ' . $dateReference);
@@ -244,7 +244,7 @@ public function readArray()
{
$arrayReference = $this->readInteger();
if (($arrayReference & 0x01)==0){
- $arrayReference = $arrayReference >> 1;
+ $arrayReference >>= 1;
if ($arrayReference>=count($this->_referenceObjects)) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Unknow array reference: ' . $arrayReference);
@@ -263,7 +263,7 @@ public function readArray()
$key = $this->readString();
}
- $arrayReference = $arrayReference >>1;
+ $arrayReference >>= 1;
//We have a dense array
for ($i=0; $i < $arrayReference; $i++) {
@@ -283,7 +283,7 @@ public function readObject()
{
$traitsInfo = $this->readInteger();
$storedObject = ($traitsInfo & 0x01)==0;
- $traitsInfo = $traitsInfo >> 1;
+ $traitsInfo >>= 1;
// Check if the Object is in the stored Objects reference table
if ($storedObject) {
@@ -296,7 +296,7 @@ public function readObject()
} else {
// Check if the Object is in the stored Definitions reference table
$storedClass = ($traitsInfo & 0x01) == 0;
- $traitsInfo = $traitsInfo >> 1;
+ $traitsInfo >>= 1;
if ($storedClass) {
$ref = $traitsInfo;
if (!isset($this->_referenceDefinitions[$ref])) {
@@ -313,23 +313,19 @@ public function readObject()
$className = $this->readString();
$encoding = $traitsInfo & 0x03;
$propertyNames = array();
- $traitsInfo = $traitsInfo >> 2;
+ $traitsInfo >>= 2;
}
// We now have the object traits defined in variables. Time to go to work:
if (!$className) {
// No class name generic object
$returnObject = new stdClass();
+ } elseif ($loader = Zend_Amf_Parse_TypeLoader::loadType($className)) {
+ $returnObject = new $loader();
} else {
- // Defined object
- // Typed object lookup against registered classname maps
- if ($loader = Zend_Amf_Parse_TypeLoader::loadType($className)) {
- $returnObject = new $loader();
- } else {
- //user defined typed object
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Typed object not found: '. $className . ' ');
- }
+ //user defined typed object
+ require_once 'Zend/Amf/Exception.php';
+ throw new Zend_Amf_Exception('Typed object not found: '. $className . ' ');
}
// Add the Object to the reference table
@@ -365,7 +361,7 @@ public function readObject()
$propertyNames[] = $property;
$properties[$property] = $this->readTypeMarker();
}
- } while ($property !="");
+ } while ($property != "");
break;
default:
// basic property list object.
@@ -399,7 +395,7 @@ public function readObject()
}
if ($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
- if (isset($returnObject->externalizedData)) {
+ if (property_exists($returnObject, 'externalizedData') && $returnObject->externalizedData !== null) {
$returnObject = $returnObject->externalizedData;
} else {
$returnObject = get_object_vars($returnObject);
diff --git a/library/Zend/Amf/Parse/Amf3/Serializer.php b/library/Zend/Amf/Parse/Amf3/Serializer.php
index 3ce47b7f7c..ada3cc7692 100644
--- a/library/Zend/Amf/Parse/Amf3/Serializer.php
+++ b/library/Zend/Amf/Parse/Amf3/Serializer.php
@@ -132,11 +132,7 @@ public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
$markerType = Zend_Amf_Constants::AMF3_NULL;
break;
case (is_bool($data)):
- if ($data){
- $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_TRUE;
- } else {
- $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_FALSE;
- }
+ $markerType = $data ? Zend_Amf_Constants::AMF3_BOOLEAN_TRUE : Zend_Amf_Constants::AMF3_BOOLEAN_FALSE;
break;
case (is_int($data)):
if (($data > 0xFFFFFFF) || ($data < -268435456)) {
@@ -158,9 +154,9 @@ public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
// Handle object types.
if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
$markerType = Zend_Amf_Constants::AMF3_DATE;
- } else if ($data instanceof Zend_Amf_Value_ByteArray) {
+ } elseif ($data instanceof Zend_Amf_Value_ByteArray) {
$markerType = Zend_Amf_Constants::AMF3_BYTEARRAY;
- } else if (($data instanceof DOMDocument) || ($data instanceof SimpleXMLElement)) {
+ } elseif (($data instanceof DOMDocument) || ($data instanceof SimpleXMLElement)) {
$markerType = Zend_Amf_Constants::AMF3_XMLSTRING;
} else {
$markerType = Zend_Amf_Constants::AMF3_OBJECT;
@@ -231,7 +227,7 @@ protected function writeBinaryString(&$string){
public function writeString(&$string)
{
$len = $this->_mbStringFunctionsOverloaded ? mb_strlen($string, '8bit') : strlen($string);
- if(!$len){
+ if($len === 0){
$this->writeInteger(0x01);
return $this;
}
@@ -264,7 +260,7 @@ public function writeByteArray(&$data)
if (is_string($data)) {
//nothing to do
- } else if ($data instanceof Zend_Amf_Value_ByteArray) {
+ } elseif ($data instanceof Zend_Amf_Value_ByteArray) {
$data = $data->getData();
} else {
require_once 'Zend/Amf/Exception.php';
@@ -288,11 +284,11 @@ public function writeXml($xml)
return $this;
}
- if(is_string($xml)) {
+ if (is_string($xml)) {
//nothing to do
- } else if ($xml instanceof DOMDocument) {
+ } elseif ($xml instanceof DOMDocument) {
$xml = $xml->saveXml();
- } else if ($xml instanceof SimpleXMLElement) {
+ } elseif ($xml instanceof SimpleXMLElement) {
$xml = $xml->asXML();
} else {
require_once 'Zend/Amf/Exception.php';
@@ -424,7 +420,7 @@ public function writeObject($object)
break;
// Check to see if the user has defined an explicit Action Script type.
- case isset($object->_explicitType):
+ case property_exists($object, '_explicitType') && $object->_explicitType !== null:
$className = $object->_explicitType;
break;
diff --git a/library/Zend/Amf/Parse/TypeLoader.php b/library/Zend/Amf/Parse/TypeLoader.php
index 40003b5779..e550884b13 100644
--- a/library/Zend/Amf/Parse/TypeLoader.php
+++ b/library/Zend/Amf/Parse/TypeLoader.php
@@ -94,7 +94,7 @@ final class Zend_Amf_Parse_TypeLoader
public static function loadType($className)
{
$class = self::getMappedClassName($className);
- if(!$class) {
+ if($class === '' || $class === '0') {
$class = str_replace('.', '_', $className);
}
if (!class_exists($class)) {
@@ -206,7 +206,7 @@ public static function handleResource($resource)
try {
while(is_resource($resource)) {
$resclass = self::getResourceParser($resource);
- if(!$resclass) {
+ if($resclass === '' || $resclass === '0') {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource));
}
diff --git a/library/Zend/Amf/Request.php b/library/Zend/Amf/Request.php
index c5da936ef0..6fcbae9b24 100644
--- a/library/Zend/Amf/Request.php
+++ b/library/Zend/Amf/Request.php
@@ -153,9 +153,7 @@ public function readHeader()
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Unable to parse ' . $name . ' header data: ' . $e->getMessage() . ' '. $e->getLine(), 0, $e);
}
-
- $header = new Zend_Amf_Value_MessageHeader($name, $mustRead, $data, $length);
- return $header;
+ return new Zend_Amf_Value_MessageHeader($name, $mustRead, $data, $length);
}
/**
@@ -190,9 +188,7 @@ public function readBody()
// set the encoding so we return our message in AMF3
$this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
}
-
- $body = new Zend_Amf_Value_MessageBody($targetURI, $responseURI, $data);
- return $body;
+ return new Zend_Amf_Value_MessageBody($targetURI, $responseURI, $data);
}
/**
diff --git a/library/Zend/Amf/Response/Http.php b/library/Zend/Amf/Response/Http.php
index e4a52937e5..b022f0d7eb 100644
--- a/library/Zend/Amf/Response/Http.php
+++ b/library/Zend/Amf/Response/Http.php
@@ -63,11 +63,7 @@ protected function isIeOverSsl()
}
$ua = $_SERVER['HTTP_USER_AGENT'];
- if (!preg_match('/; MSIE \d+\.\d+;/', (string) $ua)) {
- // Not MicroSoft Internet Explorer
- return false;
- }
-
- return true;
+ // Not MicroSoft Internet Explorer
+ return (bool) preg_match('/; MSIE \d+\.\d+;/', (string) $ua);
}
}
diff --git a/library/Zend/Amf/Server.php b/library/Zend/Amf/Server.php
index 68bca7899e..be0d049f5d 100644
--- a/library/Zend/Amf/Server.php
+++ b/library/Zend/Amf/Server.php
@@ -258,15 +258,13 @@ protected function _checkAcl($object, $function)
}
$auth = Zend_Auth::getInstance();
- if($auth->hasIdentity()) {
+ if ($auth->hasIdentity()) {
$role = $auth->getIdentity()->role;
+ } elseif ($this->_acl->hasRole(Zend_Amf_Constants::GUEST_ROLE)) {
+ $role = Zend_Amf_Constants::GUEST_ROLE;
} else {
- if($this->_acl->hasRole(Zend_Amf_Constants::GUEST_ROLE)) {
- $role = Zend_Amf_Constants::GUEST_ROLE;
- } else {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception("Unauthenticated access not allowed");
- }
+ require_once 'Zend/Amf/Server/Exception.php';
+ throw new Zend_Amf_Server_Exception("Unauthenticated access not allowed");
}
if($this->_acl->isAllowed($role, $class, $function)) {
return true;
@@ -301,10 +299,8 @@ protected function getLoader()
*/
protected function _dispatch($method, $params = null, $source = null)
{
- if($source) {
- if(($mapped = Zend_Amf_Parse_TypeLoader::getMappedClassName($source)) !== false) {
- $source = $mapped;
- }
+ if($source && ($mapped = Zend_Amf_Parse_TypeLoader::getMappedClassName($source)) !== false) {
+ $source = $mapped;
}
$qualifiedName = empty($source) ? $method : $source . '.' . $method;
@@ -477,7 +473,7 @@ protected function _handleAuth( $userid, $password)
// authentication failed, good bye
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception(
- "Authentication failed: " . join("\n",
+ "Authentication failed: " . implode("\n",
$result->getMessages()), $result->getCode());
}
@@ -507,8 +503,8 @@ protected function _handle(Zend_Amf_Request $request)
$error = false;
$headers = $request->getAmfHeaders();
if (isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER])
- && isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid)
- && isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->password)
+ && (property_exists($headers[Zend_Amf_Constants::CREDENTIALS_HEADER], 'userid') && $headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid !== null)
+ && (property_exists($headers[Zend_Amf_Constants::CREDENTIALS_HEADER], 'password') && $headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->password !== null)
) {
try {
if ($this->_handleAuth(
@@ -561,7 +557,7 @@ protected function _handle(Zend_Amf_Request $request)
// Split the target string into its values.
$source = substr($targetURI, 0, strrpos($targetURI, '.'));
- if ($source) {
+ if ($source !== '' && $source !== '0') {
// Break off method name from namespace into source
$method = substr(strrchr($targetURI, '.'), 1);
$return = $this->_dispatch($method, $body->getData(), $source);
@@ -588,7 +584,7 @@ protected function _handle(Zend_Amf_Request $request)
// Split the target string into its values.
$source = substr($targetURI, 0, strrpos($targetURI, '.'));
- if ($source) {
+ if ($source !== '' && $source !== '0') {
// Break off method name from namespace into source
$method = substr(strrchr($targetURI, '.'), 1);
$return = $this->_dispatch($method, $body->getData(), $source);
@@ -614,12 +610,8 @@ protected function _handle(Zend_Amf_Request $request)
if($this->isSession()) {
$currentID = session_id();
$joint = "?";
- if(isset($_SERVER['QUERY_STRING'])) {
- if(!strpos($_SERVER['QUERY_STRING'], $currentID) !== FALSE) {
- if(strrpos($_SERVER['QUERY_STRING'], "?") !== FALSE) {
- $joint = "&";
- }
- }
+ if(isset($_SERVER['QUERY_STRING']) && !strpos($_SERVER['QUERY_STRING'], $currentID) && strrpos($_SERVER['QUERY_STRING'], "?") !== FALSE) {
+ $joint = "&";
}
// create a new AMF message header with the session id as a variable.
@@ -641,16 +633,14 @@ protected function _handle(Zend_Amf_Request $request)
public function handle($request = null)
{
// Check if request was passed otherwise get it from the server
- if ($request === null || !$request instanceof Zend_Amf_Request) {
+ if (!$request instanceof \Zend_Amf_Request || !$request instanceof Zend_Amf_Request) {
$request = $this->getRequest();
} else {
$this->setRequest($request);
}
- if ($this->isSession()) {
- // Check if a session is being sent from the amf call
- if (isset($_COOKIE[$this->_sessionName])) {
- session_id($_COOKIE[$this->_sessionName]);
- }
+ // Check if a session is being sent from the amf call
+ if ($this->isSession() && isset($_COOKIE[$this->_sessionName])) {
+ session_id($_COOKIE[$this->_sessionName]);
}
// Check for errors that may have happend in deserialization of Request.
diff --git a/library/Zend/Amf/Value/MessageBody.php b/library/Zend/Amf/Value/MessageBody.php
index 59cacba52b..b8bc05672f 100644
--- a/library/Zend/Amf/Value/MessageBody.php
+++ b/library/Zend/Amf/Value/MessageBody.php
@@ -176,7 +176,7 @@ public function setReplyMethod($methodName)
if (!preg_match('#^[/?]#', $methodName)) {
$this->_targetUri = rtrim($this->_targetUri, '/') . '/';
}
- $this->_targetUri = $this->_targetUri . $methodName;
+ $this->_targetUri .= $methodName;
return $this;
}
}
diff --git a/library/Zend/Application.php b/library/Zend/Application.php
index 5ddee7ddaa..1f4498d531 100644
--- a/library/Zend/Application.php
+++ b/library/Zend/Application.php
@@ -89,8 +89,7 @@ public function __construct($environment, $options = null, $suppressNotFoundWarn
$options = $options->toArray();
} elseif (!is_array($options)) {
throw new Zend_Application_Exception(
- 'Invalid options provided; must be location of config file,'
- . ' a config object, or an array'
+ 'Invalid options provided; must be location of config file, a config object, or an array'
);
}
@@ -166,9 +165,9 @@ public function setOptions(array $options)
$autoloader = $this->getAutoloader();
if (method_exists($autoloader, 'setZfPath')) {
$zfPath = $options['autoloaderzfpath'];
- $zfVersion = !empty($options['autoloaderzfversion'])
- ? $options['autoloaderzfversion']
- : 'latest';
+ $zfVersion = empty($options['autoloaderzfversion'])
+ ? 'latest'
+ : $options['autoloaderzfversion'];
$autoloader->setZfPath($zfPath, $zfVersion);
}
}
@@ -341,8 +340,7 @@ public function setBootstrap($path, $class = null)
if (!$this->_bootstrap instanceof Zend_Application_Bootstrap_Bootstrapper) {
throw new Zend_Application_Exception(
- 'Bootstrap class does not implement'
- . ' Zend_Application_Bootstrap_Bootstrapper'
+ 'Bootstrap class does not implement Zend_Application_Bootstrap_Bootstrapper'
);
}
@@ -422,8 +420,7 @@ protected function _loadConfig($file)
$config = include $file;
if (!is_array($config)) {
throw new Zend_Application_Exception(
- 'Invalid configuration file provided; PHP file does not'
- . ' return array value'
+ 'Invalid configuration file provided; PHP file does not return array value'
);
}
return $config;
diff --git a/library/Zend/Application/Bootstrap/BootstrapAbstract.php b/library/Zend/Application/Bootstrap/BootstrapAbstract.php
index 444fe0ca85..e15cdd414c 100644
--- a/library/Zend/Application/Bootstrap/BootstrapAbstract.php
+++ b/library/Zend/Application/Bootstrap/BootstrapAbstract.php
@@ -719,7 +719,7 @@ protected function _loadPluginResource($resource, $options)
$options['bootstrap'] = $this;
$className = $this->getPluginLoader()->load(strtolower($resource), false);
- if (!$className) {
+ if ($className === '' || $className === '0') {
return false;
}
@@ -727,7 +727,7 @@ protected function _loadPluginResource($resource, $options)
unset($this->_pluginResources[$resource]);
- if (isset($instance->_explicitType)) {
+ if (property_exists($instance, '_explicitType') && $instance->_explicitType !== null) {
$resource = $instance->_explicitType;
}
$resource = strtolower($resource);
@@ -764,7 +764,7 @@ protected function _markRun($resource)
*/
protected function _resolvePluginResourceName($resource)
{
- if (isset($resource->_explicitType)) {
+ if (property_exists($resource, '_explicitType') && $resource->_explicitType !== null) {
$pluginName = $resource->_explicitType;
} else {
$className = get_class($resource);
@@ -778,7 +778,6 @@ protected function _resolvePluginResourceName($resource)
}
}
}
- $pluginName = strtolower($pluginName);
- return $pluginName;
+ return strtolower($pluginName);
}
}
diff --git a/library/Zend/Application/Module/Bootstrap.php b/library/Zend/Application/Module/Bootstrap.php
index 1373891cc4..f3752c6d2f 100644
--- a/library/Zend/Application/Module/Bootstrap.php
+++ b/library/Zend/Application/Module/Bootstrap.php
@@ -115,11 +115,7 @@ public function getModuleName()
{
if (empty($this->_moduleName)) {
$class = get_class($this);
- if (preg_match('/^([a-z][a-z0-9]*)_/i', $class, $matches)) {
- $prefix = $matches[1];
- } else {
- $prefix = $class;
- }
+ $prefix = preg_match('/^([a-z][a-z0-9]*)_/i', $class, $matches) ? $matches[1] : $class;
$this->_moduleName = $prefix;
}
return $this->_moduleName;
diff --git a/library/Zend/Application/Resource/Db.php b/library/Zend/Application/Resource/Db.php
index 4c7c720e5c..e4dfa90040 100644
--- a/library/Zend/Application/Resource/Db.php
+++ b/library/Zend/Application/Resource/Db.php
@@ -185,7 +185,7 @@ public function setDefaultMetadataCache($cache)
$metadataCache = $cacheManager->getCache($cache);
}
}
- } else if ($cache instanceof Zend_Cache_Core) {
+ } elseif ($cache instanceof Zend_Cache_Core) {
$metadataCache = $cache;
}
diff --git a/library/Zend/Application/Resource/Mail.php b/library/Zend/Application/Resource/Mail.php
index fc9036a81f..694261a878 100644
--- a/library/Zend/Application/Resource/Mail.php
+++ b/library/Zend/Application/Resource/Mail.php
@@ -133,8 +133,7 @@ protected function _setupTransport($options)
case 'Zend_Mail_Transport_Smtp':
if (!isset($options['host'])) {
throw new Zend_Application_Resource_Exception(
- 'A host is necessary for smtp transport,'
- . ' but none was given'
+ 'A host is necessary for smtp transport, but none was given'
);
}
diff --git a/library/Zend/Application/Resource/Modules.php b/library/Zend/Application/Resource/Modules.php
index 6106cfcad1..51e7ffb3c1 100644
--- a/library/Zend/Application/Resource/Modules.php
+++ b/library/Zend/Application/Resource/Modules.php
@@ -152,7 +152,6 @@ protected function _formatModuleName($name)
$name = strtolower($name);
$name = str_replace(array('-', '.'), ' ', $name);
$name = ucwords($name);
- $name = str_replace(' ', '', $name);
- return $name;
+ return str_replace(' ', '', $name);
}
}
diff --git a/library/Zend/Application/Resource/Multidb.php b/library/Zend/Application/Resource/Multidb.php
index a7a8c30d48..dc47945c84 100644
--- a/library/Zend/Application/Resource/Multidb.php
+++ b/library/Zend/Application/Resource/Multidb.php
@@ -197,7 +197,7 @@ protected function _setDefaultMetadataCache($cache)
$metadataCache = $cacheManager->getCache($cache);
}
}
- } else if ($cache instanceof Zend_Cache_Core) {
+ } elseif ($cache instanceof Zend_Cache_Core) {
$metadataCache = $cache;
}
diff --git a/library/Zend/Application/Resource/ResourceAbstract.php b/library/Zend/Application/Resource/ResourceAbstract.php
index 1f400eb9fb..4f266bb812 100644
--- a/library/Zend/Application/Resource/ResourceAbstract.php
+++ b/library/Zend/Application/Resource/ResourceAbstract.php
@@ -70,7 +70,7 @@ public function __construct($options = null)
{
if (is_array($options)) {
$this->setOptions($options);
- } else if ($options instanceof Zend_Config) {
+ } elseif ($options instanceof Zend_Config) {
$this->setOptions($options->toArray());
}
}
diff --git a/library/Zend/Application/Resource/Session.php b/library/Zend/Application/Resource/Session.php
index 9519fc7a42..35e666737d 100644
--- a/library/Zend/Application/Resource/Session.php
+++ b/library/Zend/Application/Resource/Session.php
@@ -108,7 +108,7 @@ public function init()
unset($options['savehandler']);
}
- if (count($options) > 0) {
+ if ($options !== []) {
Zend_Session::setOptions($options);
}
diff --git a/library/Zend/Application/Resource/Translate.php b/library/Zend/Application/Resource/Translate.php
index 5d9fc23d3c..db7648dc69 100644
--- a/library/Zend/Application/Resource/Translate.php
+++ b/library/Zend/Application/Resource/Translate.php
@@ -70,7 +70,7 @@ public function getTranslate()
if (!isset($options['content']) && !isset($options['data'])) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('No translation source data provided.');
- } else if (array_key_exists('content', $options) && array_key_exists('data', $options)) {
+ } elseif (array_key_exists('content', $options) && array_key_exists('data', $options)) {
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception(
'Conflict on translation source data: choose only one key between content and data.'
@@ -86,10 +86,8 @@ public function getTranslate()
unset($options['data']);
}
- if (isset($options['log'])) {
- if (is_array($options['log'])) {
- $options['log'] = Zend_Log::factory($options['log']);
- }
+ if (isset($options['log']) && is_array($options['log'])) {
+ $options['log'] = Zend_Log::factory($options['log']);
}
if (isset($options['options'])) {
diff --git a/library/Zend/Auth/Adapter/DbTable.php b/library/Zend/Auth/Adapter/DbTable.php
index a7f75d23ab..483d2642d1 100644
--- a/library/Zend/Auth/Adapter/DbTable.php
+++ b/library/Zend/Auth/Adapter/DbTable.php
@@ -275,8 +275,8 @@ public function setCredential($credential)
*/
public function setAmbiguityIdentity($flag)
{
- if (is_integer($flag)) {
- $this->_ambiguityIdentity = (1 === $flag ? true : false);
+ if (is_int($flag)) {
+ $this->_ambiguityIdentity = (1 === $flag);
} elseif (is_bool($flag)) {
$this->_ambiguityIdentity = $flag;
}
@@ -371,7 +371,7 @@ public function authenticate()
return $authResult;
}
- if (true === $this->getAmbiguityIdentity()) {
+ if ($this->getAmbiguityIdentity()) {
$validIdentities = array ();
$zendAuthCredentialMatchColumn = $this->_zendDb->foldCase('zend_auth_credential_match');
foreach ($resultIdentities as $identity) {
@@ -381,9 +381,7 @@ public function authenticate()
}
$resultIdentities = $validIdentities;
}
-
- $authResult = $this->_authenticateValidateResult(array_shift($resultIdentities));
- return $authResult;
+ return $this->_authenticateValidateResult(array_shift($resultIdentities));
}
/**
@@ -507,7 +505,7 @@ protected function _authenticateValidateResultSet(array $resultIdentities)
$this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
$this->_authenticateResultInfo['messages'][] = 'A record with the supplied identity could not be found.';
return $this->_authenticateCreateAuthResult();
- } elseif (count($resultIdentities) > 1 && false === $this->getAmbiguityIdentity()) {
+ } elseif (count($resultIdentities) > 1 && !$this->getAmbiguityIdentity()) {
$this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS;
$this->_authenticateResultInfo['messages'][] = 'More than one record matches the supplied identity.';
return $this->_authenticateCreateAuthResult();
diff --git a/library/Zend/Auth/Adapter/Http.php b/library/Zend/Auth/Adapter/Http.php
index 9ffebcad75..69cf53b435 100644
--- a/library/Zend/Auth/Adapter/Http.php
+++ b/library/Zend/Auth/Adapter/Http.php
@@ -234,18 +234,13 @@ public function __construct(array $config)
* @see Zend_Auth_Adapter_Exception
*/
require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Config key \'nonce_timeout\' is required, and must be an '
- . 'integer');
+ throw new Zend_Auth_Adapter_Exception('Config key \'nonce_timeout\' is required, and must be an integer');
} else {
$this->_nonceTimeout = (int) $config['nonce_timeout'];
}
// We use the opaque value unless explicitly told not to
- if (isset($config['use_opaque']) && false == (bool) $config['use_opaque']) {
- $this->_useOpaque = false;
- } else {
- $this->_useOpaque = true;
- }
+ $this->_useOpaque = isset($config['use_opaque']) && false == (bool) $config['use_opaque'] ? false : true;
if (isset($config['algorithm']) && in_array($config['algorithm'], $this->_supportedAlgos)) {
$this->_algo = $config['algorithm'];
@@ -368,15 +363,10 @@ public function authenticate()
* @see Zend_Auth_Adapter_Exception
*/
require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Request and Response objects must be set before calling '
- . 'authenticate()');
+ throw new Zend_Auth_Adapter_Exception('Request and Response objects must be set before calling authenticate()');
}
- if ($this->_imaProxy) {
- $getHeader = 'Proxy-Authorization';
- } else {
- $getHeader = 'Authorization';
- }
+ $getHeader = $this->_imaProxy ? 'Proxy-Authorization' : 'Authorization';
$authHeader = $this->_request->getHeader($getHeader);
if (!$authHeader) {
@@ -478,14 +468,12 @@ protected function _basicHeader()
*/
protected function _digestHeader()
{
- $wwwauth = 'Digest realm="' . $this->_realm . '", '
+ return 'Digest realm="' . $this->_realm . '", '
. 'domain="' . $this->_domains . '", '
. 'nonce="' . $this->_calcNonce() . '", '
. ($this->_useOpaque ? 'opaque="' . $this->_calcOpaque() . '", ' : '')
. 'algorithm="' . $this->_algo . '", '
. 'qop="' . implode(',', $this->_supportedQops) . '"';
-
- return $wwwauth;
}
/**
@@ -509,14 +497,13 @@ protected function _basicAuth($header)
* @see Zend_Auth_Adapter_Exception
*/
require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('A basicResolver object must be set before doing Basic '
- . 'authentication');
+ throw new Zend_Auth_Adapter_Exception('A basicResolver object must be set before doing Basic authentication');
}
// Decode the Authorization header
$auth = substr($header, strlen('Basic '));
$auth = base64_decode($auth);
- if (!$auth) {
+ if ($auth === '' || $auth === '0') {
/**
* @see Zend_Auth_Adapter_Exception
*/
@@ -664,9 +651,7 @@ protected function _calcNonce()
// nonce will change on its own, and effectively log the user out. This
// would be surprising if the user just logged in.
$timeout = ceil(time() / $this->_nonceTimeout) * $this->_nonceTimeout;
-
- $nonce = hash('md5', $timeout . ':' . $this->_request->getServer('HTTP_USER_AGENT') . ':' . __CLASS__);
- return $nonce;
+ return hash('md5', $timeout . ':' . $this->_request->getServer('HTTP_USER_AGENT') . ':' . __CLASS__);
}
/**
@@ -745,7 +730,7 @@ protected function _parseDigestAuth($header)
return false;
} else {
// Make sure the path portion of both URIs is the same
- if ($rUri['path'] != $cUri['path']) {
+ if ($rUri['path'] !== $cUri['path']) {
return false;
}
// Section 3.2.2.5 seems to suggest that the value of the URI
diff --git a/library/Zend/Auth/Adapter/Http/Resolver/File.php b/library/Zend/Auth/Adapter/Http/Resolver/File.php
index 8f8b64ce30..481b3a992f 100644
--- a/library/Zend/Auth/Adapter/Http/Resolver/File.php
+++ b/library/Zend/Auth/Adapter/Http/Resolver/File.php
@@ -117,13 +117,12 @@ public function resolve($username, $realm)
*/
require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username is required');
- } else if (!ctype_print($username) || strpos($username, ':') !== false) {
+ } elseif (!ctype_print($username) || strpos($username, ':') !== false) {
/**
* @see Zend_Auth_Adapter_Http_Resolver_Exception
*/
require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username must consist only of printable characters, '
- . 'excluding the colon');
+ throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username must consist only of printable characters, excluding the colon');
}
if (empty($realm)) {
/**
@@ -131,13 +130,12 @@ public function resolve($username, $realm)
*/
require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
throw new Zend_Auth_Adapter_Http_Resolver_Exception('Realm is required');
- } else if (!ctype_print($realm) || strpos($realm, ':') !== false) {
+ } elseif (!ctype_print($realm) || strpos($realm, ':') !== false) {
/**
* @see Zend_Auth_Adapter_Http_Resolver_Exception
*/
require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Realm must consist only of printable characters, '
- . 'excluding the colon.');
+ throw new Zend_Auth_Adapter_Http_Resolver_Exception('Realm must consist only of printable characters, excluding the colon.');
}
// Open file, read through looking for matching credentials
diff --git a/library/Zend/Auth/Adapter/Ldap.php b/library/Zend/Auth/Adapter/Ldap.php
index 1e8ea055ae..c914c4c172 100644
--- a/library/Zend/Auth/Adapter/Ldap.php
+++ b/library/Zend/Auth/Adapter/Ldap.php
@@ -255,12 +255,12 @@ public function authenticate()
$username = $this->_username;
$password = $this->_password;
- if (!$username) {
+ if ($username === '' || $username === '0') {
$code = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
$messages[0] = 'A username is required';
return new Zend_Auth_Result($code, '', $messages);
}
- if (!$password) {
+ if ($password === '' || $password === '0') {
/* A password is required because some servers will
* treat an empty password as an anonymous bind.
*/
@@ -333,7 +333,7 @@ public function authenticate()
$messages[0] = '';
$messages[1] = '';
$messages[] = "$canonicalName authentication successful";
- if ($requireRebind === true) {
+ if ($requireRebind) {
// rebinding with authenticated user
$ldap->bind($dn, $password);
}
@@ -353,21 +353,21 @@ public function authenticate()
$err = $zle->getCode();
if ($err == Zend_Ldap_Exception::LDAP_X_DOMAIN_MISMATCH) {
- /* This error indicates that the domain supplied in the
- * username did not match the domains in the server options
- * and therefore we should just skip to the next set of
- * server options.
- */
- continue;
- } else if ($err == Zend_Ldap_Exception::LDAP_NO_SUCH_OBJECT) {
- $code = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
- $messages[0] = "Account not found: $username";
- $failedAuthorities[$dname] = $zle->getMessage();
- } else if ($err == Zend_Ldap_Exception::LDAP_INVALID_CREDENTIALS) {
- $code = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
- $messages[0] = 'Invalid credentials';
- $failedAuthorities[$dname] = $zle->getMessage();
- } else {
+ /* This error indicates that the domain supplied in the
+ * username did not match the domains in the server options
+ * and therefore we should just skip to the next set of
+ * server options.
+ */
+ continue;
+ } elseif ($err == Zend_Ldap_Exception::LDAP_NO_SUCH_OBJECT) {
+ $code = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
+ $messages[0] = "Account not found: $username";
+ $failedAuthorities[$dname] = $zle->getMessage();
+ } elseif ($err == Zend_Ldap_Exception::LDAP_INVALID_CREDENTIALS) {
+ $code = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
+ $messages[0] = 'Invalid credentials';
+ $failedAuthorities[$dname] = $zle->getMessage();
+ } else {
$line = $zle->getLine();
$messages[] = $zle->getFile() . "($line): " . $zle->getMessage();
$messages[] = preg_replace(
@@ -446,11 +446,7 @@ protected function _checkGroupMembership(Zend_Ldap $ldap, $canonicalName, $dn, a
return true;
}
- if ($adapterOptions['memberIsDn'] === false) {
- $user = $canonicalName;
- } else {
- $user = $dn;
- }
+ $user = $adapterOptions['memberIsDn'] === false ? $canonicalName : $dn;
/**
* @see Zend_Ldap_Filter
@@ -485,7 +481,7 @@ protected function _checkGroupMembership(Zend_Ldap $ldap, $canonicalName, $dn, a
*/
public function getAccountObject(array $returnAttribs = array(), array $omitAttribs = array())
{
- if (!$this->_authenticatedDn) {
+ if ($this->_authenticatedDn === '' || $this->_authenticatedDn === '0') {
return false;
}
@@ -522,7 +518,7 @@ private function _optionsToString(array $options)
foreach ($options as $key => $val) {
if ($key === 'password')
$val = '*****';
- if ($str)
+ if ($str !== '' && $str !== '0')
$str .= ',';
$str .= $key . '=' . $val;
}
diff --git a/library/Zend/Auth/Adapter/OpenId.php b/library/Zend/Auth/Adapter/OpenId.php
index 9b886bba05..cf6f4733c3 100644
--- a/library/Zend/Auth/Adapter/OpenId.php
+++ b/library/Zend/Auth/Adapter/OpenId.php
@@ -246,17 +246,15 @@ public function authenticate() {
$id,
array("Authentication failed", $consumer->getError()));
}
- } else {
- if (!$consumer->check($id,
- $this->_returnTo,
- $this->_root,
- $this->_extensions,
- $this->_response)) {
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE,
- $id,
- array("Authentication failed", $consumer->getError()));
- }
+ } elseif (!$consumer->check($id,
+ $this->_returnTo,
+ $this->_root,
+ $this->_extensions,
+ $this->_response)) {
+ return new Zend_Auth_Result(
+ Zend_Auth_Result::FAILURE,
+ $id,
+ array("Authentication failed", $consumer->getError()));
}
} else {
$params = (isset($_SERVER['REQUEST_METHOD']) &&
diff --git a/library/Zend/Auth/Result.php b/library/Zend/Auth/Result.php
index 6f81a9a9e1..28e596edd9 100644
--- a/library/Zend/Auth/Result.php
+++ b/library/Zend/Auth/Result.php
@@ -110,7 +110,7 @@ public function __construct($code, $identity, array $messages = array())
*/
public function isValid()
{
- return ($this->_code > 0) ? true : false;
+ return $this->_code > 0;
}
/**
diff --git a/library/Zend/Auth/Storage/Session.php b/library/Zend/Auth/Storage/Session.php
index c3680f6faf..9abde003f4 100644
--- a/library/Zend/Auth/Storage/Session.php
+++ b/library/Zend/Auth/Storage/Session.php
@@ -113,7 +113,7 @@ public function getMember()
*/
public function isEmpty()
{
- return !isset($this->_session->{$this->_member});
+ return !(property_exists($this->_session, '_member') && $this->_session->{$this->_member} !== null);
}
/**
diff --git a/library/Zend/Barcode.php b/library/Zend/Barcode.php
index 6f7c386bc9..8f924afb77 100644
--- a/library/Zend/Barcode.php
+++ b/library/Zend/Barcode.php
@@ -66,20 +66,16 @@ public static function factory(
* barcode name and separate config object.
*/
if ($barcode instanceof Zend_Config) {
- if (isset($barcode->rendererParams)) {
+ if (property_exists($barcode, 'rendererParams') && $barcode->rendererParams !== null) {
$rendererConfig = $barcode->rendererParams->toArray();
}
- if (isset($barcode->renderer)) {
+ if (property_exists($barcode, 'renderer') && $barcode->renderer !== null) {
$renderer = (string) $barcode->renderer;
}
- if (isset($barcode->barcodeParams)) {
+ if (property_exists($barcode, 'barcodeParams') && $barcode->barcodeParams !== null) {
$barcodeConfig = $barcode->barcodeParams->toArray();
}
- if (isset($barcode->barcode)) {
- $barcode = (string) $barcode->barcode;
- } else {
- $barcode = null;
- }
+ $barcode = property_exists($barcode, 'barcode') && $barcode->barcode !== null ? (string) $barcode->barcode : null;
}
try {
@@ -119,14 +115,10 @@ public static function makeBarcode($barcode, $barcodeConfig = array())
* barcode name and separate config object.
*/
if ($barcode instanceof Zend_Config) {
- if (isset($barcode->barcodeParams) && $barcode->barcodeParams instanceof Zend_Config) {
+ if (property_exists($barcode, 'barcodeParams') && $barcode->barcodeParams !== null && $barcode->barcodeParams instanceof Zend_Config) {
$barcodeConfig = $barcode->barcodeParams->toArray();
}
- if (isset($barcode->barcode)) {
- $barcode = (string) $barcode->barcode;
- } else {
- $barcode = null;
- }
+ $barcode = property_exists($barcode, 'barcode') && $barcode->barcode !== null ? (string) $barcode->barcode : null;
}
if ($barcodeConfig instanceof Zend_Config) {
$barcodeConfig = $barcodeConfig->toArray();
@@ -218,10 +210,10 @@ public static function makeRenderer($renderer = 'image', $rendererConfig = array
* barcode name and separate config object.
*/
if ($renderer instanceof Zend_Config) {
- if (isset($renderer->rendererParams)) {
+ if (property_exists($renderer, 'rendererParams') && $renderer->rendererParams !== null) {
$rendererConfig = $renderer->rendererParams->toArray();
}
- if (isset($renderer->renderer)) {
+ if (property_exists($renderer, 'renderer') && $renderer->renderer !== null) {
$renderer = (string) $renderer->renderer;
}
}
diff --git a/library/Zend/Barcode/Object/Code128.php b/library/Zend/Barcode/Object/Code128.php
index 6292296ea2..507e94eff8 100644
--- a/library/Zend/Barcode/Object/Code128.php
+++ b/library/Zend/Barcode/Object/Code128.php
@@ -197,8 +197,7 @@ protected function _calculateBarcodeWidth()
$encodedData = $convertedChars * $characterLength;
// ...except the STOP character (13)
$encodedData += $characterLength + 2 * $this->_barThinWidth * $this->_factor;
- $width = $quietZone + $encodedData + $quietZone;
- return $width;
+ return $quietZone + $encodedData + $quietZone;
}
/**
@@ -266,7 +265,7 @@ protected static function _isDigit($string, $pos, $length = 2)
protected function _convertToBarcodeChars($string)
{
$string = (string) $string;
- if (!strlen($string)) {
+ if ($string === '') {
return array();
}
@@ -298,7 +297,7 @@ protected function _convertToBarcodeChars($string)
$result[] = $code;
$currentCharset = 'C';
}
- } else if (in_array($char, $this->_charSets['B']) && $currentCharset != 'B'
+ } elseif (in_array($char, $this->_charSets['B']) && $currentCharset != 'B'
&& !(in_array($char, $this->_charSets['A']) && $currentCharset == 'A')) {
/**
* Switch to B as B contains the char and B is not the current charset.
@@ -310,7 +309,7 @@ protected function _convertToBarcodeChars($string)
}
$result[] = $code;
$currentCharset = 'B';
- } else if (array_key_exists($char, $this->_charSets['A']) && $currentCharset != 'A'
+ } elseif (array_key_exists($char, $this->_charSets['A']) && $currentCharset != 'A'
&& !(array_key_exists($char, $this->_charSets['B']) && $currentCharset == 'B')) {
/**
* Switch to C as C contains the char and C is not the current charset.
@@ -375,9 +374,7 @@ public function getChecksum($text)
$sum += ($k++) * $char;
}
- $checksum = $sum % 103;
-
- return $checksum;
+ return $sum % 103;
}
/**
diff --git a/library/Zend/Barcode/Object/Code25.php b/library/Zend/Barcode/Object/Code25.php
index c55a4c5c04..f148b8a3f6 100644
--- a/library/Zend/Barcode/Object/Code25.php
+++ b/library/Zend/Barcode/Object/Code25.php
@@ -104,7 +104,7 @@ protected function _prepareBarcode()
$barcodeChar = str_split($this->_codingMap[$char]);
foreach ($barcodeChar as $c) {
/* visible, width, top, length */
- $width = $c ? $this->_barThickWidth : $this->_barThinWidth;
+ $width = $c !== '' && $c !== '0' ? $this->_barThickWidth : $this->_barThinWidth;
$barcodeTable[] = array(1 , $width , 0 , 1);
$barcodeTable[] = array(0 , $this->_barThinWidth);
}
@@ -132,12 +132,10 @@ 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;
}
- $checksum = (10 - ($checksum % 10)) % 10;
-
- return $checksum;
+ return (10 - ($checksum % 10)) % 10;
}
}
diff --git a/library/Zend/Barcode/Object/Code25interleaved.php b/library/Zend/Barcode/Object/Code25interleaved.php
index 8b606ceaaf..b54a42c01a 100644
--- a/library/Zend/Barcode/Object/Code25interleaved.php
+++ b/library/Zend/Barcode/Object/Code25interleaved.php
@@ -110,14 +110,14 @@ protected function _prepareBarcode()
// Interleave
for ($ibar = 0; $ibar < 5; $ibar ++) {
// Draws char1 bar (fore color)
- $barWidth = (substr($this->_codingMap[$char1], $ibar, 1))
+ $barWidth = (substr($this->_codingMap[$char1], $ibar, 1) !== '' && substr($this->_codingMap[$char1], $ibar, 1) !== '0')
? $this->_barThickWidth
: $this->_barThinWidth;
$barcodeTable[] = array(1, $barWidth, 0, 1);
// Left space corresponding to char2 (background color)
- $barWidth = (substr($this->_codingMap[$char2], $ibar, 1))
+ $barWidth = (substr($this->_codingMap[$char2], $ibar, 1) !== '' && substr($this->_codingMap[$char2], $ibar, 1) !== '0')
? $this->_barThickWidth
: $this->_barThinWidth;
$barcodeTable[] = array(0, $barWidth, 0 , 1);
diff --git a/library/Zend/Barcode/Object/Code39.php b/library/Zend/Barcode/Object/Code39.php
index ca4403d8cf..63f022ea06 100644
--- a/library/Zend/Barcode/Object/Code39.php
+++ b/library/Zend/Barcode/Object/Code39.php
@@ -159,7 +159,7 @@ protected function _prepareBarcode()
$visible = true;
foreach ($barcodeChar as $c) {
/* visible, width, top, length */
- $width = $c ? $this->_barThickWidth : $this->_barThinWidth;
+ $width = $c !== '' && $c !== '0' ? $this->_barThickWidth : $this->_barThinWidth;
$barcodeTable[] = array((int) $visible, $width, 0, 1);
$visible = ! $visible;
}
diff --git a/library/Zend/Barcode/Object/Ean13.php b/library/Zend/Barcode/Object/Ean13.php
index dfeb6782e7..a5ee19e7a1 100644
--- a/library/Zend/Barcode/Object/Ean13.php
+++ b/library/Zend/Barcode/Object/Ean13.php
@@ -166,13 +166,11 @@ 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;
}
- $checksum = (10 - ($checksum % 10)) % 10;
-
- return $checksum;
+ return (10 - ($checksum % 10)) % 10;
}
/**
@@ -181,7 +179,7 @@ public function getChecksum($text)
*/
protected function _drawText()
{
- if (get_class($this) == 'Zend_Barcode_Object_Ean13') {
+ if (get_class($this) === 'Zend_Barcode_Object_Ean13') {
$this->_drawEan13Text();
} else {
parent::_drawText();
diff --git a/library/Zend/Barcode/Object/Ean5.php b/library/Zend/Barcode/Object/Ean5.php
index 1f074ba077..a3e060a756 100644
--- a/library/Zend/Barcode/Object/Ean5.php
+++ b/library/Zend/Barcode/Object/Ean5.php
@@ -124,7 +124,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 !== 0 ? 9 : 3);
}
return ($checksum % 10);
diff --git a/library/Zend/Barcode/Object/Identcode.php b/library/Zend/Barcode/Object/Identcode.php
index cbb8f3ea35..a0fd17e305 100644
--- a/library/Zend/Barcode/Object/Identcode.php
+++ b/library/Zend/Barcode/Object/Identcode.php
@@ -57,7 +57,7 @@ protected function _getDefaultOptions()
*/
public function getTextToDisplay()
{
- return preg_replace('/([0-9]{2})([0-9]{3})([0-9]{3})([0-9]{3})([0-9])/',
+ return preg_replace('/(\d{2})(\d{3})(\d{3})(\d{3})(\d)/',
'$1.$2 $3.$4 $5',
$this->getText());
}
@@ -84,11 +84,9 @@ 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 !== 0) ? 4 : 9);
}
- $checksum = (10 - ($checksum % 10)) % 10;
-
- return $checksum;
+ return (10 - ($checksum % 10)) % 10;
}
}
diff --git a/library/Zend/Barcode/Object/Leitcode.php b/library/Zend/Barcode/Object/Leitcode.php
index 8646b97b25..69d7c6a23a 100644
--- a/library/Zend/Barcode/Object/Leitcode.php
+++ b/library/Zend/Barcode/Object/Leitcode.php
@@ -57,7 +57,7 @@ protected function _getDefaultOptions()
*/
public function getTextToDisplay()
{
- return preg_replace('/([0-9]{5})([0-9]{3})([0-9]{3})([0-9]{2})([0-9])/',
+ return preg_replace('/(\d{5})(\d{3})(\d{3})(\d{2})(\d)/',
'$1.$2.$3.$4 $5',
$this->getText());
}
diff --git a/library/Zend/Barcode/Object/ObjectAbstract.php b/library/Zend/Barcode/Object/ObjectAbstract.php
index 1285a0c3b8..083aaddca7 100644
--- a/library/Zend/Barcode/Object/ObjectAbstract.php
+++ b/library/Zend/Barcode/Object/ObjectAbstract.php
@@ -342,13 +342,13 @@ public function getType()
*/
public function setBarHeight($value)
{
- if (intval($value) <= 0) {
+ if ((int) $value <= 0) {
require_once 'Zend/Barcode/Object/Exception.php';
throw new Zend_Barcode_Object_Exception(
'Bar height must be greater than 0'
);
}
- $this->_barHeight = intval($value);
+ $this->_barHeight = (int) $value;
return $this;
}
@@ -371,13 +371,13 @@ public function getBarHeight()
*/
public function setBarThinWidth($value)
{
- if (intval($value) <= 0) {
+ if ((int) $value <= 0) {
require_once 'Zend/Barcode/Object/Exception.php';
throw new Zend_Barcode_Object_Exception(
'Bar width must be greater than 0'
);
}
- $this->_barThinWidth = intval($value);
+ $this->_barThinWidth = (int) $value;
return $this;
}
@@ -400,13 +400,13 @@ public function getBarThinWidth()
*/
public function setBarThickWidth($value)
{
- if (intval($value) <= 0) {
+ if ((int) $value <= 0) {
require_once 'Zend/Barcode/Object/Exception.php';
throw new Zend_Barcode_Object_Exception(
'Bar width must be greater than 0'
);
}
- $this->_barThickWidth = intval($value);
+ $this->_barThickWidth = (int) $value;
return $this;
}
@@ -424,7 +424,7 @@ public function getBarThickWidth()
* Set factor applying to
* thinBarWidth - thickBarWidth - barHeight - fontSize
*
- * @param int|float|string|bool $value
+ * @param scalar $value
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
@@ -463,7 +463,7 @@ public function setForeColor($value)
if (preg_match('`\#[0-9A-F]{6}`', $value)) {
$this->_foreColor = hexdec($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(
@@ -495,7 +495,7 @@ public function setBackgroundColor($value)
if (preg_match('`\#[0-9A-F]{6}`', (string) $value)) {
$this->_backgroundColor = hexdec($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(
@@ -576,7 +576,7 @@ public function setReverseColor()
/**
* Set orientation of barcode and text
*
- * @param int|float|string|bool $value
+ * @param scalar $value
* @return $this
* @throws Zend_Barcode_Object_Exception
*/
@@ -639,10 +639,8 @@ protected function _addLeadingZeros($text, $withoutChecksum = false)
if (strlen($text) < $length) {
$text = str_repeat('0', $length - strlen($text)) . $text;
}
- } else {
- if ($this->_barcodeLength == 'even') {
- $text = ((strlen($text) - $omitChecksum) % 2 ? '0' . $text : $text);
- }
+ } elseif ($this->_barcodeLength == 'even') {
+ $text = ((strlen($text) - $omitChecksum) % 2 !== 0 ? '0' . $text : $text);
}
}
return $text;
@@ -988,7 +986,7 @@ protected function _checkText($value = null)
if ($value === null) {
$value = $this->_text;
}
- if (!strlen($value)) {
+ if ((string) $value === '') {
require_once 'Zend/Barcode/Object/Exception.php';
throw new Zend_Barcode_Object_Exception(
'A text must be provide to Barcode before drawing'
@@ -1205,8 +1203,8 @@ protected function _rotate($x1, $y1)
+ $this->getOffsetTop();
return array(
- intval($x2),
- intval($y2)
+ (int) $x2,
+ (int) $y2
);
}
diff --git a/library/Zend/Barcode/Object/Postnet.php b/library/Zend/Barcode/Object/Postnet.php
index ddf4caa1c4..4364669da7 100644
--- a/library/Zend/Barcode/Object/Postnet.php
+++ b/library/Zend/Barcode/Object/Postnet.php
@@ -130,7 +130,6 @@ public function getChecksum($text)
{
$this->_checkText($text);
$sum = array_sum(str_split($text));
- $checksum = (10 - ($sum % 10)) % 10;
- return $checksum;
+ return (10 - ($sum % 10)) % 10;
}
}
diff --git a/library/Zend/Barcode/Object/Royalmail.php b/library/Zend/Barcode/Object/Royalmail.php
index 8d7bdd239c..d700abcbf0 100644
--- a/library/Zend/Barcode/Object/Royalmail.php
+++ b/library/Zend/Barcode/Object/Royalmail.php
@@ -126,7 +126,7 @@ protected function _prepareBarcode()
foreach ($textTable as $char) {
$bars = str_split($this->_codingMap[$char]);
foreach ($bars as $b) {
- $barcodeTable[] = array(1 , $this->_barThinWidth , ($b > 1 ? 3/8 : 0) , ($b % 2 ? 5/8 : 1));
+ $barcodeTable[] = array(1 , $this->_barThinWidth , ($b > 1 ? 3/8 : 0) , ($b % 2 !== 0 ? 5/8 : 1));
$barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
}
}
diff --git a/library/Zend/Barcode/Renderer/Image.php b/library/Zend/Barcode/Renderer/Image.php
index d73b098b11..9ec9e1a5e1 100644
--- a/library/Zend/Barcode/Renderer/Image.php
+++ b/library/Zend/Barcode/Renderer/Image.php
@@ -98,13 +98,13 @@ public function __construct($options = null)
*/
public function setHeight($value)
{
- if (!is_numeric($value) || intval($value) < 0) {
+ if (!is_numeric($value) || (int) $value < 0) {
require_once 'Zend/Barcode/Renderer/Exception.php';
throw new Zend_Barcode_Renderer_Exception(
'Image height must be greater than or equals 0'
);
}
- $this->_userHeight = intval($value);
+ $this->_userHeight = (int) $value;
return $this;
}
@@ -127,13 +127,13 @@ public function getHeight()
*/
public function setWidth($value)
{
- if (!is_numeric($value) || intval($value) < 0) {
+ if (!is_numeric($value) || (int) $value < 0) {
require_once 'Zend/Barcode/Renderer/Exception.php';
throw new Zend_Barcode_Renderer_Exception(
'Image width must be greater than or equals 0'
);
}
- $this->_userWidth = intval($value);
+ $this->_userWidth = (int) $value;
return $this;
}
@@ -301,17 +301,15 @@ protected function _checkDimensions()
'Barcode is define outside the image (height)'
);
}
- } else {
- if ($this->_userHeight) {
- $height = $this->_barcode->getHeight(true);
- if ($this->_userHeight < $height) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(sprintf(
- "Barcode is define outside the image (calculated: '%d', provided: '%d')",
- $height,
- $this->_userHeight
- ));
- }
+ } elseif ($this->_userHeight !== 0) {
+ $height = $this->_barcode->getHeight(true);
+ if ($this->_userHeight < $height) {
+ require_once 'Zend/Barcode/Renderer/Exception.php';
+ throw new Zend_Barcode_Renderer_Exception(sprintf(
+ "Barcode is define outside the image (calculated: '%d', provided: '%d')",
+ $height,
+ $this->_userHeight
+ ));
}
}
if ($this->_resource !== null) {
@@ -321,17 +319,15 @@ protected function _checkDimensions()
'Barcode is define outside the image (width)'
);
}
- } else {
- if ($this->_userWidth) {
- $width = $this->_barcode->getWidth(true);
- if ($this->_userWidth < $width) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(sprintf(
- "Barcode is define outside the image (calculated: '%d', provided: '%d')",
- $width,
- $this->_userWidth
- ));
- }
+ } elseif ($this->_userWidth !== 0) {
+ $width = $this->_barcode->getWidth(true);
+ if ($this->_userWidth < $width) {
+ require_once 'Zend/Barcode/Renderer/Exception.php';
+ throw new Zend_Barcode_Renderer_Exception(sprintf(
+ "Barcode is define outside the image (calculated: '%d', provided: '%d')",
+ $width,
+ $this->_userWidth
+ ));
}
}
}
diff --git a/library/Zend/Barcode/Renderer/Pdf.php b/library/Zend/Barcode/Renderer/Pdf.php
index 6341d7829c..6ed82a8e29 100644
--- a/library/Zend/Barcode/Renderer/Pdf.php
+++ b/library/Zend/Barcode/Renderer/Pdf.php
@@ -78,9 +78,9 @@ public function setResource($pdf, $page = 0)
}
$this->_resource = $pdf;
- $this->_page = intval($page);
+ $this->_page = (int) $page;
- if (!count($this->_resource->pages)) {
+ if ($this->_resource->pages === []) {
$this->_page = 0;
$this->_resource->pages[] = new Zend_Pdf_Page(
Zend_Pdf_Page::SIZE_A4
@@ -140,11 +140,11 @@ protected function _drawPolygon($points, $color, $filled = true)
$y[] = $page->getHeight() - $point[1] * $this->_moduleSize - $this->_topOffset;
}
if (count($y) == 4) {
- if ($x[0] != $x[3] && $y[0] == $y[3]) {
+ if ($x[0] !== $x[3] && $y[0] === $y[3]) {
$y[0] -= ($this->_moduleSize / 2);
$y[3] -= ($this->_moduleSize / 2);
}
- if ($x[1] != $x[2] && $y[1] == $y[2]) {
+ if ($x[1] !== $x[2] && $y[1] === $y[2]) {
$y[1] += ($this->_moduleSize / 2);
$y[2] += ($this->_moduleSize / 2);
}
@@ -239,7 +239,6 @@ public function widthForStringUsingFontSize($text, $font, $fontSize)
}
$glyphs = $font->glyphNumbersForCharacters($characters);
$widths = $font->widthsForGlyphs($glyphs);
- $stringWidth = (array_sum($widths) / $font->getUnitsPerEm()) * $fontSize;
- return $stringWidth;
+ return (array_sum($widths) / $font->getUnitsPerEm()) * $fontSize;
}
}
diff --git a/library/Zend/Barcode/Renderer/RendererAbstract.php b/library/Zend/Barcode/Renderer/RendererAbstract.php
index 2bbe16b5aa..51ffc995e2 100644
--- a/library/Zend/Barcode/Renderer/RendererAbstract.php
+++ b/library/Zend/Barcode/Renderer/RendererAbstract.php
@@ -174,13 +174,13 @@ public function getType()
*/
public function setTopOffset($value)
{
- if (!is_numeric($value) || intval($value) < 0) {
+ if (!is_numeric($value) || (int) $value < 0) {
require_once 'Zend/Barcode/Renderer/Exception.php';
throw new Zend_Barcode_Renderer_Exception(
'Vertical position must be greater than or equals 0'
);
}
- $this->_topOffset = intval($value);
+ $this->_topOffset = (int) $value;
return $this;
}
@@ -201,13 +201,13 @@ public function getTopOffset()
*/
public function setLeftOffset($value)
{
- if (!is_numeric($value) || intval($value) < 0) {
+ if (!is_numeric($value) || (int) $value < 0) {
require_once 'Zend/Barcode/Renderer/Exception.php';
throw new Zend_Barcode_Renderer_Exception(
'Horizontal position must be greater than or equals 0'
);
}
- $this->_leftOffset = intval($value);
+ $this->_leftOffset = (int) $value;
return $this;
}
@@ -393,7 +393,7 @@ protected function _checkBarcodeObject()
protected function _adjustPosition($supportHeight, $supportWidth)
{
$barcodeHeight = $this->_barcode->getHeight(true) * $this->_moduleSize;
- if ($barcodeHeight != $supportHeight && $this->_topOffset == 0) {
+ if ($barcodeHeight !== $supportHeight && $this->_topOffset == 0) {
switch ($this->_verticalPosition) {
case 'middle':
$this->_topOffset = floor(
@@ -409,7 +409,7 @@ protected function _adjustPosition($supportHeight, $supportWidth)
}
}
$barcodeWidth = $this->_barcode->getWidth(true) * $this->_moduleSize;
- if ($barcodeWidth != $supportWidth && $this->_leftOffset == 0) {
+ if ($barcodeWidth !== $supportWidth && $this->_leftOffset == 0) {
switch ($this->_horizontalPosition) {
case 'center':
$this->_leftOffset = floor(
diff --git a/library/Zend/Barcode/Renderer/Svg.php b/library/Zend/Barcode/Renderer/Svg.php
index 4bb94d750d..ff03658914 100644
--- a/library/Zend/Barcode/Renderer/Svg.php
+++ b/library/Zend/Barcode/Renderer/Svg.php
@@ -67,13 +67,13 @@ class Zend_Barcode_Renderer_Svg extends Zend_Barcode_Renderer_RendererAbstract
*/
public function setHeight($value)
{
- if (!is_numeric($value) || intval($value) < 0) {
+ if (!is_numeric($value) || (int) $value < 0) {
require_once 'Zend/Barcode/Renderer/Exception.php';
throw new Zend_Barcode_Renderer_Exception(
'Svg height must be greater than or equals 0'
);
}
- $this->_userHeight = intval($value);
+ $this->_userHeight = (int) $value;
return $this;
}
@@ -96,13 +96,13 @@ public function getHeight()
*/
public function setWidth($value)
{
- if (!is_numeric($value) || intval($value) < 0) {
+ if (!is_numeric($value) || (int) $value < 0) {
require_once 'Zend/Barcode/Renderer/Exception.php';
throw new Zend_Barcode_Renderer_Exception(
'Svg width must be greater than or equals 0'
);
}
- $this->_userWidth = intval($value);
+ $this->_userWidth = (int) $value;
return $this;
}
@@ -252,17 +252,15 @@ protected function _checkDimensions()
'Barcode is define outside the image (height)'
);
}
- } else {
- if ($this->_userHeight) {
- $height = $this->_barcode->getHeight(true);
- if ($this->_userHeight < $height) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(sprintf(
- "Barcode is define outside the image (calculated: '%d', provided: '%d')",
- $height,
- $this->_userHeight
- ));
- }
+ } elseif ($this->_userHeight !== 0) {
+ $height = $this->_barcode->getHeight(true);
+ if ($this->_userHeight < $height) {
+ require_once 'Zend/Barcode/Renderer/Exception.php';
+ throw new Zend_Barcode_Renderer_Exception(sprintf(
+ "Barcode is define outside the image (calculated: '%d', provided: '%d')",
+ $height,
+ $this->_userHeight
+ ));
}
}
if ($this->_resource !== null) {
@@ -274,17 +272,15 @@ protected function _checkDimensions()
'Barcode is define outside the image (width)'
);
}
- } else {
- if ($this->_userWidth) {
- $width = (float) $this->_barcode->getWidth(true);
- if ($this->_userWidth < $width) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(sprintf(
- "Barcode is define outside the image (calculated: '%d', provided: '%d')",
- $width,
- $this->_userWidth
- ));
- }
+ } elseif ($this->_userWidth !== 0) {
+ $width = (float) $this->_barcode->getWidth(true);
+ if ($this->_userWidth < $width) {
+ require_once 'Zend/Barcode/Renderer/Exception.php';
+ throw new Zend_Barcode_Renderer_Exception(sprintf(
+ "Barcode is define outside the image (calculated: '%d', provided: '%d')",
+ $width,
+ $this->_userWidth
+ ));
}
}
}
diff --git a/library/Zend/Cache.php b/library/Zend/Cache.php
index dc818f30e5..4294449cda 100644
--- a/library/Zend/Cache.php
+++ b/library/Zend/Cache.php
@@ -92,21 +92,17 @@ public static function factory($frontend, $backend, $frontendOptions = array(),
{
if (is_string($backend)) {
$backendObject = self::_makeBackend($backend, $backendOptions, $customBackendNaming, $autoload);
+ } elseif ((is_object($backend)) && (in_array('Zend_Cache_Backend_Interface', class_implements($backend)))) {
+ $backendObject = $backend;
} else {
- if ((is_object($backend)) && (in_array('Zend_Cache_Backend_Interface', class_implements($backend)))) {
- $backendObject = $backend;
- } else {
- self::throwException('backend must be a backend name (string) or an object which implements Zend_Cache_Backend_Interface');
- }
+ self::throwException('backend must be a backend name (string) or an object which implements Zend_Cache_Backend_Interface');
}
if (is_string($frontend)) {
$frontendObject = self::_makeFrontend($frontend, $frontendOptions, $customFrontendNaming, $autoload);
+ } elseif (is_object($frontend)) {
+ $frontendObject = $frontend;
} else {
- if (is_object($frontend)) {
- $frontendObject = $frontend;
- } else {
- self::throwException('frontend must be a frontend name (string) or an object');
- }
+ self::throwException('frontend must be a frontend name (string) or an object');
}
$frontendObject->setBackend($backendObject);
return $frontendObject;
@@ -136,12 +132,7 @@ public static function _makeBackend($backend, $backendOptions, $customBackendNam
if (!preg_match('~^[\w\\\\]+$~D', $backend)) {
Zend_Cache::throwException("Invalid backend name [$backend]");
}
- if (!$customBackendNaming) {
- // we use this boolean to avoid an API break
- $backendClass = 'Zend_Cache_Backend_' . $backend;
- } else {
- $backendClass = $backend;
- }
+ $backendClass = $customBackendNaming ? $backend : 'Zend_Cache_Backend_' . $backend;
if (!$autoload) {
$file = str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php';
if (!(self::_isReadable($file))) {
@@ -178,12 +169,7 @@ public static function _makeFrontend($frontend, $frontendOptions = array(), $cus
if (!preg_match('~^[\w\\\\]+$~D', $frontend)) {
Zend_Cache::throwException("Invalid frontend name [$frontend]");
}
- if (!$customFrontendNaming) {
- // we use this boolean to avoid an API break
- $frontendClass = 'Zend_Cache_Frontend_' . $frontend;
- } else {
- $frontendClass = $frontend;
- }
+ $frontendClass = $customFrontendNaming ? $frontend : 'Zend_Cache_Frontend_' . $frontend;
if (!$autoload) {
$file = str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php';
if (!(self::_isReadable($file))) {
diff --git a/library/Zend/Cache/Backend.php b/library/Zend/Cache/Backend.php
index 3d99e0939c..d581be91d9 100644
--- a/library/Zend/Cache/Backend.php
+++ b/library/Zend/Cache/Backend.php
@@ -175,11 +175,7 @@ public function getTmpDir()
foreach (array($_ENV, $_SERVER) as $tab) {
foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
if (isset($tab[$key]) && is_string($tab[$key])) {
- if (($key == 'windir') or ($key == 'SystemRoot')) {
- $dir = realpath($tab[$key] . '\\temp');
- } else {
- $dir = realpath($tab[$key]);
- }
+ $dir = ($key == 'windir' || $key == 'SystemRoot') ? realpath($tab[$key] . '\\temp') : realpath($tab[$key]);
if ($this->_isGoodTmpDir($dir)) {
return $dir;
}
@@ -225,12 +221,7 @@ public function getTmpDir()
*/
protected function _isGoodTmpDir($dir)
{
- if (is_readable($dir)) {
- if (is_writable($dir)) {
- return true;
- }
- }
- return false;
+ return is_readable($dir) && is_writable($dir);
}
/**
diff --git a/library/Zend/Cache/Backend/Apc.php b/library/Zend/Cache/Backend/Apc.php
index 5a09becdcf..d205816f89 100644
--- a/library/Zend/Cache/Backend/Apc.php
+++ b/library/Zend/Cache/Backend/Apc.php
@@ -110,7 +110,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
$result = apc_store($id, array($data, time(), $lifetime), $lifetime);
- if (count($tags) > 0) {
+ if ($tags !== []) {
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
}
return $result;
diff --git a/library/Zend/Cache/Backend/File.php b/library/Zend/Cache/Backend/File.php
index 581da22113..debcf8ede6 100644
--- a/library/Zend/Cache/Backend/File.php
+++ b/library/Zend/Cache/Backend/File.php
@@ -129,10 +129,8 @@ public function __construct(array $options = array())
} else {
$this->setCacheDir(self::getTmpDir() . DIRECTORY_SEPARATOR, false);
}
- if (isset($this->_options['file_name_prefix'])) { // particular case for this option
- if (!preg_match('~^[a-zA-Z0-9_]+$~D', (string) $this->_options['file_name_prefix'])) {
- Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]');
- }
+ // particular case for this option
+ if (isset($this->_options['file_name_prefix']) && !preg_match('~^\w+$~D', (string) $this->_options['file_name_prefix'])) { Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]');
}
if ($this->_options['metadatas_array_max_size'] < 10) {
Zend_Cache::throwException('Invalid metadatas_array_max_size, must be > 10');
@@ -253,11 +251,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
return false;
}
}
- if ($this->_options['read_control']) {
- $hash = $this->_hash($data, $this->_options['read_control_type']);
- } else {
- $hash = '';
- }
+ $hash = $this->_options['read_control'] ? $this->_hash($data, $this->_options['read_control_type']) : '';
$metadatas = array(
'hash' => $hash,
'mtime' => time(),
@@ -269,8 +263,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
$this->_log('Zend_Cache_Backend_File::save() / error on saving metadata');
return false;
}
- $res = $this->_filePutContents($file, $data);
- return $res;
+ return $this->_filePutContents($file, $data);
}
/**
@@ -440,11 +433,7 @@ public function touch($id, $extraLifetime)
'expire' => $metadatas['expire'] + $extraLifetime,
'tags' => $metadatas['tags']
);
- $res = $this->_setMetadatas($id, $newMetadatas);
- if (!$res) {
- return false;
- }
- return true;
+ return $this->_setMetadatas($id, $newMetadatas);
}
/**
@@ -568,11 +557,10 @@ protected function _loadMetadatas($id)
{
$file = $this->_metadatasFile($id);
$result = $this->_fileGetContents($file);
- if (!$result) {
+ if ($result === '' || $result === '0') {
return false;
}
- $tmp = @unserialize($result);
- return $tmp;
+ return @unserialize($result);
}
/**
@@ -585,11 +573,7 @@ protected function _loadMetadatas($id)
protected function _saveMetadatas($id, $metadatas)
{
$file = $this->_metadatasFile($id);
- $result = $this->_filePutContents($file, serialize($metadatas));
- if (!$result) {
- return false;
- }
- return true;
+ return $this->_filePutContents($file, serialize($metadatas));
}
/**
@@ -741,7 +725,7 @@ protected function _clean($dir, $mode = Zend_Cache::CLEANING_MODE_ALL, $tags = a
break;
}
}
- if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
+ if (is_dir($file) && $this->_options['hashed_directory_level']>0) {
// Recursive call
$result = $this->_clean($file . DIRECTORY_SEPARATOR, $mode, $tags) && $result;
if ($mode == Zend_Cache::CLEANING_MODE_ALL) {
@@ -832,7 +816,7 @@ protected function _get($dir, $mode, $tags = array())
break;
}
}
- if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
+ if (is_dir($file) && $this->_options['hashed_directory_level']>0) {
// Recursive call
$recursiveRs = $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags);
if ($recursiveRs === false) {
@@ -892,8 +876,7 @@ protected function _hash($data, $controlType)
protected function _idToFileName($id)
{
$prefix = $this->_options['file_name_prefix'];
- $result = $prefix . '---' . $id;
- return $result;
+ return $prefix . '---' . $id;
}
/**
@@ -1013,7 +996,7 @@ protected function _filePutContents($file, $string)
fseek($f, 0);
ftruncate($f, 0);
$tmp = @fwrite($f, $string);
- if (!($tmp === FALSE)) {
+ if ($tmp !== FALSE) {
$result = true;
}
@fclose($f);
diff --git a/library/Zend/Cache/Backend/Libmemcached.php b/library/Zend/Cache/Backend/Libmemcached.php
index 623e75776c..48b308745f 100644
--- a/library/Zend/Cache/Backend/Libmemcached.php
+++ b/library/Zend/Cache/Backend/Libmemcached.php
@@ -132,10 +132,8 @@ public function __construct(array $options = array())
$this->_log("Unknown memcached client option '{$name}' ({$optConst})");
}
}
- if (null !== $optId) {
- if (!$this->_memcache->setOption($optId, $value)) {
- $this->_log("Setting memcached client option '{$optId}' failed");
- }
+ if (null !== $optId && !$this->_memcache->setOption($optId, $value)) {
+ $this->_log("Setting memcached client option '{$optId}' failed");
}
}
@@ -209,7 +207,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
$this->_log("Memcached::set() failed: [{$rsCode}] {$rsMsg}");
}
- if (count($tags) > 0) {
+ if ($tags !== []) {
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND);
}
diff --git a/library/Zend/Cache/Backend/Memcached.php b/library/Zend/Cache/Backend/Memcached.php
index 9cb9916dd8..76994774f4 100644
--- a/library/Zend/Cache/Backend/Memcached.php
+++ b/library/Zend/Cache/Backend/Memcached.php
@@ -214,16 +214,12 @@ public function test($id)
public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
- if ($this->_options['compression']) {
- $flag = MEMCACHE_COMPRESSED;
- } else {
- $flag = 0;
- }
+ $flag = $this->_options['compression'] ? MEMCACHE_COMPRESSED : 0;
// ZF-8856: using set because add needs a second request if item already exists
$result = @$this->_memcache->set($id, array($data, time(), $lifetime), $flag, $lifetime);
- if (count($tags) > 0) {
+ if ($tags !== []) {
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
}
@@ -452,11 +448,7 @@ public function getMetadatas($id)
*/
public function touch($id, $extraLifetime)
{
- if ($this->_options['compression']) {
- $flag = MEMCACHE_COMPRESSED;
- } else {
- $flag = 0;
- }
+ $flag = $this->_options['compression'] ? MEMCACHE_COMPRESSED : 0;
$tmp = $this->_memcache->get($id);
if (is_array($tmp)) {
$data = $tmp[0];
diff --git a/library/Zend/Cache/Backend/Sqlite.php b/library/Zend/Cache/Backend/Sqlite.php
index bac31c08ce..8c61ed7b80 100644
--- a/library/Zend/Cache/Backend/Sqlite.php
+++ b/library/Zend/Cache/Backend/Sqlite.php
@@ -119,7 +119,7 @@ public function load($id, $doNotTestCacheValidity = false)
}
$result = $this->_query($sql);
$row = @sqlite_fetch_array($result);
- if ($row) {
+ if ($row !== []) {
return $row['content'];
}
return false;
@@ -137,7 +137,7 @@ public function test($id)
$sql = "SELECT lastModified FROM cache WHERE id='$id' AND (expire=0 OR expire>" . time() . ')';
$result = $this->_query($sql);
$row = @sqlite_fetch_array($result);
- if ($row) {
+ if ($row !== []) {
return ((int) $row['lastModified']);
}
return false;
@@ -162,11 +162,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
$lifetime = $this->getLifetime($specificLifetime);
$data = @sqlite_escape_string($data);
$mktime = time();
- if ($lifetime === null) {
- $expire = 0;
- } else {
- $expire = $mktime + $lifetime;
- }
+ $expire = $lifetime === null ? 0 : $mktime + $lifetime;
$this->_query("DELETE FROM cache WHERE id='$id'");
$sql = "INSERT INTO cache (id, content, lastModified, expire) VALUES ('$id', '$data', $mktime, $expire)";
$res = $this->_query($sql);
@@ -285,9 +281,7 @@ public function getIdsMatchingTags($tags = array())
}
}
$result = array();
- foreach ($ids as $id) {
- $result[] = $id;
- }
+ $result = $ids;
return $result;
}
@@ -354,9 +348,7 @@ public function getIdsMatchingAnyTags($tags = array())
}
}
$result = array();
- foreach ($ids as $id) {
- $result[] = $id;
- }
+ $result = $ids;
return $result;
}
@@ -581,10 +573,10 @@ private function _checkStructureVersion()
$result = $this->_query("SELECT num FROM version");
if (!$result) return false;
$row = @sqlite_fetch_array($result);
- if (!$row) {
+ if ($row === []) {
return false;
}
- if (((int) $row['num']) != 1) {
+ if ((int) $row['num'] != 1) {
// old cache structure
$this->_log('Zend_Cache_Backend_Sqlite::_checkStructureVersion() : old cache structure version detected => the cache is going to be dropped');
return false;
diff --git a/library/Zend/Cache/Backend/Static.php b/library/Zend/Cache/Backend/Static.php
index 70e0286eef..b6a95a253b 100644
--- a/library/Zend/Cache/Backend/Static.php
+++ b/library/Zend/Cache/Backend/Static.php
@@ -137,11 +137,7 @@ public function getOption($name)
*/
public function load($id, $doNotTestCacheValidity = false)
{
- if (($id = (string)$id) === '') {
- $id = $this->_detectId();
- } else {
- $id = $this->_decodeId($id);
- }
+ $id = ($id = (string)$id) === '' ? $this->_detectId() : $this->_decodeId($id);
if (!$this->_verifyPath($id)) {
Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path');
}
@@ -156,8 +152,7 @@ public function load($id, $doNotTestCacheValidity = false)
$pathName = $this->_options['public_dir'] . dirname($id);
$file = rtrim($pathName, '/') . '/' . $fileName . $this->_options['file_extension'];
if (file_exists($file)) {
- $content = file_get_contents($file);
- return $content;
+ return file_get_contents($file);
}
return false;
@@ -188,16 +183,9 @@ public function test($id)
$pathName = $this->_options['public_dir'] . dirname($id);
// Switch extension if needed
- if (isset($this->_tagged[$id])) {
- $extension = $this->_tagged[$id]['extension'];
- } else {
- $extension = $this->_options['file_extension'];
- }
+ $extension = isset($this->_tagged[$id]) ? $this->_tagged[$id]['extension'] : $this->_options['file_extension'];
$file = $pathName . '/' . $fileName . $extension;
- if (file_exists($file)) {
- return true;
- }
- return false;
+ return file_exists($file);
}
/**
@@ -225,11 +213,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
}
clearstatcache();
- if (($id = (string)$id) === '') {
- $id = $this->_detectId();
- } else {
- $id = $this->_decodeId($id);
- }
+ $id = ($id = (string)$id) === '' ? $this->_detectId() : $this->_decodeId($id);
$fileName = basename($id);
if ($fileName === '') {
@@ -317,11 +301,7 @@ public function remove($id)
} elseif (!$this->_tagged) {
return false;
}
- if (isset($this->_tagged[$id])) {
- $extension = $this->_tagged[$id]['extension'];
- } else {
- $extension = $this->_options['file_extension'];
- }
+ $extension = isset($this->_tagged[$id]) ? $this->_tagged[$id]['extension'] : $this->_options['file_extension'];
if ($fileName === '') {
$fileName = $this->_options['index_filename'];
}
@@ -359,10 +339,8 @@ public function removeRecursively($id)
}
if (is_dir($directory)) {
foreach (new DirectoryIterator($directory) as $file) {
- if (true === $file->isFile()) {
- if (false === unlink($file->getPathName())) {
- return false;
- }
+ if ($file->isFile() && !unlink($file->getPathName())) {
+ return false;
}
}
}
@@ -560,7 +538,7 @@ protected static function _validateIdOrTag($string)
*/
protected function _octdec($val)
{
- if (is_string($val) && decoct(octdec($val)) == $val) {
+ if (is_string($val) && decoct(octdec($val)) === $val) {
return octdec($val);
}
return $val;
diff --git a/library/Zend/Cache/Backend/Test.php b/library/Zend/Cache/Backend/Test.php
index d94e973441..b468a36740 100644
--- a/library/Zend/Cache/Backend/Test.php
+++ b/library/Zend/Cache/Backend/Test.php
@@ -167,10 +167,7 @@ public function test($id)
public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$this->_addLog('save', array($data, $id, $tags));
- if (substr($id,-5)=='false') {
- return false;
- }
- return true;
+ return !(substr($id,-5)=='false');
}
/**
@@ -185,10 +182,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
public function remove($id)
{
$this->_addLog('remove', array($id));
- if (substr($id,-5)=='false') {
- return false;
- }
- return true;
+ return !(substr($id,-5)=='false');
}
/**
@@ -212,10 +206,7 @@ public function remove($id)
public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
$this->_addLog('clean', array($mode, $tags));
- if ($mode=='false') {
- return false;
- }
- return true;
+ return !($mode=='false');
}
/**
@@ -410,7 +401,7 @@ private function _addLog($methodName, $args)
'methodName' => $methodName,
'args' => $args
);
- $this->_index = $this->_index + 1;
+ $this->_index += 1;
}
}
diff --git a/library/Zend/Cache/Backend/TwoLevels.php b/library/Zend/Cache/Backend/TwoLevels.php
index 135ff6ad8d..5ee3517245 100644
--- a/library/Zend/Cache/Backend/TwoLevels.php
+++ b/library/Zend/Cache/Backend/TwoLevels.php
@@ -205,7 +205,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false, $pr
$boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime);
} else {
$boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime);
- if ($boolSlow === true) {
+ if ($boolSlow) {
$boolFast = $this->_fastBackend->remove($id);
if (!$boolFast && !$this->_fastBackend->test($id)) {
// some backends return false on remove() even if the key never existed. (and it won't if fast is full)
@@ -492,14 +492,7 @@ private function _prepareData($data, $lifetime, $priority)
*/
private function _getFastLifetime($lifetime, $priority, $maxLifetime = null)
{
- if ($lifetime <= 0) {
- // if no lifetime, we have an infinite lifetime
- // we need to use arbitrary lifetimes
- $fastLifetime = (int) (2592000 / (11 - $priority));
- } else {
- // prevent computed infinite lifetime (0) by ceil
- $fastLifetime = (int) ceil($lifetime / (11 - $priority));
- }
+ $fastLifetime = $lifetime <= 0 ? (int) (2592000 / (11 - $priority)) : (int) ceil($lifetime / (11 - $priority));
if ($maxLifetime >= 0 && $fastLifetime > $maxLifetime) {
return $maxLifetime;
@@ -535,12 +528,8 @@ private function _getFastFillingPercentage($mode)
$this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
}
}
- } else {
- // mode loading
- // we compute the percentage only if it's not available in cache
- if ($this->_fastBackendFillingPercentage === null) {
- $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
- }
+ } elseif ($this->_fastBackendFillingPercentage === null) {
+ $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
}
return $this->_fastBackendFillingPercentage;
}
diff --git a/library/Zend/Cache/Backend/WinCache.php b/library/Zend/Cache/Backend/WinCache.php
index 06843fa39a..dc4637f9e2 100644
--- a/library/Zend/Cache/Backend/WinCache.php
+++ b/library/Zend/Cache/Backend/WinCache.php
@@ -110,7 +110,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
$result = wincache_ucache_set($id, array($data, time(), $lifetime), $lifetime);
- if (count($tags) > 0) {
+ if ($tags !== []) {
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
}
return $result;
diff --git a/library/Zend/Cache/Backend/Xcache.php b/library/Zend/Cache/Backend/Xcache.php
index 4bc077fc92..5d23e88d7d 100644
--- a/library/Zend/Cache/Backend/Xcache.php
+++ b/library/Zend/Cache/Backend/Xcache.php
@@ -132,7 +132,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
$result = xcache_set($id, array($data, time()), $lifetime);
- if (count($tags) > 0) {
+ if ($tags !== []) {
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_XCACHE_BACKEND);
}
return $result;
diff --git a/library/Zend/Cache/Backend/ZendPlatform.php b/library/Zend/Cache/Backend/ZendPlatform.php
index 31e9a7a22a..4237c017b8 100644
--- a/library/Zend/Cache/Backend/ZendPlatform.php
+++ b/library/Zend/Cache/Backend/ZendPlatform.php
@@ -86,11 +86,7 @@ public function __construct(array $options = array())
public function load($id, $doNotTestCacheValidity = false)
{
// doNotTestCacheValidity implemented by giving zero lifetime to the cache
- if ($doNotTestCacheValidity) {
- $lifetime = 0;
- } else {
- $lifetime = $this->_directives['lifetime'];
- }
+ $lifetime = $doNotTestCacheValidity ? 0 : $this->_directives['lifetime'];
$res = output_cache_get($id, $lifetime);
if($res) {
return $res[0];
@@ -129,7 +125,7 @@ public function test($id)
*/
public function save($data, $id, $tags = array(), $specificLifetime = false)
{
- if (!($specificLifetime === false)) {
+ if ($specificLifetime !== false) {
$this->_log("Zend_Cache_Backend_ZendPlatform::save() : non false specifc lifetime is unsuported for this backend");
}
@@ -198,11 +194,7 @@ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
$idlist = null;
foreach ($tags as $tag) {
$next_idlist = output_cache_get(self::TAGS_PREFIX.$tag, $this->_directives['lifetime']);
- if ($idlist) {
- $idlist = array_intersect_assoc($idlist, $next_idlist);
- } else {
- $idlist = $next_idlist;
- }
+ $idlist = $idlist ? array_intersect_assoc($idlist, $next_idlist) : $next_idlist;
if (count($idlist) == 0) {
// if ID list is already empty - we may skip checking other IDs
$idlist = null;
@@ -224,11 +216,7 @@ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
$idlist = null;
foreach ($tags as $tag) {
$next_idlist = output_cache_get(self::TAGS_PREFIX.$tag, $this->_directives['lifetime']);
- if ($idlist) {
- $idlist = array_merge_recursive($idlist, $next_idlist);
- } else {
- $idlist = $next_idlist;
- }
+ $idlist = $idlist ? array_merge_recursive($idlist, $next_idlist) : $next_idlist;
if (count($idlist) == 0) {
// if ID list is already empty - we may skip checking other IDs
$idlist = null;
@@ -271,17 +259,10 @@ private function _clean($dir, $mode)
$file = $d->path . $file;
if (is_dir($file)) {
$result = ($this->_clean($file .'/', $mode)) && ($result);
- } else {
- if ($mode == Zend_Cache::CLEANING_MODE_ALL) {
- $result = ($this->_remove($file)) && ($result);
- } else if ($mode == Zend_Cache::CLEANING_MODE_OLD) {
- // Files older than lifetime get deleted from cache
- if ($this->_directives['lifetime'] !== null) {
- if ((time() - @filemtime($file)) > $this->_directives['lifetime']) {
- $result = ($this->_remove($file)) && ($result);
- }
- }
- }
+ } elseif ($mode == Zend_Cache::CLEANING_MODE_ALL) {
+ $result = ($this->_remove($file)) && ($result);
+ } elseif ($mode == Zend_Cache::CLEANING_MODE_OLD && $this->_directives['lifetime'] !== null && (time() - @filemtime($file)) > $this->_directives['lifetime']) {
+ $result = ($this->_remove($file)) && ($result);
}
}
$d->close();
diff --git a/library/Zend/Cache/Backend/ZendServer.php b/library/Zend/Cache/Backend/ZendServer.php
index ededaf5a9b..9c14f64217 100755
--- a/library/Zend/Cache/Backend/ZendServer.php
+++ b/library/Zend/Cache/Backend/ZendServer.php
@@ -146,7 +146,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
'expire' => $this->_expireTime($lifetime),
);
- if (count($tags) > 0) {
+ if ($tags !== []) {
$this->_log('Zend_Cache_Backend_ZendServer::save() : tags are unsupported by the ZendServer backends');
}
diff --git a/library/Zend/Cache/Backend/ZendServer/Disk.php b/library/Zend/Cache/Backend/ZendServer/Disk.php
index 54914fefff..d16fb833f6 100755
--- a/library/Zend/Cache/Backend/ZendServer/Disk.php
+++ b/library/Zend/Cache/Backend/ZendServer/Disk.php
@@ -60,9 +60,9 @@ public function __construct(array $options = array())
*/
protected function _store($data, $id, $timeToLive)
{
- if (zend_disk_cache_store($this->_options['namespace'] . '::' . $id,
+ if (!zend_disk_cache_store($this->_options['namespace'] . '::' . $id,
$data,
- $timeToLive) === false) {
+ $timeToLive)) {
$this->_log('Store operation failed.');
return false;
}
diff --git a/library/Zend/Cache/Backend/ZendServer/ShMem.php b/library/Zend/Cache/Backend/ZendServer/ShMem.php
index 83086dcd4e..ab1cb56545 100755
--- a/library/Zend/Cache/Backend/ZendServer/ShMem.php
+++ b/library/Zend/Cache/Backend/ZendServer/ShMem.php
@@ -60,9 +60,9 @@ public function __construct(array $options = array())
*/
protected function _store($data, $id, $timeToLive)
{
- if (zend_shm_cache_store($this->_options['namespace'] . '::' . $id,
+ if (!zend_shm_cache_store($this->_options['namespace'] . '::' . $id,
$data,
- $timeToLive) === false) {
+ $timeToLive)) {
$this->_log('Store operation failed.');
return false;
}
diff --git a/library/Zend/Cache/Core.php b/library/Zend/Cache/Core.php
index 8c9d7070bc..34f21ad16d 100644
--- a/library/Zend/Cache/Core.php
+++ b/library/Zend/Cache/Core.php
@@ -140,8 +140,7 @@ public function __construct($options = array())
$options = $options->toArray();
}
if (!is_array($options)) {
- Zend_Cache::throwException("Options passed were not an array"
- . " or Zend_Config instance.");
+ Zend_Cache::throwException('Options passed were not an array or Zend_Config instance.');
}
foreach ($options as $name => $value) {
$this->setOption($name, $value);
@@ -350,20 +349,14 @@ public function save($data, $id = null, $tags = array(), $specificLifetime = fal
if (!$this->_options['caching']) {
return true;
}
- if ($id === null) {
- $id = $this->_lastId;
- } else {
- $id = $this->_id($id);
- }
+ $id = $id === null ? $this->_lastId : $this->_id($id);
$this->_validateIdOrTag($id);
$this->_validateTagsArray($tags);
if ($this->_options['automatic_serialization']) {
// we need to serialize datas before storing them
$data = serialize($data);
- } else {
- if (!is_string($data)) {
- Zend_Cache::throwException("Datas must be string or set automatic_serialization = true");
- }
+ } elseif (!is_string($data)) {
+ Zend_Cache::throwException("Datas must be string or set automatic_serialization = true");
}
// automatic cleaning
@@ -402,7 +395,7 @@ public function save($data, $id = null, $tags = array(), $specificLifetime = fal
if ($this->_options['write_control']) {
$data2 = $this->_backend->load($id, true);
- if ($data!=$data2) {
+ if ($data != $data2) {
$this->_log("Zend_Cache_Core::save(): write control of item '{$id}' failed -> removing it", 4);
$this->_backend->remove($id);
return false;
@@ -675,7 +668,7 @@ protected function _validateIdOrTag($string)
if (substr($string, 0, 9) == 'internal-') {
Zend_Cache::throwException('"internal-*" ids or tags are reserved');
}
- if (!preg_match('~^[a-zA-Z0-9_]+$~D', $string)) {
+ if (!preg_match('~^\w+$~D', $string)) {
Zend_Cache::throwException("Invalid id or tag '$string' : must use only [a-zA-Z0-9_]");
}
}
@@ -739,7 +732,7 @@ protected function _log($message, $priority = 4)
if (!$this->_options['logging']) {
return;
}
- if (!(isset($this->_options['logger']) || $this->_options['logger'] instanceof Zend_Log)) {
+ if (!isset($this->_options['logger']) && !$this->_options['logger'] instanceof Zend_Log) {
Zend_Cache::throwException('Logging is enabled but logger is not set');
}
$logger = $this->_options['logger'];
diff --git a/library/Zend/Cache/Frontend/Capture.php b/library/Zend/Cache/Frontend/Capture.php
index 32ecc237ee..fece40e5f4 100644
--- a/library/Zend/Cache/Frontend/Capture.php
+++ b/library/Zend/Cache/Frontend/Capture.php
@@ -59,7 +59,9 @@ public function start($id, array $tags, $extension = null)
{
$this->_tags = $tags;
$this->_extension = $extension;
- ob_start(array($this, '_flush'));
+ ob_start(function (string $data) : string {
+ return $this->_flush($data);
+ });
ob_implicit_flush(false);
$this->_idStack[] = $id;
return false;
diff --git a/library/Zend/Cache/Frontend/File.php b/library/Zend/Cache/Frontend/File.php
index e5017c631c..7da051603e 100644
--- a/library/Zend/Cache/Frontend/File.php
+++ b/library/Zend/Cache/Frontend/File.php
@@ -110,11 +110,7 @@ public function setMasterFiles(array $masterFiles)
clearstatcache();
$i = 0;
foreach ($masterFiles as $masterFile) {
- if (file_exists($masterFile)) {
- $mtime = filemtime($masterFile);
- } else {
- $mtime = false;
- }
+ $mtime = file_exists($masterFile) ? filemtime($masterFile) : false;
if (!$this->_specificOptions['ignore_missing_master_files'] && !$mtime) {
Zend_Cache::throwException('Unable to read master_file : ' . $masterFile);
@@ -157,7 +153,7 @@ public function setOption($name, $value)
{
if ($name == 'master_file') {
$this->setMasterFile($value);
- } else if ($name == 'master_files') {
+ } elseif ($name == 'master_files') {
$this->setMasterFiles($value);
} else {
parent::setOption($name, $value);
@@ -196,20 +192,16 @@ public function test($id)
if ($this->_specificOptions['master_files_mode'] == self::MODE_AND) {
// MODE_AND
foreach($this->_masterFile_mtimes as $masterFileMTime) {
- if ($masterFileMTime) {
- if ($lastModified > $masterFileMTime) {
- return $lastModified;
- }
+ if ($masterFileMTime && $lastModified > $masterFileMTime) {
+ return $lastModified;
}
}
} else {
// MODE_OR
$res = true;
foreach($this->_masterFile_mtimes as $masterFileMTime) {
- if ($masterFileMTime) {
- if ($lastModified <= $masterFileMTime) {
- return false;
- }
+ if ($masterFileMTime && $lastModified <= $masterFileMTime) {
+ return false;
}
}
return $lastModified;
diff --git a/library/Zend/Cache/Frontend/Function.php b/library/Zend/Cache/Frontend/Function.php
index 8af521bda6..6d70f73aac 100644
--- a/library/Zend/Cache/Frontend/Function.php
+++ b/library/Zend/Cache/Frontend/Function.php
@@ -161,7 +161,7 @@ public function makeId($callback, array $args = array())
// generate a unique id for arguments
$argsStr = '';
- if ($args) {
+ if ($args !== []) {
try {
$argsStr = @serialize(array_values($args));
} catch (Exception $e) {
diff --git a/library/Zend/Cache/Frontend/Page.php b/library/Zend/Cache/Frontend/Page.php
index 9239476f34..d6393ab5fe 100644
--- a/library/Zend/Cache/Frontend/Page.php
+++ b/library/Zend/Cache/Frontend/Page.php
@@ -145,10 +145,8 @@ public function __construct(array $options = array())
$this->setOption($name, $value);
}
}
- if (isset($this->_specificOptions['http_conditional'])) {
- if ($this->_specificOptions['http_conditional']) {
- Zend_Cache::throwException('http_conditional is not implemented for the moment !');
- }
+ if (isset($this->_specificOptions['http_conditional']) && $this->_specificOptions['http_conditional']) {
+ Zend_Cache::throwException('http_conditional is not implemented for the moment !');
}
$this->setOption('automatic_serialization', true);
}
@@ -195,10 +193,8 @@ protected function _setContentTypeMemorization($value)
if (!$found) {
$this->_specificOptions['memorize_headers'][] = 'Content-Type';
}
- } else {
- if ($found) {
- unset($this->_specificOptions['memorize_headers'][$found]);
- }
+ } elseif ($found) {
+ unset($this->_specificOptions['memorize_headers'][$found]);
}
}
@@ -260,7 +256,7 @@ public function start($id = false, $doNotDie = false)
if (!($this->_activeOptions['cache'])) {
return false;
}
- if (!$id) {
+ if ($id === '' || $id === '0') {
$id = $this->_makeId();
if (!$id) {
return false;
@@ -286,7 +282,9 @@ public function start($id = false, $doNotDie = false)
}
die();
}
- ob_start(array($this, '_flush'));
+ ob_start(function (string $data) : string {
+ return $this->_flush($data);
+ });
ob_implicit_flush(false);
return false;
}
@@ -318,7 +316,7 @@ public function _flush($data)
foreach ($headersList as $headerSent) {
$tmp = explode(':', (string) $headerSent);
$headerSentName = trim(array_shift($tmp));
- if (strtolower($headerName) == strtolower($headerSentName)) {
+ if (strtolower($headerName) === strtolower($headerSentName)) {
$headerSentValue = trim(implode(':', $tmp));
$storedHeaders[] = array($headerSentName, $headerSentValue);
}
@@ -347,7 +345,7 @@ protected function _makeId()
if ($tmp2===false) {
return false;
}
- $tmp = $tmp . $tmp2;
+ $tmp .= $tmp2;
}
return md5($tmp);
}
@@ -370,18 +368,10 @@ protected function _makePartialId($arrayName, $bool1, $bool2)
$var = $_POST;
break;
case 'Session':
- if (isset($_SESSION)) {
- $var = $_SESSION;
- } else {
- $var = null;
- }
+ $var = isset($_SESSION) ? $_SESSION : null;
break;
case 'Cookie':
- if (isset($_COOKIE)) {
- $var = $_COOKIE;
- } else {
- $var = null;
- }
+ $var = isset($_COOKIE) ? $_COOKIE : null;
break;
case 'Files':
$var = $_FILES;
diff --git a/library/Zend/Cache/Manager.php b/library/Zend/Cache/Manager.php
index 330ea954e8..02f87cd5f7 100644
--- a/library/Zend/Cache/Manager.php
+++ b/library/Zend/Cache/Manager.php
@@ -133,12 +133,8 @@ public function setCache($name, Zend_Cache_Core $cache)
*/
public function hasCache($name)
{
- if (isset($this->_caches[$name])
- || $this->hasCacheTemplate($name)
- ) {
- return true;
- }
- return false;
+ return isset($this->_caches[$name])
+ || $this->hasCacheTemplate($name);
}
/**
@@ -184,7 +180,7 @@ public function getCache($name)
public function getCaches()
{
$caches = $this->_caches;
- foreach ($this->_optionTemplates as $name => $tmp) {
+ foreach (array_keys($this->_optionTemplates) as $name) {
if (!isset($caches[$name])) {
$caches[$name] = $this->getCache($name);
}
@@ -207,8 +203,7 @@ public function setCacheTemplate($name, $options)
$options = $options->toArray();
} elseif (!is_array($options)) {
require_once 'Zend/Cache/Exception.php';
- throw new Zend_Cache_Exception('Options passed must be in'
- . ' an associative array or instance of Zend_Config');
+ throw new Zend_Cache_Exception('Options passed must be in an associative array or instance of Zend_Config');
}
$this->_optionTemplates[$name] = $options;
return $this;
@@ -222,10 +217,7 @@ public function setCacheTemplate($name, $options)
*/
public function hasCacheTemplate($name)
{
- if (isset($this->_optionTemplates[$name])) {
- return true;
- }
- return false;
+ return isset($this->_optionTemplates[$name]);
}
/**
@@ -257,8 +249,7 @@ public function setTemplateOptions($name, $options)
$options = $options->toArray();
} elseif (!is_array($options)) {
require_once 'Zend/Cache/Exception.php';
- throw new Zend_Cache_Exception('Options passed must be in'
- . ' an associative array or instance of Zend_Config');
+ throw new Zend_Cache_Exception('Options passed must be in an associative array or instance of Zend_Config');
}
if (!isset($this->_optionTemplates[$name])) {
throw new Zend_Cache_Exception('A cache configuration template'
diff --git a/library/Zend/Captcha/Base.php b/library/Zend/Captcha/Base.php
index 69b2d21a66..6966e96a17 100644
--- a/library/Zend/Captcha/Base.php
+++ b/library/Zend/Captcha/Base.php
@@ -96,7 +96,7 @@ public function __construct($options = null)
// Set options
if (is_array($options)) {
$this->setOptions($options);
- } else if ($options instanceof Zend_Config) {
+ } elseif ($options instanceof Zend_Config) {
$this->setConfig($options);
}
}
diff --git a/library/Zend/Captcha/Image.php b/library/Zend/Captcha/Image.php
index acc761b95d..5ecd385d7b 100644
--- a/library/Zend/Captcha/Image.php
+++ b/library/Zend/Captcha/Image.php
@@ -595,13 +595,9 @@ protected function _gc()
}
$suffixLength = strlen($this->_suffix);
foreach (new DirectoryIterator($imgdir) as $file) {
- if (!$file->isDot() && !$file->isDir()) {
- if (file_exists($file->getPathname()) && $file->getMTime() < $expire) {
- // only deletes files ending with $this->_suffix
- if (substr($file->getFilename(), -($suffixLength)) == $this->_suffix) {
- unlink($file->getPathname());
- }
- }
+ // only deletes files ending with $this->_suffix
+ if (!$file->isDot() && !$file->isDir() && (file_exists($file->getPathname()) && $file->getMTime() < $expire) && substr($file->getFilename(), -($suffixLength)) === $this->_suffix) {
+ unlink($file->getPathname());
}
}
}
diff --git a/library/Zend/Captcha/Word.php b/library/Zend/Captcha/Word.php
index 80d8aecb57..1504d4cef8 100644
--- a/library/Zend/Captcha/Word.php
+++ b/library/Zend/Captcha/Word.php
@@ -261,7 +261,7 @@ public function setUseNumbers($_useNumbers)
*/
public function getSession()
{
- if (!isset($this->_session) || (null === $this->_session)) {
+ if (!($this->_session !== null) || (null === $this->_session)) {
$id = $this->getId();
if (!class_exists($this->_sessionClass)) {
require_once 'Zend/Loader.php';
@@ -331,7 +331,7 @@ protected function _generateWord()
$totIndexCon = count($consonants) - 1;
$totIndexVow = count($vowels) - 1;
- for ($i=0; $i < $wordLen; $i = $i + 2) {
+ for ($i=0; $i < $wordLen; $i += 2) {
// generate word with mix of vowels and consonants
$consonant = $consonants[Zend_Crypt_Math::randInteger(0, $totIndexCon, true)];
$vowel = $vowels[Zend_Crypt_Math::randInteger(0, $totIndexVow, true)];
diff --git a/library/Zend/Cloud/DocumentService/Adapter/SimpleDb.php b/library/Zend/Cloud/DocumentService/Adapter/SimpleDb.php
index 0bf4d6d0a5..2957f54b59 100644
--- a/library/Zend/Cloud/DocumentService/Adapter/SimpleDb.php
+++ b/library/Zend/Cloud/DocumentService/Adapter/SimpleDb.php
@@ -160,8 +160,7 @@ public function listCollections($options = null)
public function listDocuments($collectionName, array $options = null)
{
$query = $this->select('*')->from($collectionName);
- $items = $this->query($collectionName, $query, $options);
- return $items;
+ return $this->query($collectionName, $query, $options);
}
/**
diff --git a/library/Zend/Cloud/DocumentService/Adapter/WindowsAzure.php b/library/Zend/Cloud/DocumentService/Adapter/WindowsAzure.php
index 75126dd6ed..707bc4e009 100755
--- a/library/Zend/Cloud/DocumentService/Adapter/WindowsAzure.php
+++ b/library/Zend/Cloud/DocumentService/Adapter/WindowsAzure.php
@@ -107,11 +107,7 @@ public function __construct($options = array())
}
// Build Zend_Service_WindowsAzure_Storage_Blob instance
- if (!isset($options[self::HOST])) {
- $host = self::DEFAULT_HOST;
- } else {
- $host = $options[self::HOST];
- }
+ $host = isset($options[self::HOST]) ? $options[self::HOST] : self::DEFAULT_HOST;
if (! isset($options[self::ACCOUNT_NAME])) {
throw new Zend_Cloud_DocumentService_Exception('No Windows Azure account name provided.');
@@ -360,7 +356,7 @@ public function updateDocument($collectionName, $documentId, $fieldset = null, $
$fieldset = $fieldset->getFields();
}
- $this->_validateCompositeKey($documentId, $collectionName);
+ $this->_validateCompositeKey($documentId);
$this->_validateFields($fieldset);
try {
$entity = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity($documentId[0], $documentId[1]);
@@ -525,7 +521,7 @@ protected function _resolveAttributes(Zend_Service_WindowsAzure_Storage_TableEnt
*/
protected function _validateKey($key)
{
- if (preg_match('@[/#?' . preg_quote('\\') . ']@', $key)) {
+ if (preg_match('@[/#?' . preg_quote('\\', '@') . ']@', $key)) {
throw new Zend_Cloud_DocumentService_Exception('Invalid partition or row key provided; must not contain /, \\, #, or ? characters');
}
}
diff --git a/library/Zend/Cloud/DocumentService/Query.php b/library/Zend/Cloud/DocumentService/Query.php
index 24ac3a5135..061aaed755 100644
--- a/library/Zend/Cloud/DocumentService/Query.php
+++ b/library/Zend/Cloud/DocumentService/Query.php
@@ -146,7 +146,7 @@ public function whereId($value)
*/
public function limit($limit)
{
- if ($limit != (int) $limit) {
+ if ($limit !== (int) $limit) {
require_once 'Zend/Cloud/DocumentService/Exception.php';
throw new Zend_Cloud_DocumentService_Exception("LIMIT argument must be an integer");
}
diff --git a/library/Zend/Cloud/Infrastructure/Adapter/AbstractAdapter.php b/library/Zend/Cloud/Infrastructure/Adapter/AbstractAdapter.php
index ecdef16eb1..bcbe1c89f8 100644
--- a/library/Zend/Cloud/Infrastructure/Adapter/AbstractAdapter.php
+++ b/library/Zend/Cloud/Infrastructure/Adapter/AbstractAdapter.php
@@ -78,7 +78,7 @@ public function waitStatusInstance($id, $status, $timeout = self::TIMEOUT_STATUS
}
$num = 0;
- while (($num<$timeout) && ($this->statusInstance($id) != $status)) {
+ while (($num<$timeout) && ($this->statusInstance($id) !== $status)) {
sleep(self::TIME_STEP_STATUS_CHANGE);
$num += self::TIME_STEP_STATUS_CHANGE;
}
@@ -147,11 +147,7 @@ public function deployInstance($id, $params, $cmd)
$output = stream_get_contents($stream);
$error = stream_get_contents($errorStream);
- if (empty($error)) {
- $result[$command] = $output;
- } else {
- $result[$command] = $error;
- }
+ $result[$command] = empty($error) ? $output : $error;
}
} else {
$stream = ssh2_exec($conn, $cmd);
@@ -164,11 +160,7 @@ public function deployInstance($id, $params, $cmd)
$output = stream_get_contents($stream);
$error = stream_get_contents($errorStream);
- if (empty($error)) {
- $result = $output;
- } else {
- $result = $error;
- }
+ $result = empty($error) ? $output : $error;
}
return $result;
}
diff --git a/library/Zend/Cloud/Infrastructure/Adapter/Ec2.php b/library/Zend/Cloud/Infrastructure/Adapter/Ec2.php
index 48fdac5835..bfbb12e9e9 100644
--- a/library/Zend/Cloud/Infrastructure/Adapter/Ec2.php
+++ b/library/Zend/Cloud/Infrastructure/Adapter/Ec2.php
@@ -27,6 +27,7 @@
*/
class Zend_Cloud_Infrastructure_Adapter_Ec2 extends Zend_Cloud_Infrastructure_Adapter_AbstractAdapter
{
+ public bool $error;
/**
* AWS constants
*/
@@ -333,7 +334,7 @@ public function destroyInstance($id)
*/
public function imagesInstance()
{
- if (!isset($this->ec2Image)) {
+ if (!($this->ec2Image !== null)) {
$this->ec2Image = new Zend_Service_Amazon_Ec2_Image($this->accessKey, $this->accessSecret, $this->region);
}
@@ -370,7 +371,7 @@ public function imagesInstance()
*/
public function zonesInstance()
{
- if (!isset($this->ec2Zone)) {
+ if (!($this->ec2Zone !== null)) {
$this->ec2Zone = new Zend_Service_Amazon_Ec2_Availabilityzones($this->accessKey,$this->accessSecret,$this->region);
}
$this->adapterResult = $this->ec2Zone->describe();
@@ -425,7 +426,7 @@ public function monitorInstance($id, $metric, $options = null)
));
}
- if (!isset($this->ec2Monitor)) {
+ if (!($this->ec2Monitor !== null)) {
$this->ec2Monitor = new Zend_Service_Amazon_Ec2_CloudWatch($this->accessKey, $this->accessSecret, $this->region);
}
diff --git a/library/Zend/Cloud/Infrastructure/ImageList.php b/library/Zend/Cloud/Infrastructure/ImageList.php
index 21e3a89bf0..1ce3e3dfd9 100644
--- a/library/Zend/Cloud/Infrastructure/ImageList.php
+++ b/library/Zend/Cloud/Infrastructure/ImageList.php
@@ -150,10 +150,7 @@ public function rewind()
public function valid()
{
$numItems = $this->count();
- if ($numItems > 0 && $this->iteratorKey < $numItems) {
- return true;
- }
- return false;
+ return $numItems > 0 && $this->iteratorKey < $numItems;
}
/**
diff --git a/library/Zend/Cloud/Infrastructure/InstanceList.php b/library/Zend/Cloud/Infrastructure/InstanceList.php
index 02ff7b2856..633e0c76ca 100644
--- a/library/Zend/Cloud/Infrastructure/InstanceList.php
+++ b/library/Zend/Cloud/Infrastructure/InstanceList.php
@@ -151,10 +151,7 @@ public function rewind()
public function valid()
{
$numItems = $this->count();
- if ($numItems > 0 && $this->iteratorKey < $numItems) {
- return true;
- }
- return false;
+ return $numItems > 0 && $this->iteratorKey < $numItems;
}
/**
diff --git a/library/Zend/Cloud/QueueService/Adapter/WindowsAzure.php b/library/Zend/Cloud/QueueService/Adapter/WindowsAzure.php
index 656dddb6b6..7998fed366 100755
--- a/library/Zend/Cloud/QueueService/Adapter/WindowsAzure.php
+++ b/library/Zend/Cloud/QueueService/Adapter/WindowsAzure.php
@@ -84,11 +84,7 @@ public function __construct($options = array())
}
// Build Zend_Service_WindowsAzure_Storage_Blob instance
- if (!isset($options[self::HOST])) {
- $host = self::DEFAULT_HOST;
- } else {
- $host = $options[self::HOST];
- }
+ $host = isset($options[self::HOST]) ? $options[self::HOST] : self::DEFAULT_HOST;
if (! isset($options[self::ACCOUNT_NAME])) {
throw new Zend_Cloud_Storage_Exception('No Windows Azure account name provided.');
}
@@ -256,11 +252,7 @@ public function receiveMessages($queueId, $max = 1, $options = null)
if ($queueId instanceof Zend_Service_WindowsAzure_Storage_QueueInstance) {
$queueId = $queueId->Name;
}
- if (isset($options[self::VISIBILITY_TIMEOUT])) {
- $visibility = $options[self::VISIBILITY_TIMEOUT];
- } else {
- $visibility = self::DEFAULT_TIMEOUT;
- }
+ $visibility = isset($options[self::VISIBILITY_TIMEOUT]) ? $options[self::VISIBILITY_TIMEOUT] : self::DEFAULT_TIMEOUT;
return $this->_makeMessages($this->_storageClient->getMessages($queueId, $max, $visibility, false));
} catch (Zend_Service_WindowsAzure_Exception $e) {
throw new Zend_Cloud_QueueService_Exception('Error on recieving messages: '.$e->getMessage(), $e->getCode(), $e);
diff --git a/library/Zend/Cloud/StorageService/Adapter/Rackspace.php b/library/Zend/Cloud/StorageService/Adapter/Rackspace.php
index 02980d0c36..8e63546ec9 100644
--- a/library/Zend/Cloud/StorageService/Adapter/Rackspace.php
+++ b/library/Zend/Cloud/StorageService/Adapter/Rackspace.php
@@ -91,7 +91,7 @@ function __construct($options = array())
public function fetchItem($path, $options = null)
{
$item = $this->_rackspace->getObject($this->_container,$path, $options);
- if (!$this->_rackspace->isSuccessful() && ($this->_rackspace->getErrorCode()!='404')) {
+ if (!$this->_rackspace->isSuccessful() && ($this->_rackspace->getErrorCode() != '404')) {
throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$this->_rackspace->getErrorMsg());
}
if (!empty($item)) {
@@ -163,13 +163,13 @@ public function moveItem($sourcePath, $destinationPath, $options = null)
try {
$this->copyItem($sourcePath, $destinationPath, $options);
} catch (Zend_Service_Rackspace_Exception $e) {
- throw new Zend_Cloud_StorageService_Exception('Error on move: '.$e->getMessage());
+ throw new Zend_Cloud_StorageService_Exception('Error on move: '.$e->getMessage(), $e->getCode(), $e);
}
try {
$this->deleteItem($sourcePath);
} catch (Zend_Service_Rackspace_Exception $e) {
$this->deleteItem($destinationPath);
- throw new Zend_Cloud_StorageService_Exception('Error on move: '.$e->getMessage());
+ throw new Zend_Cloud_StorageService_Exception('Error on move: '.$e->getMessage(), $e->getCode(), $e);
}
}
@@ -247,19 +247,19 @@ public function deleteMetadata($path, $metadata = null, $options = null)
try {
$this->storeMetadata($path, $newMetadata);
} catch (Zend_Service_Rackspace_Exception $e) {
- throw new Zend_Cloud_StorageService_Exception('Error on delete metadata: '.$e->getMessage());
+ throw new Zend_Cloud_StorageService_Exception('Error on delete metadata: '.$e->getMessage(), $e->getCode(), $e);
}
} else {
try {
$oldMetadata = $this->fetchMetadata($path);
} catch (Zend_Service_Rackspace_Exception $e) {
- throw new Zend_Cloud_StorageService_Exception('Error on delete metadata: '.$e->getMessage());
+ throw new Zend_Cloud_StorageService_Exception('Error on delete metadata: '.$e->getMessage(), $e->getCode(), $e);
}
$newMetadata = array_diff_assoc($oldMetadata, $metadata);
try {
$this->storeMetadata($path, $newMetadata);
} catch (Zend_Service_Rackspace_Exception $e) {
- throw new Zend_Cloud_StorageService_Exception('Error on delete metadata: '.$e->getMessage());
+ throw new Zend_Cloud_StorageService_Exception('Error on delete metadata: '.$e->getMessage(), $e->getCode(), $e);
}
}
}
diff --git a/library/Zend/Cloud/StorageService/Adapter/S3.php b/library/Zend/Cloud/StorageService/Adapter/S3.php
index 05ec1405d4..c828e93e61 100644
--- a/library/Zend/Cloud/StorageService/Adapter/S3.php
+++ b/library/Zend/Cloud/StorageService/Adapter/S3.php
@@ -304,7 +304,7 @@ protected function _getFullPath($path, $options)
{
if (isset($options[self::BUCKET_NAME])) {
$bucket = $options[self::BUCKET_NAME];
- } else if (isset($this->_defaultBucketName)) {
+ } elseif ($this->_defaultBucketName !== null) {
$bucket = $this->_defaultBucketName;
} else {
require_once 'Zend/Cloud/StorageService/Exception.php';
diff --git a/library/Zend/Cloud/StorageService/Adapter/WindowsAzure.php b/library/Zend/Cloud/StorageService/Adapter/WindowsAzure.php
index 618f463c24..01fa14d390 100644
--- a/library/Zend/Cloud/StorageService/Adapter/WindowsAzure.php
+++ b/library/Zend/Cloud/StorageService/Adapter/WindowsAzure.php
@@ -86,11 +86,7 @@ public function __construct($options = array())
}
// Build Zend_Service_WindowsAzure_Storage_Blob instance
- if (!isset($options[self::HOST])) {
- $host = self::DEFAULT_HOST;
- } else {
- $host = $options[self::HOST];
- }
+ $host = isset($options[self::HOST]) ? $options[self::HOST] : self::DEFAULT_HOST;
if (!isset($options[self::ACCOUNT_NAME])) {
throw new Zend_Cloud_StorageService_Exception('No Windows Azure account name provided.');
diff --git a/library/Zend/CodeGenerator/Php/Abstract.php b/library/Zend/CodeGenerator/Php/Abstract.php
index fc4e4bfd05..85c01271dd 100644
--- a/library/Zend/CodeGenerator/Php/Abstract.php
+++ b/library/Zend/CodeGenerator/Php/Abstract.php
@@ -58,7 +58,7 @@ abstract class Zend_CodeGenerator_Php_Abstract extends Zend_CodeGenerator_Abstra
*/
public function setSourceDirty($isSourceDirty = true)
{
- $this->_isSourceDirty = ($isSourceDirty) ? true : false;
+ $this->_isSourceDirty = $isSourceDirty;
return $this;
}
diff --git a/library/Zend/CodeGenerator/Php/Class.php b/library/Zend/CodeGenerator/Php/Class.php
index 02d5210172..4381c3c306 100644
--- a/library/Zend/CodeGenerator/Php/Class.php
+++ b/library/Zend/CodeGenerator/Php/Class.php
@@ -210,7 +210,7 @@ public function getName()
*/
public function setAbstract($isAbstract)
{
- $this->_isAbstract = ($isAbstract) ? true : false;
+ $this->_isAbstract = $isAbstract;
return $this;
}
@@ -599,9 +599,7 @@ public function generate()
}
}
- $output .= self::LINE_FEED . '}' . self::LINE_FEED;
-
- return $output;
+ return $output . (self::LINE_FEED . '}' . self::LINE_FEED);
}
/**
diff --git a/library/Zend/CodeGenerator/Php/Docblock.php b/library/Zend/CodeGenerator/Php/Docblock.php
index fe5ecfd96a..c97aebd5e6 100644
--- a/library/Zend/CodeGenerator/Php/Docblock.php
+++ b/library/Zend/CodeGenerator/Php/Docblock.php
@@ -213,15 +213,13 @@ protected function _docCommentize($content)
foreach ($lines as $line) {
$output .= $indent . ' *';
- if ($line) {
+ if ($line !== '' && $line !== '0') {
$output .= " $line";
}
$output .= self::LINE_FEED;
}
$output = rtrim($output, ' *' . self::LINE_FEED) . self::LINE_FEED;
-
- $output .= $indent . ' */' . self::LINE_FEED;
- return $output;
+ return $output . ($indent . ' */' . self::LINE_FEED);
}
}
diff --git a/library/Zend/CodeGenerator/Php/Docblock/Tag.php b/library/Zend/CodeGenerator/Php/Docblock/Tag.php
index bfb6c3a5df..a7ae36af71 100644
--- a/library/Zend/CodeGenerator/Php/Docblock/Tag.php
+++ b/library/Zend/CodeGenerator/Php/Docblock/Tag.php
@@ -112,9 +112,7 @@ public static function factory($tagName)
} catch (Zend_Loader_Exception $exception) {
$tagClass = 'Zend_CodeGenerator_Php_Docblock_Tag';
}
-
- $tag = new $tagClass(array('name' => $tagName));
- return $tag;
+ return new $tagClass(array('name' => $tagName));
}
/**
@@ -169,7 +167,7 @@ public function getDescription()
public function generate()
{
$tag = '@' . $this->_name;
- if ($this->_description) {
+ if ($this->_description !== '' && $this->_description !== '0') {
$tag .= ' ' . $this->_description;
}
return $tag;
diff --git a/library/Zend/CodeGenerator/Php/Docblock/Tag/License.php b/library/Zend/CodeGenerator/Php/Docblock/Tag/License.php
index 9642e6df5e..f09f0d7f5e 100644
--- a/library/Zend/CodeGenerator/Php/Docblock/Tag/License.php
+++ b/library/Zend/CodeGenerator/Php/Docblock/Tag/License.php
@@ -91,8 +91,7 @@ public function getUrl()
*/
public function generate()
{
- $output = '@license ' . $this->_url . ' ' . $this->_description . self::LINE_FEED;
- return $output;
+ return '@license ' . $this->_url . ' ' . $this->_description . self::LINE_FEED;
}
}
diff --git a/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php b/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php
index 64ff2f72e0..11effdfcb5 100644
--- a/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php
+++ b/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php
@@ -118,11 +118,10 @@ public function getParamName()
*/
public function generate()
{
- $output = '@param '
- . (($this->_datatype != null) ? $this->_datatype : 'unknown')
+ return '@param '
+ . (($this->_datatype != null) ? $this->_datatype : 'unknown')
. (($this->_paramName != null) ? ' $' . $this->_paramName : '')
. (($this->_description != null) ? ' ' . $this->_description : '');
- return $output;
}
}
diff --git a/library/Zend/CodeGenerator/Php/Docblock/Tag/Return.php b/library/Zend/CodeGenerator/Php/Docblock/Tag/Return.php
index 60dcf30041..e0bb55fd1a 100644
--- a/library/Zend/CodeGenerator/Php/Docblock/Tag/Return.php
+++ b/library/Zend/CodeGenerator/Php/Docblock/Tag/Return.php
@@ -91,8 +91,7 @@ public function getDatatype()
*/
public function generate()
{
- $output = '@return ' . $this->_datatype . ' ' . $this->_description;
- return $output;
+ return '@return ' . $this->_datatype . ' ' . $this->_description;
}
}
diff --git a/library/Zend/CodeGenerator/Php/File.php b/library/Zend/CodeGenerator/Php/File.php
index cfea53dbe4..3346d58db2 100644
--- a/library/Zend/CodeGenerator/Php/File.php
+++ b/library/Zend/CodeGenerator/Php/File.php
@@ -109,11 +109,9 @@ public static function fromReflectedFileName($filePath, $usePreviousCodeGenerato
{
$realpath = realpath($filePath);
- if ($realpath === false) {
- if ( ($realpath = Zend_Reflection_File::findRealpathInIncludePath($filePath)) === false) {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('No file for ' . $realpath . ' was found.');
- }
+ if ($realpath === false && ($realpath = Zend_Reflection_File::findRealpathInIncludePath($filePath)) === false) {
+ require_once 'Zend/CodeGenerator/Php/Exception.php';
+ throw new Zend_CodeGenerator_Php_Exception('No file for ' . $realpath . ' was found.');
}
if ($usePreviousCodeGeneratorIfItExists && isset(self::$_fileCodeGenerators[$realpath])) {
@@ -156,7 +154,8 @@ public static function fromReflection(Zend_Reflection_File $reflectionFile)
$bodyLines = explode("\n", $body);
$bodyReturn = array();
- for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) {
+ $bodyLinesCount = count($bodyLines);
+ for ($lineNum = 1; $lineNum <= $bodyLinesCount; $lineNum++) {
if ($lineNum == $classStartLine) {
$bodyReturn[] = str_replace('?', $class->getName(), self::$_markerClass); //'/* Zend_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */';
$lineNum = $classEndLine;
@@ -174,8 +173,9 @@ public static function fromReflection(Zend_Reflection_File $reflectionFile)
$bodyLines = explode("\n", $body);
$bodyReturn = array();
- for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) {
- if ($lineNum == $docblock->getStartLine()) {
+ $bodyLinesCount = count($bodyLines);
+ for ($lineNum = 1; $lineNum <= $bodyLinesCount; $lineNum++) {
+ if ($lineNum === $docblock->getStartLine()) {
$bodyReturn[] = str_replace('?', $class->getName(), self::$_markerDocblock); //'/* Zend_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */';
$lineNum = $docblock->getEndLine();
} else {
@@ -381,7 +381,7 @@ public function isSourceDirty()
*/
public function generate()
{
- if ($this->isSourceDirty() === false) {
+ if (!$this->isSourceDirty()) {
return $this->_sourceContent;
}
diff --git a/library/Zend/CodeGenerator/Php/Member/Abstract.php b/library/Zend/CodeGenerator/Php/Member/Abstract.php
index 4875242a6b..1731867b43 100644
--- a/library/Zend/CodeGenerator/Php/Member/Abstract.php
+++ b/library/Zend/CodeGenerator/Php/Member/Abstract.php
@@ -118,7 +118,7 @@ public function getDocblock()
*/
public function setAbstract($isAbstract)
{
- $this->_isAbstract = ($isAbstract) ? true : false;
+ $this->_isAbstract = $isAbstract;
return $this;
}
@@ -139,7 +139,7 @@ public function isAbstract()
*/
public function setFinal($isFinal)
{
- $this->_isFinal = ($isFinal) ? true : false;
+ $this->_isFinal = $isFinal;
return $this;
}
@@ -161,7 +161,7 @@ public function isFinal()
*/
public function setStatic($isStatic)
{
- $this->_isStatic = ($isStatic) ? true : false;
+ $this->_isStatic = $isStatic;
return $this;
}
diff --git a/library/Zend/CodeGenerator/Php/Method.php b/library/Zend/CodeGenerator/Php/Method.php
index 26c498bb5c..ae4eeba495 100644
--- a/library/Zend/CodeGenerator/Php/Method.php
+++ b/library/Zend/CodeGenerator/Php/Method.php
@@ -110,7 +110,7 @@ public static function fromReflection(Zend_Reflection_Method $reflectionMethod)
*/
public function setFinal($isFinal)
{
- $this->_isFinal = ($isFinal) ? true : false;
+ $this->_isFinal = $isFinal;
return $this;
}
@@ -225,13 +225,11 @@ public function generate()
$output .= ' '
. str_replace(self::LINE_FEED, self::LINE_FEED . $indent . $indent, trim($this->_body))
. self::LINE_FEED;
- } elseif ($this->_body) {
+ } elseif ($this->_body !== '' && $this->_body !== '0') {
$output .= $this->_body . self::LINE_FEED;
}
- $output .= $indent . '}' . self::LINE_FEED;
-
- return $output;
+ return $output . ($indent . '}' . self::LINE_FEED);
}
}
diff --git a/library/Zend/CodeGenerator/Php/Parameter.php b/library/Zend/CodeGenerator/Php/Parameter.php
index ce62706e5a..646aef2d30 100644
--- a/library/Zend/CodeGenerator/Php/Parameter.php
+++ b/library/Zend/CodeGenerator/Php/Parameter.php
@@ -147,12 +147,12 @@ public function getName()
*/
public function setDefaultValue($defaultValue)
{
- if($defaultValue === null) {
+ if ($defaultValue === null) {
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("null");
- } else if(is_array($defaultValue)) {
+ } elseif (is_array($defaultValue)) {
$defaultValue = str_replace(array("\r", "\n"), "", var_export($defaultValue, true));
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue($defaultValue);
- } else if(is_bool($defaultValue)) {
+ } elseif (is_bool($defaultValue)) {
if($defaultValue == true) {
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("true");
} else {
@@ -223,11 +223,11 @@ public function generate()
{
$output = '';
- if ($this->_type) {
+ if ($this->_type !== '' && $this->_type !== '0') {
$output .= $this->_type . ' ';
}
- if($this->_passedByReference === true) {
+ if($this->_passedByReference) {
$output .= '&';
}
@@ -237,7 +237,7 @@ public function generate()
$output .= ' = ';
if (is_string($this->_defaultValue)) {
$output .= '\'' . $this->_defaultValue . '\'';
- } else if($this->_defaultValue instanceof Zend_CodeGenerator_Php_Parameter_DefaultValue) {
+ } elseif ($this->_defaultValue instanceof Zend_CodeGenerator_Php_Parameter_DefaultValue) {
$output .= (string)$this->_defaultValue;
} else {
$output .= $this->_defaultValue;
diff --git a/library/Zend/CodeGenerator/Php/Property.php b/library/Zend/CodeGenerator/Php/Property.php
index af5408f91d..a28f47c5e5 100644
--- a/library/Zend/CodeGenerator/Php/Property.php
+++ b/library/Zend/CodeGenerator/Php/Property.php
@@ -105,7 +105,7 @@ public function setConst($const)
*/
public function isConst()
{
- return ($this->_isConst) ? true : false;
+ return $this->_isConst;
}
/**
diff --git a/library/Zend/CodeGenerator/Php/Property/DefaultValue.php b/library/Zend/CodeGenerator/Php/Property/DefaultValue.php
index 1eeed9576f..6a59533d44 100644
--- a/library/Zend/CodeGenerator/Php/Property/DefaultValue.php
+++ b/library/Zend/CodeGenerator/Php/Property/DefaultValue.php
@@ -92,11 +92,7 @@ protected function _init()
*/
public function isValidConstantType()
{
- if ($this->_type == self::TYPE_AUTO) {
- $type = $this->_getAutoDeterminedType($this->_value);
- } else {
- $type = $this->_type;
- }
+ $type = $this->_type == self::TYPE_AUTO ? $this->_getAutoDeterminedType($this->_value) : $this->_type;
// valid types for constants
$scalarTypes = array(
@@ -318,8 +314,6 @@ public function generate()
);
}
- $output .= ';';
-
- return $output;
+ return $output . ';';
}
}
diff --git a/library/Zend/Config.php b/library/Zend/Config.php
index a39a1f2255..85dafcff18 100644
--- a/library/Zend/Config.php
+++ b/library/Zend/Config.php
@@ -109,11 +109,7 @@ public function __construct(array $array, $allowModifications = false)
$this->_index = 0;
$this->_data = array();
foreach ($array as $key => $value) {
- if (is_array($value)) {
- $this->_data[$key] = new self($value, $this->_allowModifications);
- } else {
- $this->_data[$key] = $value;
- }
+ $this->_data[$key] = is_array($value) ? new self($value, $this->_allowModifications) : $value;
}
$this->_count = count($this->_data);
}
@@ -157,11 +153,7 @@ public function __get($name)
public function __set($name, $value)
{
if ($this->_allowModifications) {
- if (is_array($value)) {
- $this->_data[$name] = new self($value, true);
- } else {
- $this->_data[$name] = $value;
- }
+ $this->_data[$name] = is_array($value) ? new self($value, true) : $value;
$this->_count = count($this->_data);
} else {
/** @see Zend_Config_Exception */
@@ -180,11 +172,7 @@ public function __clone()
{
$array = array();
foreach ($this->_data as $key => $value) {
- if ($value instanceof Zend_Config) {
- $array[$key] = clone $value;
- } else {
- $array[$key] = $value;
- }
+ $array[$key] = $value instanceof Zend_Config ? clone $value : $value;
}
$this->_data = $array;
}
@@ -199,11 +187,7 @@ public function toArray()
$array = array();
$data = $this->_data;
foreach ($data as $key => $value) {
- if ($value instanceof Zend_Config) {
- $array[$key] = $value->toArray();
- } else {
- $array[$key] = $value;
- }
+ $array[$key] = $value instanceof Zend_Config ? $value->toArray() : $value;
}
return $array;
}
@@ -245,7 +229,7 @@ public function __unset($name)
*
* @return int
*/
- public function count()
+ public function count(): int
{
return $this->_count;
}
@@ -255,7 +239,7 @@ public function count()
*
* @return mixed
*/
- public function current()
+ public function current(): mixed
{
$this->_skipNextIteration = false;
return current($this->_data);
@@ -266,7 +250,7 @@ public function current()
*
* @return mixed
*/
- public function key()
+ public function key(): mixed
{
return key($this->_data);
}
@@ -275,7 +259,7 @@ public function key()
* Defined by Iterator interface
*
*/
- public function next()
+ public function next(): void
{
if ($this->_skipNextIteration) {
$this->_skipNextIteration = false;
@@ -289,7 +273,7 @@ public function next()
* Defined by Iterator interface
*
*/
- public function rewind()
+ public function rewind(): void
{
$this->_skipNextIteration = false;
reset($this->_data);
@@ -301,7 +285,7 @@ public function rewind()
*
* @return boolean
*/
- public function valid()
+ public function valid(): bool
{
return $this->_index < $this->_count;
}
@@ -348,11 +332,7 @@ public function merge(Zend_Config $merge)
$this->$key = $item;
}
} else {
- if($item instanceof Zend_Config) {
- $this->$key = new Zend_Config($item->toArray(), !$this->readOnly());
- } else {
- $this->$key = $item;
- }
+ $this->$key = $item instanceof Zend_Config ? new Zend_Config($item->toArray(), !$this->readOnly()) : $item;
}
}
@@ -406,7 +386,7 @@ public function setExtend($extendingSection, $extendedSection = null)
{
if ($extendedSection === null && isset($this->_extends[$extendingSection])) {
unset($this->_extends[$extendingSection]);
- } else if ($extendedSection !== null) {
+ } elseif ($extendedSection !== null) {
$this->_extends[$extendingSection] = $extendedSection;
}
}
@@ -467,12 +447,10 @@ protected function _arrayMergeRecursive($firstArray, $secondArray)
foreach ($secondArray as $key => $value) {
if (isset($firstArray[$key])) {
$firstArray[$key] = $this->_arrayMergeRecursive($firstArray[$key], $value);
+ } elseif ($key === 0) {
+ $firstArray= array(0=>$this->_arrayMergeRecursive($firstArray, $value));
} else {
- if($key === 0) {
- $firstArray= array(0=>$this->_arrayMergeRecursive($firstArray, $value));
- } else {
- $firstArray[$key] = $value;
- }
+ $firstArray[$key] = $value;
}
}
} else {
diff --git a/library/Zend/Config/Ini.php b/library/Zend/Config/Ini.php
index cc9fffa99d..8786755868 100644
--- a/library/Zend/Config/Ini.php
+++ b/library/Zend/Config/Ini.php
@@ -169,7 +169,9 @@ public function __construct($filename, $section = null, $options = false)
*/
protected function _parseIniFile($filename)
{
- set_error_handler(array($this, '_loadFileErrorHandler'));
+ set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) {
+ return $this->_loadFileErrorHandler($errno, $errstr, $errfile, $errline);
+ });
$iniArray = parse_ini_file($filename, true); // Warnings and errors are suppressed
restore_error_handler();
diff --git a/library/Zend/Config/Json.php b/library/Zend/Config/Json.php
index 2c31fdc014..a38766f194 100755
--- a/library/Zend/Config/Json.php
+++ b/library/Zend/Config/Json.php
@@ -110,7 +110,9 @@ public function __construct($json, $section = null, $options = false)
}
}
- set_error_handler(array($this, '_loadFileErrorHandler')); // Warnings and errors are suppressed
+ set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) {
+ return $this->_loadFileErrorHandler($errno, $errstr, $errfile, $errline);
+ }); // Warnings and errors are suppressed
if ($json[0] != '{') {
$json = file_get_contents($json);
}
@@ -133,7 +135,7 @@ public function __construct($json, $section = null, $options = false)
} catch (Zend_Json_Exception $e) {
// decode failed
require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Error parsing JSON data");
+ throw new Zend_Config_Exception("Error parsing JSON data", $e->getCode(), $e);
}
if ($section === null) {
@@ -205,9 +207,7 @@ protected function _processExtends(array $data, $section, array $config = array(
unset($thisSection[self::EXTENDS_NAME]);
}
- $config = $this->_arrayMergeRecursive($config, $thisSection);
-
- return $config;
+ return $this->_arrayMergeRecursive($config, $thisSection);
}
/**
diff --git a/library/Zend/Config/Writer/Array.php b/library/Zend/Config/Writer/Array.php
index 50c260e0cf..b88d5479aa 100644
--- a/library/Zend/Config/Writer/Array.php
+++ b/library/Zend/Config/Writer/Array.php
@@ -47,9 +47,7 @@ public function render()
$data = array($sectionName => $data);
}
- $arrayString = "_config->getExtends();
$sectionName = $this->_config->getSectionName();
- if($this->_renderWithoutSections == true) {
+ if ($this->_renderWithoutSections == true) {
$iniString .= $this->_addBranch($this->_config);
- } else if (is_string($sectionName)) {
+ } elseif (is_string($sectionName)) {
$iniString .= '[' . $sectionName . ']' . "\n"
. $this->_addBranch($this->_config)
. "\n";
@@ -148,7 +148,7 @@ protected function _addBranch(Zend_Config $config, $parents = array())
*/
protected function _prepareValue($value)
{
- if (is_integer($value) || is_float($value)) {
+ if (is_int($value) || is_float($value)) {
return $value;
} elseif (is_bool($value)) {
return ($value ? 'true' : 'false');
diff --git a/library/Zend/Config/Writer/Xml.php b/library/Zend/Config/Writer/Xml.php
index c73564b219..b3b3aed763 100644
--- a/library/Zend/Config/Writer/Xml.php
+++ b/library/Zend/Config/Writer/Xml.php
@@ -72,9 +72,7 @@ public function render()
$dom = dom_import_simplexml($xml)->ownerDocument;
$dom->formatOutput = true;
- $xmlString = $dom->saveXML();
-
- return $xmlString;
+ return $dom->saveXML();
}
/**
@@ -100,7 +98,7 @@ protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, Simple
} else {
$branchType = 'string';
}
- } else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
+ } elseif ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
}
@@ -113,14 +111,11 @@ protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, Simple
} else {
$parent->addChild($branchName, (string) $value);
}
+ } elseif ($value instanceof Zend_Config) {
+ $child = $xml->addChild($key);
+ $this->_addBranch($value, $child, $xml);
} else {
- if ($value instanceof Zend_Config) {
- $child = $xml->addChild($key);
-
- $this->_addBranch($value, $child, $xml);
- } else {
- $xml->addChild($key, (string) $value);
- }
+ $xml->addChild($key, (string) $value);
}
}
}
diff --git a/library/Zend/Config/Writer/Yaml.php b/library/Zend/Config/Writer/Yaml.php
index 4d2b1fed44..6ccb04cd19 100755
--- a/library/Zend/Config/Writer/Yaml.php
+++ b/library/Zend/Config/Writer/Yaml.php
@@ -132,11 +132,7 @@ protected static function _encodeYaml($indent, $data)
$numeric = is_numeric(key($data));
foreach($data as $key => $value) {
- if(is_array($value)) {
- $encoded = "\n".self::_encodeYaml($indent+1, $value);
- } else {
- $encoded = (string)$value."\n";
- }
+ $encoded = is_array($value) ? "\n".self::_encodeYaml($indent+1, $value) : (string)$value."\n";
$result .= str_repeat(" ", $indent).($numeric?"- ":"$key: ").$encoded;
}
return $result;
diff --git a/library/Zend/Config/Xml.php b/library/Zend/Config/Xml.php
index 4425a8b705..d05116ffa3 100644
--- a/library/Zend/Config/Xml.php
+++ b/library/Zend/Config/Xml.php
@@ -100,7 +100,9 @@ public function __construct($xml, $section = null, $options = false)
}
}
- set_error_handler(array($this, '_loadFileErrorHandler')); // Warnings and errors are suppressed
+ set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) {
+ return $this->_loadFileErrorHandler($errno, $errstr, $errfile, $errline);
+ }); // Warnings and errors are suppressed
if (strstr($xml, 'getMessage()
- );
+ throw new Zend_Config_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@@ -131,9 +131,8 @@ public function __construct($xml, $section = null, $options = false)
foreach ($config as $sectionName => $sectionData) {
$dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
}
-
parent::__construct($dataArray, $allowModifications);
- } else if (is_array($section)) {
+ } elseif (is_array($section)) {
$dataArray = array();
foreach ($section as $sectionName) {
if (!isset($config->$sectionName)) {
@@ -143,7 +142,6 @@ public function __construct($xml, $section = null, $options = false)
$dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
}
-
parent::__construct($dataArray, $allowModifications);
} else {
if (!isset($config->$section)) {
@@ -192,9 +190,7 @@ protected function _processExtends(SimpleXMLElement $element, $section, array $c
}
}
- $config = $this->_arrayMergeRecursive($config, $this->_toArray($thisSection));
-
- return $config;
+ return $this->_arrayMergeRecursive($config, $this->_toArray($thisSection));
}
/**
@@ -282,13 +278,9 @@ protected function _toArray(SimpleXMLElement $xmlObject)
foreach ($xmlObject->children() as $key => $value) {
if (count($value->children()) > 0 || count($value->children(self::XML_NAMESPACE)) > 0) {
$value = $this->_toArray($value);
- } else if (count($value->attributes()) > 0) {
+ } elseif (count($value->attributes()) > 0) {
$attributes = $value->attributes();
- if (isset($attributes['value'])) {
- $value = (string) $attributes['value'];
- } else {
- $value = $this->_toArray($value);
- }
+ $value = isset($attributes['value']) ? (string) $attributes['value'] : $this->_toArray($value);
} else {
$value = (string) $value;
}
@@ -303,7 +295,7 @@ protected function _toArray(SimpleXMLElement $xmlObject)
$config[$key] = $value;
}
}
- } else if (!isset($xmlObject['extends']) && !isset($nsAttributes['extends']) && (count($config) === 0)) {
+ } elseif (!isset($xmlObject['extends']) && !isset($nsAttributes['extends']) && ($config === [])) {
// Object has no children nor attributes and doesn't use the extends
// attribute: it's a string
$config = (string) $xmlObject;
diff --git a/library/Zend/Config/Yaml.php b/library/Zend/Config/Yaml.php
index 8a1a1f2123..4f71401e8b 100755
--- a/library/Zend/Config/Yaml.php
+++ b/library/Zend/Config/Yaml.php
@@ -165,7 +165,9 @@ public function __construct($yaml, $section = null, $options = false)
}
// Suppress warnings and errors while loading file
- set_error_handler(array($this, '_loadFileErrorHandler'));
+ set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) {
+ return $this->_loadFileErrorHandler($errno, $errstr, $errfile, $errline);
+ });
$yaml = file_get_contents($yaml);
restore_error_handler();
@@ -258,9 +260,7 @@ protected function _processExtends(array $data, $section, array $config = array(
unset($thisSection[self::EXTENDS_NAME]);
}
- $config = $this->_arrayMergeRecursive($config, $thisSection);
-
- return $config;
+ return $this->_arrayMergeRecursive($config, $thisSection);
}
/**
@@ -318,14 +318,14 @@ protected static function _decodeYaml($currentIndent, &$lines)
if (preg_match("/(?!-)([\w\-]+):\s*(.*)/", $line, $m)) {
// key: value
- if (strlen((string) $m[2])) {
+ if (strlen((string) $m[2]) !== 0) {
// simple key: value
$value = preg_replace("/#.*$/", "", $m[2]);
$value = self::_parseValue($value);
} else {
// key: and then values on new lines
$value = self::_decodeYaml($currentIndent + 1, $lines);
- if (is_array($value) && !count($value)) {
+ if (is_array($value) && $value === []) {
$value = "";
}
}
diff --git a/library/Zend/Console/Getopt.php b/library/Zend/Console/Getopt.php
index 75bc7c54af..20ddf414ab 100644
--- a/library/Zend/Console/Getopt.php
+++ b/library/Zend/Console/Getopt.php
@@ -506,9 +506,8 @@ public function toJson()
* @see Zend_Json
*/
require_once 'Zend/Json.php';
- $json = Zend_Json::encode($j);
- return $json;
+ return Zend_Json::encode($j);
}
/**
@@ -530,8 +529,7 @@ public function toXml()
}
$optionsNode->appendChild($optionNode);
}
- $xml = $doc->saveXML();
- return $xml;
+ return $doc->saveXML();
}
/**
@@ -698,7 +696,7 @@ public function setHelp($helpMap)
*/
public function parse()
{
- if ($this->_parsed === true) {
+ if ($this->_parsed) {
return;
}
$argv = $this->_argv;
@@ -714,9 +712,9 @@ public function parse()
}
if (substr($argv[0], 0, 2) == '--') {
$this->_parseLongOption($argv);
- } else if (substr($argv[0], 0, 1) == '-' && ('-' != $argv[0] || count($argv) >1)) {
+ } elseif (substr($argv[0], 0, 1) == '-' && ('-' != $argv[0] || count($argv) >1)) {
$this->_parseShortOptionCluster($argv);
- } else if($this->_getoptConfig[self::CONFIG_PARSEALL]) {
+ } elseif ($this->_getoptConfig[self::CONFIG_PARSEALL]) {
$this->_remainingArgs[] = array_shift($argv);
} else {
/*
@@ -740,9 +738,9 @@ public function checkRequiredArguments()
if ($rule['param'] === 'required') {
$defined = false;
foreach ($rule['alias'] as $alias) {
- $defined = $defined === true ? true : array_key_exists($alias, $this->_options);
+ $defined = $defined ? true : array_key_exists($alias, $this->_options);
}
- if ($defined === false) {
+ if (!$defined) {
require_once 'Zend/Console/Getopt/Exception.php';
throw new Zend_Console_Getopt_Exception(
'Option "$alias" requires a parameter.',
diff --git a/library/Zend/Controller/Action.php b/library/Zend/Controller/Action.php
index 9508e74711..05b93ccab7 100644
--- a/library/Zend/Controller/Action.php
+++ b/library/Zend/Controller/Action.php
@@ -167,7 +167,7 @@ public function initView()
}
require_once 'Zend/View/Interface.php';
- if (isset($this->view) && ($this->view instanceof Zend_View_Interface)) {
+ if ($this->view !== null && ($this->view instanceof Zend_View_Interface)) {
return $this->view;
}
@@ -562,7 +562,7 @@ public function run(Zend_Controller_Request_Abstract $request = null, Zend_Contr
if (empty($action)) {
$action = 'index';
}
- $action = $action . 'Action';
+ $action .= 'Action';
$request->setDispatched(true);
$this->dispatch($action);
diff --git a/library/Zend/Controller/Action/Helper/ActionStack.php b/library/Zend/Controller/Action/Helper/ActionStack.php
index e22e8b8e7e..a68e1ad21e 100644
--- a/library/Zend/Controller/Action/Helper/ActionStack.php
+++ b/library/Zend/Controller/Action/Helper/ActionStack.php
@@ -100,7 +100,7 @@ public function actionToStack($action, $controller = null, $module = null, array
$request = $this->getRequest();
- if ($request instanceof Zend_Controller_Request_Abstract === false){
+ if (!$request instanceof Zend_Controller_Request_Abstract){
/**
* @see Zend_Controller_Action_Exception
*/
diff --git a/library/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php b/library/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php
index 098aed8b10..c5fbd77825 100644
--- a/library/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php
+++ b/library/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php
@@ -45,11 +45,7 @@ class Zend_Controller_Action_Helper_AutoCompleteScriptaculous extends Zend_Contr
*/
public function validateData($data)
{
- if (!is_array($data) && !is_scalar($data)) {
- return false;
- }
-
- return true;
+ return !(!is_array($data) && !is_scalar($data));
}
/**
diff --git a/library/Zend/Controller/Action/Helper/ContextSwitch.php b/library/Zend/Controller/Action/Helper/ContextSwitch.php
index fe9114bc6e..33d761e92a 100644
--- a/library/Zend/Controller/Action/Helper/ContextSwitch.php
+++ b/library/Zend/Controller/Action/Helper/ContextSwitch.php
@@ -260,11 +260,8 @@ public function initContext($format = null)
// Return if invalid context parameter provided and no format or invalid
// format provided
- if (!$this->hasContext($context)) {
- if (empty($format) || !$this->hasContext($format)) {
-
- return;
- }
+ if (!$this->hasContext($context) && (empty($format) || !$this->hasContext($format))) {
+ return;
}
// Use provided format if passed
@@ -453,11 +450,7 @@ public function setSuffix($context, $suffix, $prependViewRendererSuffix = true)
if (isset($suffix['prependViewRendererSuffix'])) {
$prependViewRendererSuffix = $suffix['prependViewRendererSuffix'];
}
- if (isset($suffix['suffix'])) {
- $suffix = $suffix['suffix'];
- } else {
- $suffix = '';
- }
+ $suffix = isset($suffix['suffix']) ? $suffix['suffix'] : '';
}
$suffix = (string) $suffix;
@@ -516,7 +509,7 @@ public function hasContext($context, $throwException = false)
break;
}
}
- if (false === $error) {
+ if (!$error) {
return true;
}
$context = $error;
@@ -746,14 +739,12 @@ public function setCallback($context, $trigger, $callback)
$this->hasContext($context, true);
$trigger = $this->_validateTrigger($trigger);
- if (!is_string($callback)) {
- if (!is_array($callback) || (2 != count($callback))) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid callback specified');
- }
+ if (!is_string($callback) && (!is_array($callback) || (2 != count($callback)))) {
+ /**
+ * @see Zend_Controller_Action_Exception
+ */
+ require_once 'Zend/Controller/Action/Exception.php';
+ throw new Zend_Controller_Action_Exception('Invalid callback specified');
}
$this->_contexts[$context]['callbacks'][$trigger] = $callback;
@@ -924,7 +915,7 @@ public function getDefaultContext()
*/
public function setAutoDisableLayout($flag)
{
- $this->_disableLayout = ($flag) ? true : false;
+ $this->_disableLayout = $flag;
return $this;
}
@@ -1078,21 +1069,19 @@ public function getCurrentContext()
public function postDispatch()
{
$context = $this->getCurrentContext();
- if (null !== $context) {
- if (null !== ($callback = $this->getCallback($context, self::TRIGGER_POST))) {
- if (is_string($callback) && method_exists($this, $callback)) {
- $this->$callback();
- } elseif (is_string($callback) && function_exists($callback)) {
- $callback();
- } elseif (is_array($callback)) {
- call_user_func($callback);
- } else {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Invalid postDispatch context callback registered for context "%s"', $context));
- }
+ if (null !== $context && null !== ($callback = $this->getCallback($context, self::TRIGGER_POST))) {
+ if (is_string($callback) && method_exists($this, $callback)) {
+ $this->$callback();
+ } elseif (is_string($callback) && function_exists($callback)) {
+ $callback();
+ } elseif (is_array($callback)) {
+ call_user_func($callback);
+ } else {
+ /**
+ * @see Zend_Controller_Action_Exception
+ */
+ require_once 'Zend/Controller/Action/Exception.php';
+ throw new Zend_Controller_Action_Exception(sprintf('Invalid postDispatch context callback registered for context "%s"', $context));
}
}
}
diff --git a/library/Zend/Controller/Action/Helper/FlashMessenger.php b/library/Zend/Controller/Action/Helper/FlashMessenger.php
index 57fe9ecdee..5881b65294 100644
--- a/library/Zend/Controller/Action/Helper/FlashMessenger.php
+++ b/library/Zend/Controller/Action/Helper/FlashMessenger.php
@@ -82,7 +82,7 @@ public function __construct()
self::$_session = new Zend_Session_Namespace($this->getName());
foreach (self::$_session as $namespace => $messages) {
self::$_messages[$namespace] = $messages;
- unset(self::$_session->{$namespace});
+ unset(self::$_session->getNamespace());
}
}
}
@@ -146,7 +146,7 @@ public function addMessage($message, $namespace = null)
$namespace = $this->getNamespace();
}
- if (self::$_messageAdded === false) {
+ if (!self::$_messageAdded) {
self::$_session->setExpirationHops(1, null, true);
}
diff --git a/library/Zend/Controller/Action/Helper/Redirector.php b/library/Zend/Controller/Action/Helper/Redirector.php
index bf95772981..c25717633a 100644
--- a/library/Zend/Controller/Action/Helper/Redirector.php
+++ b/library/Zend/Controller/Action/Helper/Redirector.php
@@ -130,7 +130,7 @@ public function getExit()
*/
public function setExit($flag)
{
- $this->_exit = ($flag) ? true : false;
+ $this->_exit = $flag;
return $this;
}
@@ -153,7 +153,7 @@ public function getPrependBase()
*/
public function setPrependBase($flag)
{
- $this->_prependBase = ($flag) ? true : false;
+ $this->_prependBase = $flag;
return $this;
}
@@ -176,7 +176,7 @@ public function getCloseSessionOnExit()
*/
public function setCloseSessionOnExit($flag)
{
- $this->_closeSessionOnExit = ($flag) ? true : false;
+ $this->_closeSessionOnExit = $flag;
return $this;
}
@@ -198,7 +198,7 @@ public function getUseAbsoluteUri()
*/
public function setUseAbsoluteUri($flag = true)
{
- $this->_useAbsoluteUri = ($flag) ? true : false;
+ $this->_useAbsoluteUri = $flag;
return $this;
}
@@ -214,11 +214,9 @@ protected function _redirect($url)
$proto = (isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=="off") ? 'https' : 'http';
$port = (isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:80);
$uri = $proto . '://' . $host;
- if ((('http' == $proto) && (80 != $port)) || (('https' == $proto) && (443 != $port))) {
- // do not append if HTTP_HOST already contains port
- if (strrchr($host, ':') === false) {
- $uri .= ':' . $port;
- }
+ // do not append if HTTP_HOST already contains port
+ if (((('http' == $proto) && (80 != $port)) || (('https' == $proto) && (443 != $port))) && strrchr($host, ':') === false) {
+ $uri .= ':' . $port;
}
$url = $uri . '/' . ltrim($url, '/');
}
@@ -248,11 +246,7 @@ protected function _prependBase($url)
$request = $this->getRequest();
if ($request instanceof Zend_Controller_Request_Http) {
$base = rtrim($request->getBaseUrl(), '/');
- if (!empty($base) && ('/' != $base)) {
- $url = $base . '/' . ltrim($url, '/');
- } else {
- $url = '/' . ltrim($url, '/');
- }
+ $url = !empty($base) && ('/' != $base) ? $base . '/' . ltrim($url, '/') : '/' . ltrim($url, '/');
}
}
@@ -283,7 +277,7 @@ public function setGotoSimple($action, $controller = null, $module = null, array
$module = $curModule;
}
- if ($module == $dispatcher->getDefaultModule()) {
+ if ($module === $dispatcher->getDefaultModule()) {
$module = '';
}
@@ -352,10 +346,10 @@ public function setGotoUrl($url, array $options = array())
if (null !== $options) {
if (isset($options['exit'])) {
- $this->setExit(($options['exit']) ? true : false);
+ $this->setExit((bool) $options['exit']);
}
if (isset($options['prependBase'])) {
- $this->setPrependBase(($options['prependBase']) ? true : false);
+ $this->setPrependBase((bool) $options['prependBase']);
}
if (isset($options['code'])) {
$this->setCode($options['code']);
@@ -519,13 +513,19 @@ public function __call($method, $args)
{
$method = strtolower($method);
if ('goto' == $method) {
- return call_user_func_array(array($this, 'gotoSimple'), $args);
+ return call_user_func_array(function (string $action, ?string $controller = \null, ?string $module = \null, array $params = array()) : void {
+ $this->gotoSimple($action, $controller, $module, $params);
+ }, $args);
}
if ('setgoto' == $method) {
- return call_user_func_array(array($this, 'setGotoSimple'), $args);
+ return call_user_func_array(function (string $action, ?string $controller = \null, ?string $module = \null, array $params = array()) : void {
+ $this->setGotoSimple($action, $controller, $module, $params);
+ }, $args);
}
if ('gotoandexit' == $method) {
- return call_user_func_array(array($this, 'gotoSimpleAndExit'), $args);
+ return call_user_func_array(function ($action, $controller = \null, $module = \null, array $params = array()) : void {
+ $this->gotoSimpleAndExit($action, $controller, $module, $params);
+ }, $args);
}
require_once 'Zend/Controller/Action/Exception.php';
diff --git a/library/Zend/Controller/Action/Helper/Url.php b/library/Zend/Controller/Action/Helper/Url.php
index 7b8c69ac12..4119e41731 100644
--- a/library/Zend/Controller/Action/Helper/Url.php
+++ b/library/Zend/Controller/Action/Helper/Url.php
@@ -59,7 +59,7 @@ public function simple($action, $controller = null, $module = null, array $param
}
$url = $controller . '/' . $action;
- if ($module != $this->getFrontController()->getDispatcher()->getDefaultModule()) {
+ if ($module !== $this->getFrontController()->getDispatcher()->getDefaultModule()) {
$url = $module . '/' . $url;
}
@@ -76,9 +76,7 @@ public function simple($action, $controller = null, $module = null, array $param
$url .= '/' . $paramString;
}
- $url = '/' . ltrim($url, '/');
-
- return $url;
+ return '/' . ltrim($url, '/');
}
/**
diff --git a/library/Zend/Controller/Action/Helper/ViewRenderer.php b/library/Zend/Controller/Action/Helper/ViewRenderer.php
index a66c12a466..4d81708d36 100644
--- a/library/Zend/Controller/Action/Helper/ViewRenderer.php
+++ b/library/Zend/Controller/Action/Helper/ViewRenderer.php
@@ -197,7 +197,7 @@ public function __construct(Zend_View_Interface $view = null, array $options = a
*/
public function __clone()
{
- if (isset($this->view) && $this->view instanceof Zend_View_Interface) {
+ if ($this->view !== null && $this->view instanceof Zend_View_Interface) {
$this->view = clone $this->view;
}
@@ -362,9 +362,7 @@ protected function _generateDefaultPrefix()
return $default;
}
- $prefix = substr($class, 0, strpos($class, '_')) . '_View';
-
- return $prefix;
+ return substr($class, 0, strpos($class, '_')) . '_View';
}
/**
@@ -389,9 +387,7 @@ protected function _getBasePath()
'controller' => $request->getControllerName(),
'action' => $dispatcher->formatActionName($request->getActionName())
);
-
- $path = $inflector->filter($parts);
- return $path;
+ return $inflector->filter($parts);
}
/**
@@ -410,7 +406,7 @@ protected function _setOptions(array $options)
case 'noController':
case 'noRender':
$property = '_' . $key;
- $this->{$property} = ($value) ? true : false;
+ $this->{$property} = (bool) $value;
break;
case 'responseSegment':
case 'scriptAction':
@@ -647,7 +643,7 @@ public function getViewScript($action = null, array $vars = array())
*/
public function setNeverRender($flag = true)
{
- $this->_neverRender = ($flag) ? true : false;
+ $this->_neverRender = $flag;
return $this;
}
@@ -669,7 +665,7 @@ public function getNeverRender()
*/
public function setNoRender($flag = true)
{
- $this->_noRender = ($flag) ? true : false;
+ $this->_noRender = $flag;
return $this;
}
@@ -713,11 +709,7 @@ public function getScriptAction()
*/
public function setResponseSegment($name)
{
- if (null === $name) {
- $this->_responseSegment = null;
- } else {
- $this->_responseSegment = (string) $name;
- }
+ $this->_responseSegment = null === $name ? null : (string) $name;
return $this;
}
@@ -740,7 +732,7 @@ public function getResponseSegment()
*/
public function setNoController($flag = true)
{
- $this->_noController = ($flag) ? true : false;
+ $this->_noController = $flag;
return $this;
}
@@ -762,7 +754,7 @@ public function getNoController()
*/
public function setNeverController($flag = true)
{
- $this->_neverController = ($flag) ? true : false;
+ $this->_neverController = $flag;
return $this;
}
@@ -857,7 +849,7 @@ protected function _translateSpec(array $vars = array())
// Format action name
$action = $dispatcher->formatActionName($request->getActionName());
- $params = compact('module', 'controller', 'action');
+ $params = ['module' => $module, 'controller' => $controller, 'action' => $action];
foreach ($vars as $key => $value) {
switch ($key) {
case 'module':
diff --git a/library/Zend/Controller/Action/HelperBroker/PriorityStack.php b/library/Zend/Controller/Action/HelperBroker/PriorityStack.php
index d510b74ee5..ff9bdc0179 100644
--- a/library/Zend/Controller/Action/HelperBroker/PriorityStack.php
+++ b/library/Zend/Controller/Action/HelperBroker/PriorityStack.php
@@ -88,7 +88,7 @@ public function push(Zend_Controller_Action_Helper_Abstract $helper)
*
* @return array
*/
- public function getIterator()
+ public function getIterator(): Traversable
{
return new ArrayObject($this->_helpersByPriority);
}
@@ -99,7 +99,7 @@ public function getIterator()
* @param int|string $priorityOrHelperName
* @return Zend_Controller_Action_HelperBroker_PriorityStack
*/
- public function offsetExists($priorityOrHelperName)
+ public function offsetExists($priorityOrHelperName): bool
{
if (is_string($priorityOrHelperName)) {
return array_key_exists($priorityOrHelperName, $this->_helpersByNameRef);
@@ -114,7 +114,7 @@ public function offsetExists($priorityOrHelperName)
* @param int|string $priorityOrHelperName
* @return Zend_Controller_Action_HelperBroker_PriorityStack
*/
- public function offsetGet($priorityOrHelperName)
+ public function offsetGet($priorityOrHelperName): mixed
{
if (!$this->offsetExists($priorityOrHelperName)) {
require_once 'Zend/Controller/Action/Exception.php';
@@ -135,6 +135,7 @@ public function offsetGet($priorityOrHelperName)
* @param Zend_Controller_Action_Helper_Abstract $helper
* @return Zend_Controller_Action_HelperBroker_PriorityStack
*/
+ #[\ReturnTypeWillChange]
public function offsetSet($priority, $helper)
{
$priority = (int) $priority;
@@ -158,7 +159,7 @@ public function offsetSet($priority, $helper)
$this->_helpersByPriority[$priority] = $helper;
$this->_helpersByNameRef[$helper->getName()] = $helper;
- if ($priority == ($nextFreeDefault = $this->getNextFreeHigherPriority($this->_nextDefaultPriority))) {
+ if ($priority === ($nextFreeDefault = $this->getNextFreeHigherPriority($this->_nextDefaultPriority))) {
$this->_nextDefaultPriority = $nextFreeDefault;
}
@@ -172,6 +173,7 @@ public function offsetSet($priority, $helper)
* @param int|string $priorityOrHelperName Priority integer or the helper name
* @return Zend_Controller_Action_HelperBroker_PriorityStack
*/
+ #[\ReturnTypeWillChange]
public function offsetUnset($priorityOrHelperName)
{
if (!$this->offsetExists($priorityOrHelperName)) {
@@ -198,7 +200,7 @@ public function offsetUnset($priorityOrHelperName)
*
* @return int
*/
- public function count()
+ public function count(): int
{
return count($this->_helpersByPriority);
}
@@ -216,9 +218,7 @@ public function getNextFreeHigherPriority($indexPriority = null)
$indexPriority = $this->_nextDefaultPriority;
}
- $priorities = array_keys($this->_helpersByPriority);
-
- while (in_array($indexPriority, $priorities)) {
+ while (array_key_exists($indexPriority, $this->_helpersByPriority)) {
$indexPriority++;
}
@@ -238,9 +238,7 @@ public function getNextFreeLowerPriority($indexPriority = null)
$indexPriority = $this->_nextDefaultPriority;
}
- $priorities = array_keys($this->_helpersByPriority);
-
- while (in_array($indexPriority, $priorities)) {
+ while (array_key_exists($indexPriority, $this->_helpersByPriority)) {
$indexPriority--;
}
diff --git a/library/Zend/Controller/Dispatcher/Abstract.php b/library/Zend/Controller/Dispatcher/Abstract.php
index 2bfe1be2be..833906c1fd 100644
--- a/library/Zend/Controller/Dispatcher/Abstract.php
+++ b/library/Zend/Controller/Dispatcher/Abstract.php
@@ -230,11 +230,7 @@ public function setPathDelimiter($spec)
protected function _formatName($unformatted, $isAction = false)
{
// preserve directories
- if (!$isAction) {
- $segments = explode($this->getPathDelimiter(), $unformatted);
- } else {
- $segments = (array) $unformatted;
- }
+ $segments = $isAction ? (array) $unformatted : explode($this->getPathDelimiter(), $unformatted);
foreach ($segments as $key => $segment) {
$segment = str_replace($this->getWordDelimiter(), ' ', strtolower($segment));
diff --git a/library/Zend/Controller/Dispatcher/Standard.php b/library/Zend/Controller/Dispatcher/Standard.php
index 492056e42a..de6ab1dc3e 100644
--- a/library/Zend/Controller/Dispatcher/Standard.php
+++ b/library/Zend/Controller/Dispatcher/Standard.php
@@ -157,7 +157,7 @@ public function removeControllerDirectory($module)
*/
public function formatModuleName($unformatted)
{
- if (($this->_defaultModule == $unformatted) && !$this->getParam('prefixDefaultModule')) {
+ if (($this->_defaultModule === $unformatted) && !$this->getParam('prefixDefaultModule')) {
return $unformatted;
}
@@ -207,7 +207,7 @@ public function isDispatchable(Zend_Controller_Request_Abstract $request)
}
$finalClass = $className;
- if (($this->_defaultModule != $this->_curModule)
+ if (($this->_defaultModule !== $this->_curModule)
|| $this->getParam('prefixDefaultModule'))
{
$finalClass = $this->formatClassName($this->_curModule, $className);
@@ -263,7 +263,7 @@ public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Control
* class name to do the class->file mapping, but the full class name to insantiate the controller
*/
$moduleClassName = $className;
- if (($this->_defaultModule != $this->_curModule)
+ if (($this->_defaultModule !== $this->_curModule)
|| $this->getParam('prefixDefaultModule'))
{
$moduleClassName = $this->formatClassName($this->_curModule, $className);
@@ -341,7 +341,7 @@ public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Control
public function loadClass($className)
{
$finalClass = $className;
- if (($this->_defaultModule != $this->_curModule)
+ if (($this->_defaultModule !== $this->_curModule)
|| $this->getParam('prefixDefaultModule'))
{
$finalClass = $this->formatClassName($this->_curModule, $className);
@@ -422,7 +422,7 @@ public function isValidModule($module)
$module = strtolower($module);
$controllerDir = $this->getControllerDirectory();
foreach (array_keys($controllerDir) as $moduleName) {
- if ($module == strtolower($moduleName)) {
+ if ($module === strtolower($moduleName)) {
return true;
}
}
diff --git a/library/Zend/Controller/Front.php b/library/Zend/Controller/Front.php
index 3ca4c78b1d..25e5464766 100644
--- a/library/Zend/Controller/Front.php
+++ b/library/Zend/Controller/Front.php
@@ -859,10 +859,8 @@ public function dispatch(Zend_Controller_Request_Abstract $request = null, Zend_
/**
* Set base URL of request object, if available
*/
- if (is_callable(array($this->_request, 'setBaseUrl'))) {
- if (null !== $this->_baseUrl) {
- $this->_request->setBaseUrl($this->_baseUrl);
- }
+ if (is_callable(array($this->_request, 'setBaseUrl')) && null !== $this->_baseUrl) {
+ $this->_request->setBaseUrl($this->_baseUrl);
}
/**
diff --git a/library/Zend/Controller/Plugin/ActionStack.php b/library/Zend/Controller/Plugin/ActionStack.php
index 12c62de112..18d306d128 100644
--- a/library/Zend/Controller/Plugin/ActionStack.php
+++ b/library/Zend/Controller/Plugin/ActionStack.php
@@ -163,8 +163,7 @@ public function getClearRequestParams()
public function getStack()
{
$registry = $this->getRegistry();
- $stack = $registry[$this->getRegistryKey()];
- return $stack;
+ return $registry[$this->getRegistryKey()];
}
/**
@@ -189,7 +188,7 @@ protected function _saveStack(array $stack)
public function pushStack(Zend_Controller_Request_Abstract $next)
{
$stack = $this->getStack();
- array_push($stack, $next);
+ $stack[] = $next;
return $this->_saveStack($stack);
}
@@ -214,7 +213,7 @@ public function popStack()
}
$action = $next->getActionName();
if (empty($action)) {
- return $this->popStack($stack);
+ return $this->popStack();
}
$request = $this->getRequest();
diff --git a/library/Zend/Controller/Plugin/Broker.php b/library/Zend/Controller/Plugin/Broker.php
index 1214583eb3..a4efec1611 100644
--- a/library/Zend/Controller/Plugin/Broker.php
+++ b/library/Zend/Controller/Plugin/Broker.php
@@ -50,14 +50,14 @@ class Zend_Controller_Plugin_Broker extends Zend_Controller_Plugin_Abstract
*/
public function registerPlugin(Zend_Controller_Plugin_Abstract $plugin, $stackIndex = null)
{
- if (false !== array_search($plugin, $this->_plugins, true)) {
+ if (in_array($plugin, $this->_plugins, true)) {
require_once 'Zend/Controller/Exception.php';
throw new Zend_Controller_Exception('Plugin already registered');
}
$stackIndex = (int) $stackIndex;
- if ($stackIndex) {
+ if ($stackIndex !== 0) {
if (isset($this->_plugins[$stackIndex])) {
require_once 'Zend/Controller/Exception.php';
throw new Zend_Controller_Exception('Plugin with stackIndex "' . $stackIndex . '" already registered');
diff --git a/library/Zend/Controller/Plugin/ErrorHandler.php b/library/Zend/Controller/Plugin/ErrorHandler.php
index 42da1633c6..d12b4fe3c1 100644
--- a/library/Zend/Controller/Plugin/ErrorHandler.php
+++ b/library/Zend/Controller/Plugin/ErrorHandler.php
@@ -262,21 +262,13 @@ protected function _handleError(Zend_Controller_Request_Abstract $request)
$error->exception = $exception;
switch ($exceptionType) {
case 'Zend_Controller_Router_Exception':
- if (404 == $exception->getCode()) {
- $error->type = self::EXCEPTION_NO_ROUTE;
- } else {
- $error->type = self::EXCEPTION_OTHER;
- }
+ $error->type = 404 == $exception->getCode() ? self::EXCEPTION_NO_ROUTE : self::EXCEPTION_OTHER;
break;
case 'Zend_Controller_Dispatcher_Exception':
$error->type = self::EXCEPTION_NO_CONTROLLER;
break;
case 'Zend_Controller_Action_Exception':
- if (404 == $exception->getCode()) {
- $error->type = self::EXCEPTION_NO_ACTION;
- } else {
- $error->type = self::EXCEPTION_OTHER;
- }
+ $error->type = 404 == $exception->getCode() ? self::EXCEPTION_NO_ACTION : self::EXCEPTION_OTHER;
break;
default:
$error->type = self::EXCEPTION_OTHER;
diff --git a/library/Zend/Controller/Request/Abstract.php b/library/Zend/Controller/Request/Abstract.php
index d57238f46b..79efb7db8f 100644
--- a/library/Zend/Controller/Request/Abstract.php
+++ b/library/Zend/Controller/Request/Abstract.php
@@ -310,7 +310,7 @@ public function getParams()
*/
public function setParams(array $array)
{
- $this->_params = $this->_params + (array) $array;
+ $this->_params += (array) $array;
foreach ($array as $key => $value) {
if (null === $value) {
@@ -340,7 +340,7 @@ public function clearParams()
*/
public function setDispatched($flag = true)
{
- $this->_dispatched = $flag ? true : false;
+ $this->_dispatched = $flag;
return $this;
}
diff --git a/library/Zend/Controller/Request/Apache404.php b/library/Zend/Controller/Request/Apache404.php
index 3c4dd7ac48..5d096813a1 100644
--- a/library/Zend/Controller/Request/Apache404.php
+++ b/library/Zend/Controller/Request/Apache404.php
@@ -65,10 +65,8 @@ public function setRequestUri($requestUri = null)
}
} elseif (!is_string($requestUri)) {
return $this;
- } else {
- if (false !== ($pos = strpos($requestUri, '?'))) {
- $parseUriGetVars = substr($requestUri, $pos + 1);
- }
+ } elseif (false !== ($pos = strpos($requestUri, '?'))) {
+ $parseUriGetVars = substr($requestUri, $pos + 1);
}
if ($parseUriGetVars) {
diff --git a/library/Zend/Controller/Request/Http.php b/library/Zend/Controller/Request/Http.php
index 7ccb20cd74..0c2e820852 100644
--- a/library/Zend/Controller/Request/Http.php
+++ b/library/Zend/Controller/Request/Http.php
@@ -421,14 +421,11 @@ public function setRequestUri($requestUri = null)
}
} elseif (!is_string($requestUri)) {
return $this;
- } else {
- // Set GET items, if available
- if (false !== ($pos = strpos($requestUri, '?'))) {
- // Get key => value pairs and set $_GET
- $query = substr($requestUri, $pos + 1);
- parse_str($query, $vars);
- $this->setQuery($vars);
- }
+ } elseif (false !== ($pos = strpos($requestUri, '?'))) {
+ // Get key => value pairs and set $_GET
+ $query = substr($requestUri, $pos + 1);
+ parse_str($query, $vars);
+ $this->setQuery($vars);
}
$this->_requestUri = $requestUri;
@@ -577,11 +574,7 @@ public function setBasePath($basePath = null)
return $this;
}
- if (basename($baseUrl) === $filename) {
- $basePath = dirname($baseUrl);
- } else {
- $basePath = $baseUrl;
- }
+ $basePath = basename($baseUrl) === $filename ? dirname($baseUrl) : $baseUrl;
}
if (substr(PHP_OS, 0, 3) === 'WIN') {
@@ -840,11 +833,7 @@ public function getMethod()
*/
public function isPost()
{
- if ('POST' == $this->getMethod()) {
- return true;
- }
-
- return false;
+ return 'POST' == $this->getMethod();
}
/**
@@ -854,11 +843,7 @@ public function isPost()
*/
public function isGet()
{
- if ('GET' == $this->getMethod()) {
- return true;
- }
-
- return false;
+ return 'GET' == $this->getMethod();
}
/**
@@ -868,11 +853,7 @@ public function isGet()
*/
public function isPut()
{
- if ('PUT' == $this->getMethod()) {
- return true;
- }
-
- return false;
+ return 'PUT' == $this->getMethod();
}
/**
@@ -882,11 +863,7 @@ public function isPut()
*/
public function isDelete()
{
- if ('DELETE' == $this->getMethod()) {
- return true;
- }
-
- return false;
+ return 'DELETE' == $this->getMethod();
}
/**
@@ -896,11 +873,7 @@ public function isDelete()
*/
public function isHead()
{
- if ('HEAD' == $this->getMethod()) {
- return true;
- }
-
- return false;
+ return 'HEAD' == $this->getMethod();
}
/**
@@ -910,11 +883,7 @@ public function isHead()
*/
public function isOptions()
{
- if ('OPTIONS' == $this->getMethod()) {
- return true;
- }
-
- return false;
+ return 'OPTIONS' == $this->getMethod();
}
/**
@@ -924,11 +893,7 @@ public function isOptions()
*/
public function isPatch()
{
- if ('PATCH' == $this->getMethod()) {
- return true;
- }
-
- return false;
+ return 'PATCH' == $this->getMethod();
}
/**
@@ -951,7 +916,7 @@ public function isXmlHttpRequest()
public function isFlashRequest()
{
$header = strtolower($this->getHeader('USER_AGENT'));
- return (strstr($header, ' flash')) ? true : false;
+ return (bool) strstr($header, ' flash');
}
/**
@@ -974,11 +939,7 @@ public function getRawBody()
if (null === $this->_rawBody) {
$body = file_get_contents('php://input');
- if (strlen(trim($body)) > 0) {
- $this->_rawBody = $body;
- } else {
- $this->_rawBody = false;
- }
+ $this->_rawBody = strlen(trim($body)) > 0 ? $body : false;
}
return $this->_rawBody;
}
@@ -1024,7 +985,7 @@ public function getHeader($header)
}
$header = strtolower($header);
foreach ($headers as $key => $value) {
- if (strtolower($key) == $header) {
+ if (strtolower($key) === $header) {
return $value;
}
}
@@ -1083,7 +1044,7 @@ public function getClientIp($checkProxy = true)
{
if ($checkProxy && $this->getServer('HTTP_CLIENT_IP') != null) {
$ip = $this->getServer('HTTP_CLIENT_IP');
- } else if ($checkProxy && $this->getServer('HTTP_X_FORWARDED_FOR') != null) {
+ } elseif ($checkProxy && $this->getServer('HTTP_X_FORWARDED_FOR') != null) {
$ip = $this->getServer('HTTP_X_FORWARDED_FOR');
} else {
$ip = $this->getServer('REMOTE_ADDR');
diff --git a/library/Zend/Controller/Request/HttpTestCase.php b/library/Zend/Controller/Request/HttpTestCase.php
index 58b9bd3936..d5fb134f61 100644
--- a/library/Zend/Controller/Request/HttpTestCase.php
+++ b/library/Zend/Controller/Request/HttpTestCase.php
@@ -271,7 +271,6 @@ public function getRequestUri()
protected function _normalizeHeaderName($name)
{
$name = strtoupper((string) $name);
- $name = str_replace('-', '_', $name);
- return $name;
+ return str_replace('-', '_', $name);
}
}
diff --git a/library/Zend/Controller/Request/Simple.php b/library/Zend/Controller/Request/Simple.php
index 74e4b0c4a1..b4cd07f9cf 100644
--- a/library/Zend/Controller/Request/Simple.php
+++ b/library/Zend/Controller/Request/Simple.php
@@ -47,7 +47,7 @@ public function __construct($action = null, $controller = null, $module = null,
$this->setModuleName($module);
}
- if ($params) {
+ if ($params !== []) {
$this->setParams($params);
}
}
diff --git a/library/Zend/Controller/Response/Abstract.php b/library/Zend/Controller/Response/Abstract.php
index 9fcc22693e..971be26580 100644
--- a/library/Zend/Controller/Response/Abstract.php
+++ b/library/Zend/Controller/Response/Abstract.php
@@ -95,8 +95,7 @@ protected function _normalizeHeader($name)
{
$filtered = str_replace(array('-', '_'), ' ', (string) $name);
$filtered = ucwords(strtolower($filtered));
- $filtered = str_replace(' ', '-', $filtered);
- return $filtered;
+ return str_replace(' ', '-', $filtered);
}
/**
@@ -192,7 +191,7 @@ public function clearHeaders()
*/
public function clearHeader($name)
{
- if (! count($this->_headers)) {
+ if ($this->_headers === []) {
return $this;
}
@@ -252,7 +251,7 @@ public function clearRawHeaders()
*/
public function clearRawHeader($headerRaw)
{
- if (! count($this->_headersRaw)) {
+ if ($this->_headersRaw === []) {
return $this;
}
@@ -288,11 +287,7 @@ public function setHttpResponseCode($code)
throw new Zend_Controller_Response_Exception('Invalid HTTP response code');
}
- if ((300 <= $code) && (307 >= $code)) {
- $this->_isRedirect = true;
- } else {
- $this->_isRedirect = false;
- }
+ $this->_isRedirect = (300 <= $code) && (307 >= $code);
$this->_httpResponseCode = $code;
return $this;
@@ -339,7 +334,7 @@ public function sendHeaders()
// Only check if we can send headers if we have headers to send
if (count($this->_headersRaw) || count($this->_headers) || (200 != $this->_httpResponseCode)) {
$this->canSendHeaders(true);
- } elseif (200 == $this->_httpResponseCode) {
+ } elseif (200 === $this->_httpResponseCode) {
// Haven't changed the response code, and we have no headers
return $this;
}
@@ -459,11 +454,11 @@ public function clearBody($name = null)
*/
public function getBody($spec = false)
{
- if (false === $spec) {
+ if (!$spec) {
ob_start();
$this->outputBody();
return ob_get_clean();
- } elseif (true === $spec) {
+ } elseif ($spec) {
return $this->_body;
} elseif (is_string($spec) && isset($this->_body[$spec])) {
return $this->_body[$spec];
@@ -566,7 +561,7 @@ public function insert($name, $content, $parent = null, $before = false)
$this->_body = $ins + $this->_body;
} elseif ($loc >= (count($this->_body))) {
// If location of key is maximal, we're appending
- $this->_body = $this->_body + $ins;
+ $this->_body += $ins;
} else {
// Otherwise, insert at location specified
$pre = array_slice($this->_body, 0, $loc);
@@ -751,7 +746,7 @@ public function getExceptionByCode($code)
public function renderExceptions($flag = null)
{
if (null !== $flag) {
- $this->_renderExceptions = $flag ? true : false;
+ $this->_renderExceptions = $flag;
}
return $this->_renderExceptions;
diff --git a/library/Zend/Controller/Response/HttpTestCase.php b/library/Zend/Controller/Response/HttpTestCase.php
index 768dbfd311..f5712ddeed 100644
--- a/library/Zend/Controller/Response/HttpTestCase.php
+++ b/library/Zend/Controller/Response/HttpTestCase.php
@@ -41,9 +41,7 @@ class Zend_Controller_Response_HttpTestCase extends Zend_Controller_Response_Htt
public function sendHeaders()
{
$headers = array();
- foreach ($this->_headersRaw as $header) {
- $headers[] = $header;
- }
+ $headers = $this->_headersRaw;
foreach ($this->_headers as $header) {
$name = $header['name'];
$key = strtolower($name);
diff --git a/library/Zend/Controller/Router/Rewrite.php b/library/Zend/Controller/Router/Rewrite.php
index 83909f8a87..7e3f2bcbcf 100644
--- a/library/Zend/Controller/Router/Rewrite.php
+++ b/library/Zend/Controller/Router/Rewrite.php
@@ -180,11 +180,7 @@ public function addConfig(Zend_Config $config, $section = null)
throw new Zend_Controller_Router_Exception("No chain defined");
}
- if ($info->chain instanceof Zend_Config) {
- $childRouteNames = $info->chain;
- } else {
- $childRouteNames = explode(',', (string) $info->chain);
- }
+ $childRouteNames = $info->chain instanceof Zend_Config ? $info->chain : explode(',', (string) $info->chain);
foreach ($childRouteNames as $childRouteName) {
$childRoute = $this->getRoute(trim($childRouteName));
@@ -401,11 +397,7 @@ public function route(Zend_Controller_Request_Abstract $request)
}
// TODO: Should be an interface method. Hack for 1.0 BC
- if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
- $match = $request->getPathInfo();
- } else {
- $match = $request;
- }
+ $match = !method_exists($route, 'getVersion') || $route->getVersion() == 1 ? $request->getPathInfo() : $request;
if ($params = $route->match($match)) {
$this->_setRequestParams($request, $params);
diff --git a/library/Zend/Controller/Router/Route.php b/library/Zend/Controller/Router/Route.php
index 404340bf88..52f50192ad 100644
--- a/library/Zend/Controller/Router/Route.php
+++ b/library/Zend/Controller/Router/Route.php
@@ -392,11 +392,7 @@ public function assemble($data = array(), $reset = false, $encode = false, $part
}
} elseif ($part != '*') {
if ($this->_isTranslated && substr($part, 0, 1) === '@') {
- if (substr($part, 1, 1) !== '@') {
- $url[$key] = $translator->translate(substr($part, 1), $locale);
- } else {
- $url[$key] = substr($part, 1);
- }
+ $url[$key] = substr($part, 1, 1) !== '@' ? $translator->translate(substr($part, 1), $locale) : substr($part, 1);
} else {
if (substr($part, 0, 2) === '@@') {
$part = substr($part, 1);
@@ -523,19 +519,17 @@ public function getTranslator()
{
if ($this->_translator !== null) {
return $this->_translator;
+ } elseif (($translator = self::getDefaultTranslator()) !== null) {
+ return $translator;
} else {
- if (($translator = self::getDefaultTranslator()) !== null) {
- return $translator;
- } else {
- try {
- $translator = Zend_Registry::get('Zend_Translate');
- } catch (Zend_Exception $e) {
- $translator = null;
- }
+ try {
+ $translator = Zend_Registry::get('Zend_Translate');
+ } catch (Zend_Exception $e) {
+ $translator = null;
+ }
- if ($translator instanceof Zend_Translate) {
- return $translator;
- }
+ if ($translator instanceof Zend_Translate) {
+ return $translator;
}
}
@@ -582,24 +576,6 @@ public function setLocale($locale)
*/
public function getLocale()
{
- if ($this->_locale !== null) {
- return $this->_locale;
- } else {
- if (($locale = self::getDefaultLocale()) !== null) {
- return $locale;
- } else {
- try {
- $locale = Zend_Registry::get('Zend_Locale');
- } catch (Zend_Exception $e) {
- $locale = null;
- }
-
- if ($locale !== null) {
- return $locale;
- }
- }
- }
-
- return null;
+ return $this->_locale;
}
}
diff --git a/library/Zend/Controller/Router/Route/Chain.php b/library/Zend/Controller/Router/Route/Chain.php
index e05910dff1..f5bf71ade2 100644
--- a/library/Zend/Controller/Router/Route/Chain.php
+++ b/library/Zend/Controller/Router/Route/Chain.php
@@ -34,6 +34,7 @@
class Zend_Controller_Router_Route_Chain extends Zend_Controller_Router_Route_Abstract
{
+ public ?\Zend_Controller_Request_Abstract $_request;
/**
* Routes
*
diff --git a/library/Zend/Controller/Router/Route/Hostname.php b/library/Zend/Controller/Router/Route/Hostname.php
index 21cbe1d659..934796995f 100644
--- a/library/Zend/Controller/Router/Route/Hostname.php
+++ b/library/Zend/Controller/Router/Route/Hostname.php
@@ -133,7 +133,7 @@ public function setRequest(Zend_Controller_Request_Abstract $request = null)
*/
public function getRequest()
{
- if ($this->_request === null) {
+ if (!$this->_request instanceof \Zend_Controller_Request_Abstract) {
require_once 'Zend/Controller/Front.php';
$this->_request = Zend_Controller_Front::getInstance()->getRequest();
}
@@ -151,7 +151,7 @@ public static function getInstance(Zend_Config $config)
{
$reqs = ($config->reqs instanceof Zend_Config) ? $config->reqs->toArray() : array();
$defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
- $scheme = (isset($config->scheme)) ? $config->scheme : null;
+ $scheme = (property_exists($config, 'scheme') && $config->scheme !== null) ? $config->scheme : null;
return new self($config->route, $defs, $reqs, $scheme);
}
@@ -175,7 +175,7 @@ public function __construct($route, $defaults = array(), $reqs = array(), $schem
if ($route != '') {
foreach (explode('.', $route) as $pos => $part) {
- if (substr($part, 0, 1) == $this->_hostVariable) {
+ if (substr($part, 0, 1) === $this->_hostVariable) {
$name = substr($part, 1);
$this->_parts[$pos] = (isset($reqs[$name]) ? $reqs[$name] : $this->_defaultRegex);
$this->_variables[$pos] = $name;
@@ -331,16 +331,10 @@ public function assemble($data = array(), $reset = false, $encode = false, $part
$scheme = $this->_scheme;
} else {
$request = $this->getRequest();
- if ($request instanceof Zend_Controller_Request_Http) {
- $scheme = $request->getScheme();
- } else {
- $scheme = 'http';
- }
+ $scheme = $request instanceof Zend_Controller_Request_Http ? $request->getScheme() : 'http';
}
- $url = $scheme . '://' . $url;
-
- return $url;
+ return $scheme . '://' . $url;
}
/**
diff --git a/library/Zend/Controller/Router/Route/Module.php b/library/Zend/Controller/Router/Route/Module.php
index 581a89b1bc..5ff51dbda0 100644
--- a/library/Zend/Controller/Router/Route/Module.php
+++ b/library/Zend/Controller/Router/Route/Module.php
@@ -197,8 +197,8 @@ public function match($path, $partial = false)
$values[$this->_actionKey] = array_shift($path);
}
- if ($numSegs = count($path)) {
- for ($i = 0; $i < $numSegs; $i = $i + 2) {
+ if (($numSegs = count($path)) !== 0) {
+ for ($i = 0; $i < $numSegs; $i += 2) {
$key = urldecode($path[$i]);
$val = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null;
$params[$key] = (isset($params[$key]) ? (array_merge((array)$params[$key], array($val))) : $val);
@@ -230,7 +230,7 @@ public function assemble($data = array(), $reset = false, $encode = true, $parti
$this->_setRequestKeys();
}
- $params = (!$reset) ? $this->_values : array();
+ $params = ($reset) ? array() : $this->_values;
foreach ($data as $key => $value) {
if ($value !== null) {
@@ -244,10 +244,8 @@ public function assemble($data = array(), $reset = false, $encode = true, $parti
$url = '';
- if ($this->_moduleValid || array_key_exists($this->_moduleKey, $data)) {
- if ($params[$this->_moduleKey] != $this->_defaults[$this->_moduleKey]) {
- $module = $params[$this->_moduleKey];
- }
+ if (($this->_moduleValid || array_key_exists($this->_moduleKey, $data)) && $params[$this->_moduleKey] != $this->_defaults[$this->_moduleKey]) {
+ $module = $params[$this->_moduleKey];
}
unset($params[$this->_moduleKey]);
diff --git a/library/Zend/Controller/Router/Route/Regex.php b/library/Zend/Controller/Router/Route/Regex.php
index e012357d7b..4323ea58b9 100644
--- a/library/Zend/Controller/Router/Route/Regex.php
+++ b/library/Zend/Controller/Router/Route/Regex.php
@@ -79,7 +79,7 @@ public static function getInstance(Zend_Config $config)
{
$defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
$map = ($config->map instanceof Zend_Config) ? $config->map->toArray() : array();
- $reverse = (isset($config->reverse)) ? $config->reverse : null;
+ $reverse = (property_exists($config, 'reverse') && $config->reverse !== null) ? $config->reverse : null;
return new self($config->route, $defs, $map, $reverse);
}
@@ -147,9 +147,8 @@ public function match($path, $partial = false)
$values = $this->_getMappedValues($values);
$defaults = $this->_getMappedValues($this->_defaults, false, true);
- $return = $values + $defaults;
- return $return;
+ return $values + $defaults;
}
/**
@@ -185,11 +184,7 @@ protected function _getMappedValues($values, $reversed = false, $preserve = fals
} elseif ($reversed) {
$index = $key;
if (!is_int($key)) {
- if (array_key_exists($key, $this->_map)) {
- $index = $this->_map[$key];
- } else {
- $index = array_search($key, $this->_map, true);
- }
+ $index = array_key_exists($key, $this->_map) ? $this->_map[$key] : array_search($key, $this->_map, true);
}
if (false !== $index) {
$return[$index] = $values[$key];
@@ -289,11 +284,7 @@ public function getVariables()
$variables = array();
foreach ($this->_map as $key => $value) {
- if (is_numeric($key)) {
- $variables[] = $value;
- } else {
- $variables[] = $key;
- }
+ $variables[] = is_numeric($key) ? $value : $key;
}
return $variables;
diff --git a/library/Zend/Controller/Router/Route/Static.php b/library/Zend/Controller/Router/Route/Static.php
index 2acf62b4b3..fcbd93889f 100644
--- a/library/Zend/Controller/Router/Route/Static.php
+++ b/library/Zend/Controller/Router/Route/Static.php
@@ -102,10 +102,8 @@ public function match($path, $partial = false)
return $this->_defaults;
}
- } else {
- if (trim($path, self::URI_DELIMITER) == $this->_route) {
- return $this->_defaults;
- }
+ } elseif (trim($path, self::URI_DELIMITER) == $this->_route) {
+ return $this->_defaults;
}
return false;
diff --git a/library/Zend/Crypt.php b/library/Zend/Crypt.php
index 0ceeac71e3..fb86d52545 100644
--- a/library/Zend/Crypt.php
+++ b/library/Zend/Crypt.php
@@ -86,8 +86,7 @@ public static function hash($algorithm, $data, $binaryOutput = false)
}
self::_detectHashSupport($algorithm);
$supportedMethod = '_digest' . ucfirst(self::$_type);
- $result = self::$supportedMethod($algorithm, $data, $binaryOutput);
- return $result;
+ return self::$supportedMethod($algorithm, $data, $binaryOutput);
}
/**
diff --git a/library/Zend/Crypt/DiffieHellman.php b/library/Zend/Crypt/DiffieHellman.php
index 03463a59a5..c96ee098b0 100644
--- a/library/Zend/Crypt/DiffieHellman.php
+++ b/library/Zend/Crypt/DiffieHellman.php
@@ -121,7 +121,7 @@ public function __construct($prime, $generator, $privateKey = null, $privateKeyT
*/
public function generateKeys()
{
- if (function_exists('openssl_dh_compute_key') && self::$useOpenssl !== false) {
+ if (function_exists('openssl_dh_compute_key') && self::$useOpenssl) {
$details = array();
$details['p'] = $this->getPrime();
$details['g'] = $this->getGenerator();
@@ -209,7 +209,7 @@ public function computeSecretKey($publicKey, $type = self::NUMBER, $output = sel
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
}
- if (function_exists('openssl_dh_compute_key') && self::$useOpenssl !== false) {
+ if (function_exists('openssl_dh_compute_key') && self::$useOpenssl) {
$this->_secretKey = openssl_dh_compute_key($publicKey, $this->getPublicKey());
} else {
$this->_secretKey = $this->_math->powmod($publicKey, $this->getPrivateKey(), $this->getPrime());
@@ -226,7 +226,7 @@ public function computeSecretKey($publicKey, $type = self::NUMBER, $output = sel
*/
public function getSharedSecretKey($type = self::NUMBER)
{
- if (!isset($this->_secretKey)) {
+ if (!($this->_secretKey !== null)) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('A secret key has not yet been computed; call computeSecretKey()');
}
@@ -263,7 +263,7 @@ public function setPrime($number)
*/
public function getPrime()
{
- if (!isset($this->_prime)) {
+ if (!($this->_prime !== null)) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('No prime number has been set');
}
@@ -295,7 +295,7 @@ public function setGenerator($number)
*/
public function getGenerator()
{
- if (!isset($this->_generator)) {
+ if (!($this->_generator !== null)) {
require_once('Zend/Crypt/DiffieHellman/Exception.php');
throw new Zend_Crypt_DiffieHellman_Exception('No generator number has been set');
}
@@ -349,7 +349,7 @@ public function getPrivateKey($type = self::NUMBER)
*/
public function hasPrivateKey()
{
- return isset($this->_privateKey);
+ return $this->_privateKey !== null;
}
/**
@@ -381,8 +381,7 @@ public function setBigIntegerMath($extension = null)
*/
protected function _generatePrivateKey()
{
- $rand = $this->_math->rand($this->getGenerator(), $this->getPrime());
- return $rand;
+ return $this->_math->rand($this->getGenerator(), $this->getPrime());
}
}
diff --git a/library/Zend/Crypt/Hmac.php b/library/Zend/Crypt/Hmac.php
index b11eb4d749..4ff711915a 100644
--- a/library/Zend/Crypt/Hmac.php
+++ b/library/Zend/Crypt/Hmac.php
@@ -125,11 +125,11 @@ protected static function _setHashAlgorithm($hash)
$hashSupported = true;
}
- if ($hashSupported === false && function_exists('mhash') && in_array($hash, self::$_supportedAlgosMhash)) {
+ if (!$hashSupported && function_exists('mhash') && in_array($hash, self::$_supportedAlgosMhash)) {
$hashSupported = true;
}
- if ($hashSupported === false) {
+ if (!$hashSupported) {
require_once 'Zend/Crypt/Hmac/Exception.php';
throw new Zend_Crypt_Hmac_Exception('hash algorithm provided is not supported on this PHP installation; please enable the hash or mhash extensions');
}
diff --git a/library/Zend/Crypt/Math.php b/library/Zend/Crypt/Math.php
index 6c8687a893..844d78c0c2 100644
--- a/library/Zend/Crypt/Math.php
+++ b/library/Zend/Crypt/Math.php
@@ -60,8 +60,7 @@ public function rand($minimum, $maximum)
for ($i = 1; $i < $i2; $i++) {
$rand .= mt_rand(0, 9);
}
- $rand .= mt_rand(0, 9);
- return $rand;
+ return $rand . mt_rand(0, 9);
}
/**
@@ -92,7 +91,7 @@ public static function randBytes($length, $strong = false)
return fread($frandom, $length);
}
}
- if (true === $strong) {
+ if ($strong) {
require_once 'Zend/Crypt/Exception.php';
throw new Zend_Crypt_Exception(
'This PHP environment doesn\'t support secure random number generation. ' .
diff --git a/library/Zend/Crypt/Math/BigInteger/Gmp.php b/library/Zend/Crypt/Math/BigInteger/Gmp.php
index 33196edc2a..bcacae1e0a 100644
--- a/library/Zend/Crypt/Math/BigInteger/Gmp.php
+++ b/library/Zend/Crypt/Math/BigInteger/Gmp.php
@@ -195,11 +195,10 @@ public function integerToBinary($operand)
$bigInt = gmp_strval($operand, 16);
if (strlen($bigInt) % 2 != 0) {
$bigInt = '0' . $bigInt;
- } else if ($bigInt[0] > '7') {
+ } elseif ($bigInt[0] > '7') {
$bigInt = '00' . $bigInt;
}
- $return = pack("H*", $bigInt);
- return $return;
+ return pack("H*", $bigInt);
}
/**
diff --git a/library/Zend/Crypt/Rsa.php b/library/Zend/Crypt/Rsa.php
index 84e6e76848..4c42b0b482 100644
--- a/library/Zend/Crypt/Rsa.php
+++ b/library/Zend/Crypt/Rsa.php
@@ -155,10 +155,9 @@ public function verifySignature($data, $signature, $format = null)
if ($format == self::BASE64) {
$signature = base64_decode($signature);
}
- $result = openssl_verify($data, $signature,
+ return openssl_verify($data, $signature,
$this->getPublicKey()->getOpensslKeyResource(),
$this->getHashAlgorithm());
- return $result;
}
/**
@@ -231,11 +230,10 @@ public function generateKeys(array $configargs = null)
$privateKey = new Zend_Crypt_Rsa_Key_Private($private, $passPhrase);
$details = openssl_pkey_get_details($resource);
$publicKey = new Zend_Crypt_Rsa_Key_Public($details['key']);
- $return = new ArrayObject(array(
+ return new ArrayObject(array(
'privateKey'=>$privateKey,
'publicKey'=>$publicKey
), ArrayObject::ARRAY_AS_PROPS);
- return $return;
}
/**
diff --git a/library/Zend/Crypt/Rsa/Key.php b/library/Zend/Crypt/Rsa/Key.php
index fafde02f57..23815d8e0d 100644
--- a/library/Zend/Crypt/Rsa/Key.php
+++ b/library/Zend/Crypt/Rsa/Key.php
@@ -28,6 +28,7 @@
*/
class Zend_Crypt_Rsa_Key implements Countable
{
+ public $_certificateString;
/**
* @var string
*/
diff --git a/library/Zend/Currency.php b/library/Zend/Currency.php
index d8b1dcda8c..68df473fd1 100644
--- a/library/Zend/Currency.php
+++ b/library/Zend/Currency.php
@@ -99,7 +99,7 @@ public function __construct($options = null, $locale = null)
if (is_array($options)) {
$this->setLocale($locale);
$this->setFormat($options);
- } else if (Zend_Locale::isLocale($options, false, false)) {
+ } elseif (Zend_Locale::isLocale($options, false, false)) {
$this->setLocale($options);
$options = $locale;
} else {
@@ -119,7 +119,7 @@ public function __construct($options = null, $locale = null)
$this->_options['symbol'] = self::getSymbol($options, $this->_options['locale']);
}
- if (($this->_options['currency'] === null) and ($this->_options['name'] === null)) {
+ if ($this->_options['currency'] === null && $this->_options['name'] === null) {
require_once 'Zend/Currency/Exception.php';
throw new Zend_Currency_Exception("Currency '$options' not found");
}
@@ -129,7 +129,7 @@ public function __construct($options = null, $locale = null)
|| (!is_array($calloptions) && $this->_options['display'] == self::NO_SYMBOL)) {
if (!empty($this->_options['symbol'])) {
$this->_options['display'] = self::USE_SYMBOL;
- } else if (!empty($this->_options['currency'])) {
+ } elseif (!empty($this->_options['currency'])) {
$this->_options['display'] = self::USE_SHORTNAME;
}
}
@@ -146,11 +146,7 @@ public function __construct($options = null, $locale = null)
public function toCurrency($value = null, array $options = array())
{
if ($value === null) {
- if (is_array($options) && isset($options['value'])) {
- $value = $options['value'];
- } else {
- $value = $this->_options['value'];
- }
+ $value = is_array($options) && isset($options['value']) ? $options['value'] : $this->_options['value'];
}
if (is_array($value)) {
@@ -161,7 +157,7 @@ public function toCurrency($value = null, array $options = array())
}
// Validate the passed number
- if (!(isset($value)) or (is_numeric($value) === false)) {
+ if (!(isset($value)) || !is_numeric($value)) {
require_once 'Zend/Currency/Exception.php';
throw new Zend_Currency_Exception("Value '$value' has to be numeric");
}
@@ -183,7 +179,7 @@ public function toCurrency($value = null, array $options = array())
$locale = $options['locale'];
if (empty($format)) {
$format = Zend_Locale_Data::getContent($locale, 'currencynumber');
- } else if (Zend_Locale::isLocale($format, true, false)) {
+ } elseif (Zend_Locale::isLocale($format, true, false)) {
$locale = $format;
$format = Zend_Locale_Data::getContent($format, 'currencynumber');
}
@@ -201,20 +197,16 @@ public function toCurrency($value = null, array $options = array())
$space = 'Â ';
}
- if ($options['position'] == self::LEFT) {
- $value = '¤' . $space . $value;
- } else {
- $value = $value . $space . '¤';
- }
+ $value = $options['position'] == self::LEFT ? '¤' . $space . $value : $value . $space . '¤';
}
// Localize the number digits
- if (empty($options['script']) === false) {
+ if (!empty($options['script'])) {
$value = Zend_Locale_Format::convertNumerals($value, 'Latn', $options['script']);
}
// Get the sign to be placed next to the number
- if (is_numeric($options['display']) === false) {
+ if (!is_numeric($options['display'])) {
$sign = $options['display'];
} else {
switch($options['display']) {
@@ -236,9 +228,7 @@ public function toCurrency($value = null, array $options = array())
break;
}
}
-
- $value = str_replace('¤', $sign, $value);
- return $value;
+ return str_replace('¤', $sign, $value);
}
/**
@@ -304,15 +294,14 @@ public function setFormat(array $options = array())
private function _checkParams($currency = null, $locale = null)
{
// Manage the params
- if ((empty($locale)) and (!empty($currency)) and
- (Zend_Locale::isLocale($currency, true, false))) {
+ if (empty($locale) && !empty($currency) && Zend_Locale::isLocale($currency, true, false)) {
$locale = $currency;
$currency = null;
}
// Validate the locale and get the country short name
$country = null;
- if ((Zend_Locale::isLocale($locale, true, false)) and (strlen((string) $locale) > 4)) {
+ if (Zend_Locale::isLocale($locale, true, false) && strlen((string) $locale) > 4) {
$country = substr($locale, (strpos($locale, '_') + 1));
} else {
require_once 'Zend/Currency/Exception.php';
@@ -321,11 +310,7 @@ private function _checkParams($currency = null, $locale = null)
// Get the available currencies for this country
$data = Zend_Locale_Data::getContent($locale, 'currencytoregion', $country);
- if ((empty($currency) === false) and (empty($data) === false)) {
- $abbreviation = $currency;
- } else {
- $abbreviation = $data;
- }
+ $abbreviation = (!empty($currency) && !empty($data)) ? $currency : $data;
return array('locale' => $locale, 'currency' => $currency, 'name' => $abbreviation, 'country' => $country);
}
@@ -340,7 +325,7 @@ private function _checkParams($currency = null, $locale = null)
*/
public function getSymbol($currency = null, $locale = null)
{
- if (($currency === null) and ($locale === null)) {
+ if ($currency === null && $locale === null) {
return $this->_options['symbol'];
}
@@ -348,11 +333,11 @@ public function getSymbol($currency = null, $locale = null)
// Get the symbol
$symbol = Zend_Locale_Data::getContent($params['locale'], 'currencysymbol', $params['currency']);
- if (empty($symbol) === true) {
+ if (empty($symbol)) {
$symbol = Zend_Locale_Data::getContent($params['locale'], 'currencysymbol', $params['name']);
}
- if (empty($symbol) === true) {
+ if (empty($symbol)) {
return null;
}
@@ -368,14 +353,14 @@ public function getSymbol($currency = null, $locale = null)
*/
public function getShortName($currency = null, $locale = null)
{
- if (($currency === null) and ($locale === null)) {
+ if ($currency === null && $locale === null) {
return $this->_options['currency'];
}
$params = self::_checkParams($currency, $locale);
// Get the shortname
- if (empty($params['currency']) === true) {
+ if (empty($params['currency'])) {
return $params['name'];
}
@@ -403,7 +388,7 @@ public function getShortName($currency = null, $locale = null)
*/
public function getName($currency = null, $locale = null)
{
- if (($currency === null) and ($locale === null)) {
+ if ($currency === null && $locale === null) {
return $this->_options['name'];
}
@@ -411,11 +396,11 @@ public function getName($currency = null, $locale = null)
// Get the name
$name = Zend_Locale_Data::getContent($params['locale'], 'nametocurrency', $params['currency']);
- if (empty($name) === true) {
+ if (empty($name)) {
$name = Zend_Locale_Data::getContent($params['locale'], 'nametocurrency', $params['name']);
}
- if (empty($name) === true) {
+ if (empty($name)) {
return null;
}
@@ -435,15 +420,13 @@ public function getRegionList($currency = null)
$currency = $this->_options['currency'];
}
- if (empty($currency) === true) {
+ if (empty($currency)) {
require_once 'Zend/Currency/Exception.php';
throw new Zend_Currency_Exception('No currency defined');
}
$data = Zend_Locale_Data::getContent($this->_options['locale'], 'regiontocurrency', $currency);
-
- $result = explode(' ', $data);
- return $result;
+ return explode(' ', $data);
}
/**
@@ -456,16 +439,12 @@ public function getRegionList($currency = null)
*/
public function getCurrencyList($region = null)
{
- if (empty($region) === true) {
- if (strlen((string) $this->_options['locale']) > 4) {
- $region = substr($this->_options['locale'], (strpos($this->_options['locale'], '_') + 1));
- }
+ if (empty($region) && strlen((string) $this->_options['locale']) > 4) {
+ $region = substr($this->_options['locale'], (strpos($this->_options['locale'], '_') + 1));
}
$data = Zend_Locale_Data::getContent($this->_options['locale'], 'currencytoregion', $region);
-
- $result = explode(' ', $data);
- return $result;
+ return explode(' ', $data);
}
/**
@@ -537,7 +516,7 @@ public static function removeCache()
*/
public static function clearCache($tag = null)
{
- Zend_Locale_Data::clearCache($tag);
+ Zend_Locale_Data::clearCache();
}
/**
@@ -562,7 +541,7 @@ public function setLocale($locale = null)
}
} catch (Zend_Locale_Exception $e) {
require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception($e->getMessage());
+ throw new Zend_Currency_Exception($e->getMessage(), $e->getCode(), $e);
}
// Get currency details
@@ -689,7 +668,7 @@ public function compare($value, $currency = null)
$value = $this->_options['value'] - $value;
if ($value < 0) {
return -1;
- } else if ($value > 0) {
+ } elseif ($value > 0) {
return 1;
}
@@ -706,11 +685,7 @@ public function compare($value, $currency = null)
public function equals($value, $currency = null)
{
$value = $this->_exchangeCurrency($value, $currency);
- if ($this->_options['value'] == $value) {
- return true;
- }
-
- return false;
+ return $this->_options['value'] == $value;
}
/**
@@ -723,11 +698,7 @@ public function equals($value, $currency = null)
public function isMore($value, $currency = null)
{
$value = $this->_exchangeCurrency($value, $currency);
- if ($this->_options['value'] > $value) {
- return true;
- }
-
- return false;
+ return $this->_options['value'] > $value;
}
/**
@@ -740,11 +711,7 @@ public function isMore($value, $currency = null)
public function isLess($value, $currency = null)
{
$value = $this->_exchangeCurrency($value, $currency);
- if ($this->_options['value'] < $value) {
- return true;
- }
-
- return false;
+ return $this->_options['value'] < $value;
}
@@ -774,9 +741,7 @@ protected function _exchangeCurrency($value, $currency)
$rate = $service->getRate($currency, $this->getShortName());
}
-
- $value *= $rate;
- return $value;
+ return $value * $rate;
}
/**
@@ -832,21 +797,19 @@ public function setService($service)
*/
protected function _checkOptions(array $options = array())
{
- if (count($options) === 0) {
+ if ($options === []) {
return $this->_options;
}
foreach ($options as $name => $value) {
$name = strtolower($name);
- if ($name !== 'format') {
- if (gettype($value) === 'string') {
- $value = strtolower($value);
- }
+ if ($name !== 'format' && gettype($value) === 'string') {
+ $value = strtolower($value);
}
switch($name) {
case 'position':
- if (($value !== self::STANDARD) and ($value !== self::RIGHT) and ($value !== self::LEFT)) {
+ if ($value !== self::STANDARD && $value !== self::RIGHT && $value !== self::LEFT) {
require_once 'Zend/Currency/Exception.php';
throw new Zend_Currency_Exception("Unknown position '" . $value . "'");
}
@@ -854,19 +817,16 @@ protected function _checkOptions(array $options = array())
break;
case 'format':
- if ((empty($value) === false) and (Zend_Locale::isLocale($value, null, false) === false)) {
- if (!is_string($value) || (strpos($value, '0') === false)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("'" .
- ((gettype($value) === 'object') ? get_class($value) : $value)
- . "' is no format token");
- }
+ if ((!empty($value) && !Zend_Locale::isLocale($value, null, false)) && (!is_string($value) || (strpos($value, '0') === false))) {
+ require_once 'Zend/Currency/Exception.php';
+ throw new Zend_Currency_Exception("'" .
+ ((gettype($value) === 'object') ? get_class($value) : $value)
+ . "' is no format token");
}
break;
case 'display':
- if (is_numeric($value) and ($value !== self::NO_SYMBOL) and ($value !== self::USE_SYMBOL) and
- ($value !== self::USE_SHORTNAME) and ($value !== self::USE_NAME)) {
+ if (is_numeric($value) && $value !== self::NO_SYMBOL && $value !== self::USE_SYMBOL && $value !== self::USE_SHORTNAME && $value !== self::USE_NAME) {
require_once 'Zend/Currency/Exception.php';
throw new Zend_Currency_Exception("Unknown display '$value'");
}
@@ -877,7 +837,7 @@ protected function _checkOptions(array $options = array())
$value = -1;
}
- if (($value < -1) or ($value > 30)) {
+ if ($value < -1 || $value > 30) {
require_once 'Zend/Currency/Exception.php';
throw new Zend_Currency_Exception("'$value' precision has to be between -1 and 30.");
}
@@ -888,7 +848,7 @@ protected function _checkOptions(array $options = array())
Zend_Locale_Format::convertNumerals(0, $options['script']);
} catch (Zend_Locale_Exception $e) {
require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception($e->getMessage());
+ throw new Zend_Currency_Exception($e->getMessage(), $e->getCode(), $e);
}
break;
diff --git a/library/Zend/Date.php b/library/Zend/Date.php
index 101d96929d..ce1467bbb5 100644
--- a/library/Zend/Date.php
+++ b/library/Zend/Date.php
@@ -136,8 +136,7 @@ class Zend_Date extends Zend_Date_DateObject
*/
public function __construct($date = null, $part = null, $locale = null)
{
- if (is_object($date) and !($date instanceof Zend_TimeSync_Protocol) and
- !($date instanceof Zend_Date)) {
+ if (is_object($date) && !($date instanceof Zend_TimeSync_Protocol) && !($date instanceof Zend_Date)) {
if ($locale instanceof Zend_Locale) {
$locale = $date;
$date = null;
@@ -147,12 +146,11 @@ public function __construct($date = null, $part = null, $locale = null)
}
}
- if (($date !== null) and !is_array($date) and !($date instanceof Zend_TimeSync_Protocol) and
- !($date instanceof Zend_Date) and !defined($date) and Zend_Locale::isLocale($date, true, false)) {
+ if ($date !== null && !is_array($date) && !($date instanceof Zend_TimeSync_Protocol) && !($date instanceof Zend_Date) && !defined($date) && Zend_Locale::isLocale($date, true, false)) {
$locale = $date;
$date = null;
$part = null;
- } else if (($part !== null) and !defined($part) and Zend_Locale::isLocale($part, true, false)) {
+ } elseif ($part !== null && !defined($part) && Zend_Locale::isLocale($part, true, false)) {
$locale = $part;
$part = null;
}
@@ -166,7 +164,7 @@ public function __construct($date = null, $part = null, $locale = null)
if ($date === null) {
if ($part === null) {
$date = time();
- } else if ($part !== self::TIMESTAMP) {
+ } elseif ($part !== self::TIMESTAMP) {
$date = self::now($locale);
$date = $date->get($part);
}
@@ -176,7 +174,7 @@ public function __construct($date = null, $part = null, $locale = null)
$date = $date->getInfo();
$date = $this->_getTime($date['offset']);
$part = null;
- } else if (parent::$_defaultOffset != 0) {
+ } elseif (parent::$_defaultOffset != 0) {
$date = $this->_getTime(parent::$_defaultOffset);
}
@@ -191,13 +189,13 @@ public function __construct($date = null, $part = null, $locale = null)
}
// set datepart
- if (($part !== null && $part !== self::TIMESTAMP) or (!is_numeric($date))) {
+ if ($part !== null && $part !== self::TIMESTAMP || !is_numeric($date)) {
// switch off dst handling for value setting
$this->setUnixTimestamp($this->getGmtOffset());
$this->set($date, $part, $this->_locale);
// DST fix
- if (is_array($date) === true) {
+ if (is_array($date)) {
if (!isset($date['hour'])) {
$date['hour'] = 0;
}
@@ -331,7 +329,7 @@ private function _timestamp($calc, $stamp)
}
if (is_array($stamp)) {
- if (isset($stamp['timestamp']) === true) {
+ if (isset($stamp['timestamp'])) {
$stamp = $stamp['timestamp'];
} else {
require_once 'Zend/Date/Exception.php';
@@ -339,11 +337,7 @@ private function _timestamp($calc, $stamp)
}
}
- if ($calc === 'set') {
- $return = $this->setUnixTimestamp($stamp);
- } else {
- $return = $this->_calcdetail($calc, $stamp, self::TIMESTAMP, null);
- }
+ $return = $calc === 'set' ? $this->setUnixTimestamp($stamp) : $this->_calcdetail($calc, $stamp, self::TIMESTAMP, null);
if ($calc != 'cmp') {
return $this;
}
@@ -447,8 +441,7 @@ public function toString($format = null, $type = null, $locale = null)
$format = null;
}
- if (($type !== null) and ($type != 'php') and ($type != 'iso') and
- Zend_Locale::isLocale($type, null, false)) {
+ if ($type !== null && $type != 'php' && $type != 'iso' && Zend_Locale::isLocale($type, null, false)) {
$locale = $type;
$type = null;
}
@@ -459,7 +452,7 @@ public function toString($format = null, $type = null, $locale = null)
if ($format === null) {
$format = Zend_Locale_Format::getDateFormat($locale) . ' ' . Zend_Locale_Format::getTimeFormat($locale);
- } else if (((self::$_options['format_type'] == 'php') && ($type === null)) or ($type == 'php')) {
+ } elseif ((self::$_options['format_type'] == 'php') && ($type === null) || $type == 'php') {
$format = Zend_Locale_Format::convertPhpToIsoFormat($format);
}
@@ -487,7 +480,7 @@ public function toValue($part = null)
{
$result = $this->get($part);
if (is_numeric($result)) {
- return intval("$result");
+ return (int) "$result";
} else {
return false;
}
@@ -539,7 +532,7 @@ public function get($part = null, $locale = null)
if ($part === null) {
$part = self::TIMESTAMP;
- } else if (self::$_options['format_type'] == 'php') {
+ } elseif (self::$_options['format_type'] == 'php') {
$part = Zend_Locale_Format::convertPhpToIsoFormat($part);
}
@@ -560,9 +553,9 @@ private function _toToken($part, $locale) {
$orig = '';
for ($i = 0; isset($part[$i]); ++$i) {
if ($part[$i] == "'") {
- $comment = $comment ? false : true;
+ $comment = !$comment;
if (isset($part[$i+1]) && ($part[$i+1] == "'")) {
- $comment = $comment ? false : true;
+ $comment = !$comment;
$format .= "\\'";
++$i;
}
@@ -576,7 +569,7 @@ private function _toToken($part, $locale) {
$orig = '';
} else {
$orig .= $part[$i];
- if (!isset($part[$i+1]) || (isset($orig[0]) && ($orig[0] != $part[$i+1]))) {
+ if (!isset($part[$i+1]) || (isset($orig[0]) && ($orig[0] !== $part[$i+1]))) {
$format .= $this->_parseIsoToDate($orig, $locale);
$orig = '';
}
@@ -1047,7 +1040,7 @@ public static function getFullYear($value)
if ($value >= 0) {
if ($value < 70) {
$value += 2000;
- } else if ($value < 100) {
+ } elseif ($value < 100) {
$value += 1900;
}
}
@@ -1147,7 +1140,7 @@ public function compare($date, $part = self::TIMESTAMP, $locale = null)
if ($compare > 0) {
return 1;
- } else if ($compare < 0) {
+ } elseif ($compare < 0) {
return -1;
}
return 0;
@@ -1201,7 +1194,7 @@ public function getTimezoneFromString($zone)
}
preg_match('/([+-]\d{2}):{0,1}\d{2}/', $zone, $match);
- if (!empty($match) and ($match[count($match) - 1] <= 14) and ($match[count($match) - 1] >= -12)) {
+ if (!empty($match) && $match[count($match) - 1] <= 14 && $match[count($match) - 1] >= -12) {
$zone = "Etc/GMT";
$zone .= ($match[count($match) - 1] < 0) ? "+" : "-";
$zone .= (int) abs($match[count($match) - 1]);
@@ -1210,7 +1203,7 @@ public function getTimezoneFromString($zone)
preg_match('/([[:alpha:]\/_]{3,30})(?!.*([[:alpha:]\/]{3,30}))/', $zone, $match);
try {
- if (!empty($match) and (!is_int($match[count($match) - 1]))) {
+ if (!empty($match) && !is_int($match[count($match) - 1])) {
$oldzone = $this->getTimezone();
$this->setTimezone($match[count($match) - 1]);
$result = $this->getTimezone();
@@ -1260,12 +1253,12 @@ private function _assign($calc, $date, $comp = 0, $dst = false)
}
// dst-correction if 'fix_dst' = true and dst !== false but only for non UTC and non GMT
- if ((self::$_options['fix_dst'] === true) and ($dst !== false) and ($this->_dst === true)) {
+ if (self::$_options['fix_dst'] === true && $dst !== false && $this->_dst === true) {
$hour = $this->toString(self::HOUR, 'iso');
if ($hour != $dst) {
- if (($dst == ($hour + 1)) or ($dst == ($hour - 23))) {
+ if ($dst == ($hour + 1) || $dst == ($hour - 23)) {
$value += 3600;
- } else if (($dst == ($hour - 1)) or ($dst == ($hour + 23))) {
+ } elseif ($dst == ($hour - 1) || $dst == ($hour + 23)) {
$value -= 3600;
}
$this->setUnixTimestamp($value);
@@ -1315,13 +1308,13 @@ private function _calculate($calc, $date, $part, $locale)
$date = $date->toString($part, 'iso', $locale);
}
- if (is_array($date) === true) {
- if (empty($part) === false) {
+ if (is_array($date)) {
+ if (!empty($part)) {
switch($part) {
// Fall through
case self::DAY:
case self::DAY_SHORT:
- if (isset($date['day']) === true) {
+ if (isset($date['day'])) {
$date = $date['day'];
}
break;
@@ -1332,13 +1325,13 @@ private function _calculate($calc, $date, $part, $locale)
case self::WEEKDAY_DIGIT:
case self::WEEKDAY_NARROW:
case self::WEEKDAY_NAME:
- if (isset($date['weekday']) === true) {
+ if (isset($date['weekday'])) {
$date = $date['weekday'];
$part = self::WEEKDAY_DIGIT;
}
break;
case self::DAY_OF_YEAR:
- if (isset($date['day_of_year']) === true) {
+ if (isset($date['day_of_year'])) {
$date = $date['day_of_year'];
}
break;
@@ -1348,7 +1341,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::MONTH_NAME:
case self::MONTH_NAME_SHORT:
case self::MONTH_NAME_NARROW:
- if (isset($date['month']) === true) {
+ if (isset($date['month'])) {
$date = $date['month'];
}
break;
@@ -1357,7 +1350,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::YEAR_SHORT:
case self::YEAR_8601:
case self::YEAR_SHORT_8601:
- if (isset($date['year']) === true) {
+ if (isset($date['year'])) {
$date = $date['year'];
}
break;
@@ -1366,43 +1359,43 @@ private function _calculate($calc, $date, $part, $locale)
case self::HOUR_AM:
case self::HOUR_SHORT:
case self::HOUR_SHORT_AM:
- if (isset($date['hour']) === true) {
+ if (isset($date['hour'])) {
$date = $date['hour'];
}
break;
// Fall through
case self::MINUTE:
case self::MINUTE_SHORT:
- if (isset($date['minute']) === true) {
+ if (isset($date['minute'])) {
$date = $date['minute'];
}
break;
// Fall through
case self::SECOND:
case self::SECOND_SHORT:
- if (isset($date['second']) === true) {
+ if (isset($date['second'])) {
$date = $date['second'];
}
break;
// Fall through
case self::TIMEZONE:
case self::TIMEZONE_NAME:
- if (isset($date['timezone']) === true) {
+ if (isset($date['timezone'])) {
$date = $date['timezone'];
}
break;
case self::TIMESTAMP:
- if (isset($date['timestamp']) === true) {
+ if (isset($date['timestamp'])) {
$date = $date['timestamp'];
}
break;
case self::WEEK:
- if (isset($date['week']) === true) {
+ if (isset($date['week'])) {
$date = $date['week'];
}
break;
case self::TIMEZONE_SECS:
- if (isset($date['gmtsecs']) === true) {
+ if (isset($date['gmtsecs'])) {
$date = $date['gmtsecs'];
}
break;
@@ -1413,27 +1406,27 @@ private function _calculate($calc, $date, $part, $locale)
}
} else {
$hours = 0;
- if (isset($date['hour']) === true) {
+ if (isset($date['hour'])) {
$hours = $date['hour'];
}
$minutes = 0;
- if (isset($date['minute']) === true) {
+ if (isset($date['minute'])) {
$minutes = $date['minute'];
}
$seconds = 0;
- if (isset($date['second']) === true) {
+ if (isset($date['second'])) {
$seconds = $date['second'];
}
$months = 0;
- if (isset($date['month']) === true) {
+ if (isset($date['month'])) {
$months = $date['month'];
}
$days = 0;
- if (isset($date['day']) === true) {
+ if (isset($date['day'])) {
$days = $date['day'];
}
$years = 0;
- if (isset($date['year']) === true) {
+ if (isset($date['year'])) {
$years = $date['year'];
}
return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, $months, $days, $years, true),
@@ -1447,8 +1440,8 @@ private function _calculate($calc, $date, $part, $locale)
// day formats
case self::DAY:
if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true), $hour);
+ return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + (int) $date, 1970, true),
+ $this->mktime(0, 0, 0, 1, 1 + (int) $day, 1970, true), $hour);
}
require_once 'Zend/Date/Exception.php';
@@ -1461,7 +1454,7 @@ private function _calculate($calc, $date, $part, $locale)
$cnt = 0;
foreach ($daylist as $key => $value) {
- if (strtoupper(iconv_substr($value, 0, 3, 'UTF-8')) == strtoupper($date)) {
+ if (strtoupper(iconv_substr($value, 0, 3, 'UTF-8')) === strtoupper($date)) {
$found = $cnt;
break;
}
@@ -1481,8 +1474,8 @@ private function _calculate($calc, $date, $part, $locale)
case self::DAY_SHORT:
if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true), $hour);
+ return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + (int) $date, 1970, true),
+ $this->mktime(0, 0, 0, 1, 1 + (int) $day, 1970, true), $hour);
}
require_once 'Zend/Date/Exception.php';
@@ -1495,7 +1488,7 @@ private function _calculate($calc, $date, $part, $locale)
$cnt = 0;
foreach ($daylist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
+ if (strtoupper($value) === strtoupper($date)) {
$found = $cnt;
break;
}
@@ -1515,8 +1508,8 @@ private function _calculate($calc, $date, $part, $locale)
case self::WEEKDAY_8601:
$weekday = (int) $this->toString(self::WEEKDAY_8601, 'iso', $locale);
- if ((intval($date) > 0) and (intval($date) < 8)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),
+ if ((int) $date > 0 && (int) $date < 8) {
+ return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + (int) $date, 1970, true),
$this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
}
@@ -1532,7 +1525,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::WEEKDAY_DIGIT:
$weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- if (is_numeric($date) and (intval($date) >= 0) and (intval($date) < 7)) {
+ if (is_numeric($date) && (int) $date >= 0 && (int) $date < 7) {
return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $date, 1970, true),
$this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
}
@@ -1563,7 +1556,7 @@ private function _calculate($calc, $date, $part, $locale)
$weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
$cnt = 0;
foreach ($daylist as $key => $value) {
- if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) == strtoupper($date)) {
+ if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) === strtoupper($date)) {
$found = $cnt;
break;
}
@@ -1586,7 +1579,7 @@ private function _calculate($calc, $date, $part, $locale)
$weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
$cnt = 0;
foreach ($daylist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
+ if (strtoupper($value) === strtoupper($date)) {
$found = $cnt;
break;
}
@@ -1621,7 +1614,7 @@ private function _calculate($calc, $date, $part, $locale)
$monthlist = Zend_Locale_Data::getList($locale, 'month');
$cnt = 0;
foreach ($monthlist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
+ if (strtoupper($value) === strtoupper($date)) {
$found = $key;
break;
}
@@ -1641,7 +1634,7 @@ private function _calculate($calc, $date, $part, $locale)
$fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
}
}
- } else if ($calc == 'sub') {
+ } elseif ($calc == 'sub') {
$date = $month - $found;
$calc = 'set';
if (self::$_options['extend_month'] == false) {
@@ -1672,7 +1665,7 @@ private function _calculate($calc, $date, $part, $locale)
$fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
}
}
- } else if ($calc == 'sub') {
+ } elseif ($calc == 'sub') {
$date = $month - $date;
$calc = 'set';
if (self::$_options['extend_month'] == false) {
@@ -1694,7 +1687,7 @@ private function _calculate($calc, $date, $part, $locale)
$monthlist = Zend_Locale_Data::getList($locale, 'month', array('gregorian', 'format', 'abbreviated'));
$cnt = 0;
foreach ($monthlist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
+ if (strtoupper($value) === strtoupper($date)) {
$found = $key;
break;
}
@@ -1714,7 +1707,7 @@ private function _calculate($calc, $date, $part, $locale)
$fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
}
}
- } else if ($calc == 'sub') {
+ } elseif ($calc == 'sub') {
$date = $month - $found;
$calc = 'set';
if (self::$_options['extend_month'] === false) {
@@ -1734,7 +1727,7 @@ private function _calculate($calc, $date, $part, $locale)
break;
case self::MONTH_SHORT:
- if (is_numeric($date) === true) {
+ if (is_numeric($date)) {
$fixday = 0;
if ($calc === 'add') {
$date += $month;
@@ -1745,7 +1738,7 @@ private function _calculate($calc, $date, $part, $locale)
$fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
}
}
- } else if ($calc === 'sub') {
+ } elseif ($calc === 'sub') {
$date = $month - $date;
$calc = 'set';
if (self::$_options['extend_month'] === false) {
@@ -1793,7 +1786,7 @@ private function _calculate($calc, $date, $part, $locale)
$fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
}
}
- } else if ($calc === 'sub') {
+ } elseif ($calc === 'sub') {
$date = $month - $found;
$calc = 'set';
if (self::$_options['extend_month'] === false) {
@@ -1823,12 +1816,12 @@ private function _calculate($calc, $date, $part, $locale)
if ($calc === 'add') {
$date += $year;
$calc = 'set';
- } else if ($calc === 'sub') {
+ } elseif ($calc === 'sub') {
$date = $year - $date;
$calc = 'set';
}
- return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, intval($date), true),
+ return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, (int) $date, true),
$this->mktime(0, 0, 0, $month, $day, $year, true), false);
}
@@ -1841,12 +1834,12 @@ private function _calculate($calc, $date, $part, $locale)
if ($calc === 'add') {
$date += $year;
$calc = 'set';
- } else if ($calc === 'sub') {
+ } elseif ($calc === 'sub') {
$date = $year - $date;
$calc = 'set';
}
- return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, intval($date), true),
+ return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, (int) $date, true),
$this->mktime(0, 0, 0, $month, $day, $year, true), false);
}
@@ -1856,14 +1849,14 @@ private function _calculate($calc, $date, $part, $locale)
case self::YEAR_SHORT:
if (is_numeric($date)) {
- $date = intval($date);
+ $date = (int) $date;
if (($calc == 'set') || ($calc == 'cmp')) {
$date = self::getFullYear($date);
}
if ($calc === 'add') {
$date += $year;
$calc = 'set';
- } else if ($calc === 'sub') {
+ } elseif ($calc === 'sub') {
$date = $year - $date;
$calc = 'set';
}
@@ -1878,14 +1871,14 @@ private function _calculate($calc, $date, $part, $locale)
case self::YEAR_SHORT_8601:
if (is_numeric($date)) {
- $date = intval($date);
+ $date = (int) $date;
if (($calc === 'set') || ($calc === 'cmp')) {
$date = self::getFullYear($date);
}
if ($calc === 'add') {
$date += $year;
$calc = 'set';
- } else if ($calc === 'sub') {
+ } elseif ($calc === 'sub') {
$date = $year - $date;
$calc = 'set';
}
@@ -1906,11 +1899,11 @@ private function _calculate($calc, $date, $part, $locale)
case self::SWATCH:
if (is_numeric($date)) {
- $rest = intval($date);
+ $rest = (int) $date;
$hours = floor($rest * 24 / 1000);
- $rest = $rest - ($hours * 1000 / 24);
+ $rest -= $hours * 1000 / 24;
$minutes = floor($rest * 1440 / 1000);
- $rest = $rest - ($minutes * 1000 / 1440);
+ $rest -= $minutes * 1000 / 1440;
$seconds = floor($rest * 86400 / 1000);
return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1, 1, 1970, true),
$this->mktime($hour, $minute, $second, 1, 1, 1970, true), false);
@@ -1922,7 +1915,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::HOUR_SHORT_AM:
if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
+ return $this->_assign($calc, $this->mktime((int) $date, 0, 0, 1, 1, 1970, true),
$this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
}
@@ -1932,7 +1925,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::HOUR_SHORT:
if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
+ return $this->_assign($calc, $this->mktime((int) $date, 0, 0, 1, 1, 1970, true),
$this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
}
@@ -1942,7 +1935,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::HOUR_AM:
if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
+ return $this->_assign($calc, $this->mktime((int) $date, 0, 0, 1, 1, 1970, true),
$this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
}
@@ -1952,7 +1945,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::HOUR:
if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
+ return $this->_assign($calc, $this->mktime((int) $date, 0, 0, 1, 1, 1970, true),
$this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
}
@@ -1962,7 +1955,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::MINUTE:
if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, intval($date), 0, 1, 1, 1970, true),
+ return $this->_assign($calc, $this->mktime(0, (int) $date, 0, 1, 1, 1970, true),
$this->mktime(0, $minute, 0, 1, 1, 1970, true), false);
}
@@ -1972,7 +1965,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::SECOND:
if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, intval($date), 1, 1, 1970, true),
+ return $this->_assign($calc, $this->mktime(0, 0, (int) $date, 1, 1, 1970, true),
$this->mktime(0, 0, $second, 1, 1, 1970, true), false);
}
@@ -2003,7 +1996,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::MINUTE_SHORT:
if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, intval($date), 0, 1, 1, 1970, true),
+ return $this->_assign($calc, $this->mktime(0, (int) $date, 0, 1, 1, 1970, true),
$this->mktime(0, $minute, 0, 1, 1, 1970, true), false);
}
@@ -2013,7 +2006,7 @@ private function _calculate($calc, $date, $part, $locale)
case self::SECOND_SHORT:
if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, intval($date), 1, 1, 1970, true),
+ return $this->_assign($calc, $this->mktime(0, 0, (int) $date, 1, 1, 1970, true),
$this->mktime(0, 0, $second, 1, 1, 1970, true), false);
}
@@ -2079,7 +2072,7 @@ private function _calculate($calc, $date, $part, $locale)
if (empty($timematch)) {
preg_match('/[T,\s]{0,1}(\d{2})(\d{2})/', (string) $tmpdate, $timematch);
}
- if (empty($datematch) and empty($timematch)) {
+ if (empty($datematch) && empty($timematch)) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("unsupported ISO8601 format ($date)", 0, null, $date);
}
@@ -2094,7 +2087,7 @@ private function _calculate($calc, $date, $part, $locale)
$datematch[1] = 1970;
$datematch[2] = 1;
$datematch[3] = 1;
- } else if (iconv_strlen($datematch[1], 'UTF-8') == 2) {
+ } elseif (iconv_strlen($datematch[1], 'UTF-8') == 2) {
$datematch[1] = self::getFullYear($datematch[1]);
}
if (empty($timematch)) {
@@ -2119,9 +2112,7 @@ private function _calculate($calc, $date, $part, $locale)
break;
case self::RFC_2822:
- $result = preg_match('/^\w{3},\s(\d{1,2})\s(\w{3})\s(\d{4})\s'
- . '(\d{2}):(\d{2}):{0,1}(\d{0,2})\s([+-]'
- . '{1}\d{4}|\w{1,20})$/', (string) $date, $match);
+ $result = preg_match('/^\w{3},\s(\d{1,2})\s(\w{3})\s(\d{4})\s(\d{2}):(\d{2}):{0,1}(\d{0,2})\s([+-]{1}\d{4}|\w{1,20})$/', (string) $date, $match);
if (!$result) {
require_once 'Zend/Date/Exception.php';
@@ -2639,7 +2630,7 @@ private function _calculate($calc, $date, $part, $locale)
}
$parsed = Zend_Locale_Format::getDate($date, array('date_format' => $part, 'locale' => $locale, 'fix_date' => true, 'format_type' => 'iso'));
- if ((strpos(strtoupper($part), 'YY') !== false) and (strpos(strtoupper($part), 'YYYY') === false)) {
+ if (strpos(strtoupper($part), 'YY') !== false && strpos(strtoupper($part), 'YYYY') === false) {
$parsed['year'] = self::getFullYear($parsed['year']);
}
@@ -2696,12 +2687,7 @@ private function _calculate($calc, $date, $part, $locale)
public function equals($date, $part = self::TIMESTAMP, $locale = null)
{
$result = $this->compare($date, $part, $locale);
-
- if ($result == 0) {
- return true;
- }
-
- return false;
+ return $result == 0;
}
/**
@@ -2718,12 +2704,7 @@ public function equals($date, $part = self::TIMESTAMP, $locale = null)
public function isEarlier($date, $part = null, $locale = null)
{
$result = $this->compare($date, $part, $locale);
-
- if ($result == -1) {
- return true;
- }
-
- return false;
+ return $result == -1;
}
/**
@@ -2741,12 +2722,7 @@ public function isEarlier($date, $part = null, $locale = null)
public function isLater($date, $part = null, $locale = null)
{
$result = $this->compare($date, $part, $locale);
-
- if ($result == 1) {
- return true;
- }
-
- return false;
+ return $result == 1;
}
/**
@@ -2759,11 +2735,7 @@ public function isLater($date, $part = null, $locale = null)
*/
public function getTime($locale = null)
{
- if (self::$_options['format_type'] == 'php') {
- $format = 'H:i:s';
- } else {
- $format = self::TIME_MEDIUM;
- }
+ $format = self::$_options['format_type'] == 'php' ? 'H:i:s' : self::TIME_MEDIUM;
return $this->copyPart($format, $locale);
}
@@ -2790,8 +2762,7 @@ private function _time($calc, $time, $format, $locale)
$time = $time->toString('HH:mm:ss', 'iso');
} else {
if (is_array($time)) {
- if ((isset($time['hour']) === true) or (isset($time['minute']) === true) or
- (isset($time['second']) === true)) {
+ if (isset($time['hour']) || isset($time['minute']) || isset($time['second'])) {
$parsed = $time;
} else {
require_once 'Zend/Date/Exception.php';
@@ -2952,8 +2923,7 @@ private function _date($calc, $date, $format, $locale)
$date = $date->toString('d.M.y', 'iso');
} else {
if (is_array($date)) {
- if ((isset($date['year']) === true) or (isset($date['month']) === true) or
- (isset($date['day']) === true)) {
+ if (isset($date['year']) || isset($date['month']) || isset($date['day'])) {
$parsed = $date;
} else {
require_once 'Zend/Date/Exception.php';
@@ -2969,7 +2939,7 @@ private function _date($calc, $date, $format, $locale)
}
$parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'locale' => $locale, 'format_type' => 'iso'));
- if ((strpos(strtoupper($format), 'YY') !== false) and (strpos(strtoupper($format), 'YYYY') === false)) {
+ if (strpos(strtoupper($format), 'YY') !== false && strpos(strtoupper($format), 'YYYY') === false) {
$parsed['year'] = self::getFullYear($parsed['year']);
}
} catch (Zend_Locale_Exception $e) {
@@ -3167,11 +3137,7 @@ public function compareIso($date, $locale = null)
*/
public function getArpa($locale = null)
{
- if (self::$_options['format_type'] == 'php') {
- $format = 'D\, d M y H\:i\:s O';
- } else {
- $format = self::RFC_822;
- }
+ $format = self::$_options['format_type'] == 'php' ? 'D\, d M y H\:i\:s O' : self::RFC_822;
return $this->toString($format, 'iso', $locale);
}
@@ -3256,15 +3222,15 @@ public function compareArpa($date, $locale = null)
*/
private function _checkLocation($location)
{
- if (!isset($location['longitude']) or !isset($location['latitude'])) {
+ if (!isset($location['longitude']) || !isset($location['latitude'])) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception('Location must include \'longitude\' and \'latitude\'', 0, null, $location);
}
- if (($location['longitude'] > 180) or ($location['longitude'] < -180)) {
+ if ($location['longitude'] > 180 || $location['longitude'] < -180) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception('Longitude must be between -180 and 180', 0, null, $location);
}
- if (($location['latitude'] > 90) or ($location['latitude'] < -90)) {
+ if ($location['latitude'] > 90 || $location['latitude'] < -90) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception('Latitude must be between -90 and 90', 0, null, $location);
}
@@ -3384,7 +3350,7 @@ public static function checkLeapYear($year)
}
if (is_array($year)) {
- if (isset($year['year']) === true) {
+ if (isset($year['year'])) {
$year = $year['year'];
} else {
require_once 'Zend/Date/Exception.php';
@@ -3421,7 +3387,7 @@ public function isToday()
{
$today = $this->date('Ymd', $this->_getTime());
$day = $this->date('Ymd', $this->getUnixTimestamp());
- return ($today == $day);
+ return ($today === $day);
}
@@ -3436,7 +3402,7 @@ public function isYesterday()
// adjusts for leap days and DST changes that are timezone specific
$yesterday = $this->date('Ymd', $this->mktime(0, 0, 0, $month, $day -1, $year));
$day = $this->date('Ymd', $this->getUnixTimestamp());
- return $day == $yesterday;
+ return $day === $yesterday;
}
@@ -3451,7 +3417,7 @@ public function isTomorrow()
// adjusts for leap days and DST changes that are timezone specific
$tomorrow = $this->date('Ymd', $this->mktime(0, 0, 0, $month, $day +1, $year));
$day = $this->date('Ymd', $this->getUnixTimestamp());
- return $day == $tomorrow;
+ return $day === $tomorrow;
}
/**
@@ -3530,7 +3496,7 @@ private function _calcvalue($calc, $value, $type, $parameter, $locale)
if ($value instanceof Zend_Date) {
// extract value from object
$value = $value->toString($parameter, 'iso', $locale);
- } else if (!is_array($value) && !is_numeric($value) && ($type != 'iso') && ($type != 'arpa')) {
+ } elseif (!is_array($value) && !is_numeric($value) && ($type != 'iso') && ($type != 'arpa')) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("invalid $type ($value) operand", 0, null, $value);
}
@@ -3552,11 +3518,7 @@ private function _calcvalue($calc, $value, $type, $parameter, $locale)
*/
public function getYear($locale = null)
{
- if (self::$_options['format_type'] == 'php') {
- $format = 'Y';
- } else {
- $format = self::YEAR;
- }
+ $format = self::$_options['format_type'] == 'php' ? 'Y' : self::YEAR;
return $this->copyPart($format, $locale);
}
@@ -3644,11 +3606,7 @@ public function compareYear($year, $locale = null)
*/
public function getMonth($locale = null)
{
- if (self::$_options['format_type'] == 'php') {
- $format = 'm';
- } else {
- $format = self::MONTH;
- }
+ $format = self::$_options['format_type'] == 'php' ? 'm' : self::MONTH;
return $this->copyPart($format, $locale);
}
@@ -3677,43 +3635,41 @@ private function _month($calc, $month, $locale)
if ($month instanceof Zend_Date) {
// extract month from object
$found = $month->toString(self::MONTH_SHORT, 'iso', $locale);
+ } elseif (is_numeric($month)) {
+ $found = $month;
+ } elseif (is_array($month)) {
+ if (isset($month['month'])) {
+ $month = $month['month'];
+ } else {
+ require_once 'Zend/Date/Exception.php';
+ throw new Zend_Date_Exception("no month given in array");
+ }
} else {
- if (is_numeric($month)) {
- $found = $month;
- } else if (is_array($month)) {
- if (isset($month['month']) === true) {
- $month = $month['month'];
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no month given in array");
+ $monthlist = Zend_Locale_Data::getList($locale, 'month');
+ $monthlist2 = Zend_Locale_Data::getList($locale, 'month', array('gregorian', 'format', 'abbreviated'));
+
+ $monthlist = array_merge($monthlist, $monthlist2);
+ $found = 0;
+ $cnt = 0;
+ foreach ($monthlist as $key => $value) {
+ if (strtoupper($value) === strtoupper($month)) {
+ $found = ($key % 12) + 1;
+ break;
}
- } else {
- $monthlist = Zend_Locale_Data::getList($locale, 'month');
- $monthlist2 = Zend_Locale_Data::getList($locale, 'month', array('gregorian', 'format', 'abbreviated'));
-
- $monthlist = array_merge($monthlist, $monthlist2);
- $found = 0;
- $cnt = 0;
- foreach ($monthlist as $key => $value) {
- if (strtoupper($value) == strtoupper($month)) {
- $found = ($key % 12) + 1;
+ ++$cnt;
+ }
+ if ($found == 0) {
+ foreach ($monthlist2 as $key => $value) {
+ if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) === strtoupper($month)) {
+ $found = $key + 1;
break;
}
++$cnt;
}
- if ($found == 0) {
- foreach ($monthlist2 as $key => $value) {
- if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) == strtoupper($month)) {
- $found = $key + 1;
- break;
- }
- ++$cnt;
- }
- }
- if ($found == 0) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("unknown month name ($month)", 0, null, $month);
- }
+ }
+ if ($found == 0) {
+ require_once 'Zend/Date/Exception.php';
+ throw new Zend_Date_Exception("unknown month name ($month)", 0, null, $month);
}
}
$return = $this->_calcdetail($calc, $found, self::MONTH_SHORT, $locale);
@@ -3835,8 +3791,8 @@ private function _day($calc, $day, $locale)
if (is_numeric($day)) {
$type = self::DAY_SHORT;
- } else if (is_array($day)) {
- if (isset($day['day']) === true) {
+ } elseif (is_array($day)) {
+ if (isset($day['day'])) {
$day = $day['day'];
$type = self::WEEKDAY;
} else {
@@ -3949,11 +3905,7 @@ public function compareDay($day, $locale = null)
*/
public function getWeekday($locale = null)
{
- if (self::$_options['format_type'] == 'php') {
- $format = 'l';
- } else {
- $format = self::WEEKDAY;
- }
+ $format = self::$_options['format_type'] == 'php' ? 'l' : self::WEEKDAY;
return $this->copyPart($format, $locale);
}
@@ -3985,8 +3937,8 @@ private function _weekday($calc, $weekday, $locale)
if (is_numeric($weekday)) {
$type = self::WEEKDAY_8601;
- } else if (is_array($weekday)) {
- if (isset($weekday['weekday']) === true) {
+ } elseif (is_array($weekday)) {
+ if (isset($weekday['weekday'])) {
$weekday = $weekday['weekday'];
$type = self::WEEKDAY;
} else {
@@ -4100,11 +4052,7 @@ public function compareWeekday($weekday, $locale = null)
*/
public function getDayOfYear($locale = null)
{
- if (self::$_options['format_type'] == 'php') {
- $format = 'D';
- } else {
- $format = self::DAY_OF_YEAR;
- }
+ $format = self::$_options['format_type'] == 'php' ? 'D' : self::DAY_OF_YEAR;
return $this->copyPart($format, $locale);
}
@@ -4266,11 +4214,7 @@ public function compareHour($hour, $locale = null)
*/
public function getMinute($locale = null)
{
- if (self::$_options['format_type'] == 'php') {
- $format = 'i';
- } else {
- $format = self::MINUTE;
- }
+ $format = self::$_options['format_type'] == 'php' ? 'i' : self::MINUTE;
return $this->copyPart($format, $locale);
}
@@ -4352,11 +4296,7 @@ public function compareMinute($minute, $locale = null)
*/
public function getSecond($locale = null)
{
- if (self::$_options['format_type'] == 'php') {
- $format = 's';
- } else {
- $format = self::SECOND;
- }
+ $format = self::$_options['format_type'] == 'php' ? 's' : self::SECOND;
return $this->copyPart($format, $locale);
}
@@ -4449,7 +4389,7 @@ public function getFractionalPrecision()
*/
public function setFractionalPrecision($precision)
{
- if (!intval($precision) or ($precision < 0) or ($precision > 9)) {
+ if (!(int) $precision || $precision < 0 || $precision > 9) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
}
@@ -4488,9 +4428,9 @@ public function setMilliSecond($milli = null, $precision = null)
{
if ($milli === null) {
list($milli, $time) = explode(" ", microtime());
- $milli = intval($milli);
+ $milli = (int) $milli;
$precision = 6;
- } else if (!is_numeric($milli)) {
+ } elseif (!is_numeric($milli)) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("invalid milli second ($milli) operand", 0, null, $milli);
}
@@ -4521,8 +4461,8 @@ public function addMilliSecond($milli = null, $precision = null)
{
if ($milli === null) {
list($milli, $time) = explode(" ", microtime());
- $milli = intval($milli);
- } else if (!is_numeric($milli)) {
+ $milli = (int) $milli;
+ } elseif (!is_numeric($milli)) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("invalid milli second ($milli) operand", 0, null, $milli);
}
@@ -4543,7 +4483,7 @@ public function addMilliSecond($milli = null, $precision = null)
}
if ($this->_precision > $precision) {
- $milli = $milli * pow(10, $this->_precision - $precision);
+ $milli *= pow(10, $this->_precision - $precision);
} elseif ($this->_precision < $precision) {
$milli = round($milli / pow(10, $precision - $this->_precision));
}
@@ -4600,15 +4540,15 @@ public function compareMilliSecond($milli = null, $precision = null)
{
if ($milli === null) {
list($milli, $time) = explode(" ", microtime());
- $milli = intval($milli);
- } else if (is_numeric($milli) === false) {
+ $milli = (int) $milli;
+ } elseif (!is_numeric($milli)) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("invalid milli second ($milli) operand", 0, null, $milli);
}
if ($precision === null) {
$precision = strlen((string) $milli);
- } else if (!is_int($precision) || $precision < 1 || $precision > 9) {
+ } elseif (!is_int($precision) || $precision < 1 || $precision > 9) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
}
@@ -4631,7 +4571,7 @@ public function compareMilliSecond($milli = null, $precision = null)
$comp = $this->_fractional - $milli;
if ($comp < 0) {
return -1;
- } else if ($comp > 0) {
+ } elseif ($comp > 0) {
return 1;
}
return 0;
@@ -4646,11 +4586,7 @@ public function compareMilliSecond($milli = null, $precision = null)
*/
public function getWeek($locale = null)
{
- if (self::$_options['format_type'] == 'php') {
- $format = 'W';
- } else {
- $format = self::WEEK;
- }
+ $format = self::$_options['format_type'] == 'php' ? 'W' : self::WEEK;
return $this->copyPart($format, $locale);
}
@@ -4777,7 +4713,7 @@ public static function isDate($date, $format = null, $locale = null)
if ($format === null) {
$format = Zend_Locale_Format::getDateFormat($locale);
- } else if ((self::$_options['format_type'] == 'php') && !defined($format)) {
+ } elseif ((self::$_options['format_type'] == 'php') && !defined($format)) {
$format = Zend_Locale_Format::convertPhpToIsoFormat($format);
}
@@ -4795,68 +4731,62 @@ public static function isDate($date, $format = null, $locale = null)
$parsed = $date;
}
- if (((strpos($format, 'Y') !== false) or (strpos($format, 'y') !== false)) and
- (!isset($parsed['year']))) {
+ if ((strpos($format, 'Y') !== false || strpos($format, 'y') !== false) && !isset($parsed['year'])) {
// Year expected but not found
return false;
}
- if ((strpos($format, 'M') !== false) and (!isset($parsed['month']))) {
+ if (strpos($format, 'M') !== false && !isset($parsed['month'])) {
// Month expected but not found
return false;
}
- if ((strpos($format, 'd') !== false) and (!isset($parsed['day']))) {
+ if (strpos($format, 'd') !== false && !isset($parsed['day'])) {
// Day expected but not found
return false;
}
- if (((strpos($format, 'H') !== false) or (strpos($format, 'h') !== false)) and
- (!isset($parsed['hour']))) {
+ if ((strpos($format, 'H') !== false || strpos($format, 'h') !== false) && !isset($parsed['hour'])) {
// Hour expected but not found
return false;
}
- if ((strpos($format, 'm') !== false) and (!isset($parsed['minute']))) {
+ if (strpos($format, 'm') !== false && !isset($parsed['minute'])) {
// Minute expected but not found
return false;
}
- if ((strpos($format, 's') !== false) and (!isset($parsed['second']))) {
+ if (strpos($format, 's') !== false && !isset($parsed['second'])) {
// Second expected but not found
return false;
}
// Set not given dateparts
- if (isset($parsed['hour']) === false) {
+ if (!isset($parsed['hour'])) {
$parsed['hour'] = 12;
}
- if (isset($parsed['minute']) === false) {
+ if (!isset($parsed['minute'])) {
$parsed['minute'] = 0;
}
- if (isset($parsed['second']) === false) {
+ if (!isset($parsed['second'])) {
$parsed['second'] = 0;
}
- if (isset($parsed['month']) === false) {
+ if (!isset($parsed['month'])) {
$parsed['month'] = 1;
}
- if (isset($parsed['day']) === false) {
+ if (!isset($parsed['day'])) {
$parsed['day'] = 1;
}
- if (isset($parsed['year']) === false) {
+ if (!isset($parsed['year'])) {
$parsed['year'] = 1970;
}
- if (self::isYearLeapYear($parsed['year'])) {
- $parsed['year'] = 1972;
- } else {
- $parsed['year'] = 1971;
- }
+ $parsed['year'] = self::isYearLeapYear($parsed['year']) ? 1972 : 1971;
$date = new self($parsed, null, $locale);
$timestamp = $date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'],
diff --git a/library/Zend/Date/DateObject.php b/library/Zend/Date/DateObject.php
index a5842bde68..7db27071bd 100644
--- a/library/Zend/Date/DateObject.php
+++ b/library/Zend/Date/DateObject.php
@@ -82,7 +82,7 @@ protected function setUnixTimestamp($timestamp = null)
if (is_numeric($timestamp)) {
$this->_unixTimestamp = $timestamp;
- } else if ($timestamp === null) {
+ } elseif ($timestamp === null) {
$this->_unixTimestamp = time();
} else {
require_once 'Zend/Date/Exception.php';
@@ -101,7 +101,7 @@ protected function setUnixTimestamp($timestamp = null)
*/
protected function getUnixTimestamp()
{
- if ($this->_unixTimestamp === intval($this->_unixTimestamp)) {
+ if ($this->_unixTimestamp === (int) $this->_unixTimestamp) {
return (int) $this->_unixTimestamp;
} else {
return (string) $this->_unixTimestamp;
@@ -146,12 +146,12 @@ protected function _getTime($sync = null)
protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = false)
{
// complete date but in 32bit timestamp - use PHP internal
- if ((1901 < $year) and ($year < 2038)) {
+ if (1901 < $year && $year < 2038) {
$oldzone = @date_default_timezone_get();
// Timezone also includes DST settings, therefor substracting the GMT offset is not enough
// We have to set the correct timezone to get the right value
- if (($this->_timezone != $oldzone) and ($gmt === false)) {
+ if ($this->_timezone != $oldzone && !$gmt) {
date_default_timezone_set($this->_timezone);
}
$result = ($gmt) ? @gmmktime($hour, $minute, $second, $month, $day, $year)
@@ -161,7 +161,7 @@ protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = f
return $result;
}
- if ($gmt !== true) {
+ if (!$gmt) {
$second += $this->_offset;
}
@@ -173,9 +173,9 @@ protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = f
}
// date to integer
- $day = intval($day);
- $month = intval($month);
- $year = intval($year);
+ $day = (int) $day;
+ $month = (int) $month;
+ $year = (int) $year;
// correct months > 12 and months < 1
if ($month > 12) {
@@ -200,7 +200,7 @@ protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = f
if ($count < $year) {
$date += 365;
- if ($leapyear === true) {
+ if ($leapyear) {
$date++;
}
@@ -208,7 +208,7 @@ protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = f
for ($mcount = 0; $mcount < ($month - 1); $mcount++) {
$date += self::$_monthTable[$mcount];
- if (($leapyear === true) and ($mcount == 1)) {
+ if ($leapyear && $mcount == 1) {
$date++;
}
@@ -229,13 +229,13 @@ protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = f
if ($count > $year)
{
$date += 365;
- if ($leapyear === true)
+ if ($leapyear)
$date++;
} else {
for ($mcount = 11; $mcount > ($month - 1); $mcount--) {
$date += self::$_monthTable[$mcount];
- if (($leapyear === true) and ($mcount == 2)) {
+ if ($leapyear && $mcount == 2) {
$date++;
}
@@ -249,7 +249,7 @@ protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = f
// gregorian correction for 5.Oct.1582
if ($date < -12220185600) {
$date += 864000;
- } else if ($date < -12219321600) {
+ } elseif ($date < -12219321600) {
$date = -12219321600;
}
}
@@ -274,14 +274,14 @@ protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = f
protected static function isYearLeapYear($year)
{
// all leapyears can be divided through 4
- if (($year % 4) != 0) {
+ if ($year % 4 != 0) {
return false;
}
// all leapyears can be divided through 400
if ($year % 400 == 0) {
return true;
- } else if (($year > 1582) and ($year % 100 == 0)) {
+ } elseif ($year > 1582 && $year % 100 == 0) {
return false;
}
@@ -335,7 +335,7 @@ protected function date($format, $timestamp = null, $gmt = false)
}
// check on false or null alone fails
- if (empty($gmt) and empty($jump)) {
+ if (empty($gmt) && empty($jump)) {
$tempstamp = $timestamp;
if ($tempstamp > 0) {
while (abs($tempstamp) > 0x7FFFFFFF) {
@@ -360,7 +360,7 @@ protected function date($format, $timestamp = null, $gmt = false)
}
}
- if (($timestamp < 0) and ($gmt !== true)) {
+ if ($timestamp < 0 && !$gmt) {
$timestamp -= $this->_offset;
}
@@ -399,9 +399,9 @@ protected function date($format, $timestamp = null, $gmt = false)
case 'S': // english suffix for day of month, st nd rd th
if (($date['mday'] % 10) == 1) {
$output .= 'st';
- } else if ((($date['mday'] % 10) == 2) and ($date['mday'] != 12)) {
+ } elseif (($date['mday'] % 10) == 2 && $date['mday'] != 12) {
$output .= 'nd';
- } else if (($date['mday'] % 10) == 3) {
+ } elseif (($date['mday'] % 10) == 3) {
$output .= 'rd';
} else {
$output .= 'th';
@@ -452,7 +452,7 @@ protected function date($format, $timestamp = null, $gmt = false)
case 'o': // ISO 8601 year number
$week = $this->weekNumber($date['year'], $date['mon'], $date['mday']);
- if (($week > 50) and ($date['mon'] == 1)) {
+ if ($week > 50 && $date['mon'] == 1) {
$output .= ($date['year'] - 1);
} else {
$output .= $date['year'];
@@ -479,7 +479,7 @@ protected function date($format, $timestamp = null, $gmt = false)
case 'B': // swatch internet time
$dayseconds = ($date['hours'] * 3600) + ($date['minutes'] * 60) + $date['seconds'];
- if ($gmt === true) {
+ if ($gmt) {
$dayseconds += 3600;
}
$output .= (int) (($dayseconds % 86400) / 86.4);
@@ -489,11 +489,7 @@ protected function date($format, $timestamp = null, $gmt = false)
if ($date['hours'] > 12) {
$hour = $date['hours'] - 12;
} else {
- if ($date['hours'] == 0) {
- $hour = '12';
- } else {
- $hour = $date['hours'];
- }
+ $hour = $date['hours'] == 0 ? '12' : $date['hours'];
}
$output .= $hour;
break;
@@ -506,11 +502,7 @@ protected function date($format, $timestamp = null, $gmt = false)
if ($date['hours'] > 12) {
$hour = $date['hours'] - 12;
} else {
- if ($date['hours'] == 0) {
- $hour = '12';
- } else {
- $hour = $date['hours'];
- }
+ $hour = $date['hours'] == 0 ? '12' : $date['hours'];
}
$output .= (($hour < 10) ? '0'.$hour : $hour);
break;
@@ -530,7 +522,7 @@ protected function date($format, $timestamp = null, $gmt = false)
// timezone formats
case 'e': // timezone identifier
- if ($gmt === true) {
+ if ($gmt) {
$output .= gmdate('e', mktime($date['hours'], $date['minutes'], $date['seconds'],
$date['mon'], $date['mday'], 2000));
} else {
@@ -540,7 +532,7 @@ protected function date($format, $timestamp = null, $gmt = false)
break;
case 'I': // daylight saving time or not
- if ($gmt === true) {
+ if ($gmt) {
$output .= gmdate('I', mktime($date['hours'], $date['minutes'], $date['seconds'],
$date['mon'], $date['mday'], 2000));
} else {
@@ -550,18 +542,18 @@ protected function date($format, $timestamp = null, $gmt = false)
break;
case 'O': // difference to GMT in hours
- $gmtstr = ($gmt === true) ? 0 : $this->getGmtOffset();
+ $gmtstr = ($gmt) ? 0 : $this->getGmtOffset();
$output .= sprintf('%s%04d', ($gmtstr <= 0) ? '+' : '-', abs($gmtstr) / 36);
break;
case 'P': // difference to GMT with colon
- $gmtstr = ($gmt === true) ? 0 : $this->getGmtOffset();
+ $gmtstr = ($gmt) ? 0 : $this->getGmtOffset();
$gmtstr = sprintf('%s%04d', ($gmtstr <= 0) ? '+' : '-', abs($gmtstr) / 36);
$output = $output . substr($gmtstr, 0, 3) . ':' . substr($gmtstr, 3);
break;
case 'T': // timezone settings
- if ($gmt === true) {
+ if ($gmt) {
$output .= gmdate('T', mktime($date['hours'], $date['minutes'], $date['seconds'],
$date['mon'], $date['mday'], 2000));
} else {
@@ -571,7 +563,7 @@ protected function date($format, $timestamp = null, $gmt = false)
break;
case 'Z': // timezone offset in seconds
- $output .= ($gmt === true) ? 0 : -$this->getGmtOffset();
+ $output .= ($gmt) ? 0 : -$this->getGmtOffset();
break;
@@ -635,13 +627,13 @@ protected function date($format, $timestamp = null, $gmt = false)
*/
protected static function dayOfWeek($year, $month, $day)
{
- if ((1901 < $year) and ($year < 2038)) {
+ if (1901 < $year && $year < 2038) {
return (int) date('w', mktime(0, 0, 0, $month, $day, $year));
}
// gregorian correction
$correction = 0;
- if (($year < 1582) or (($year == 1582) and (($month < 10) or (($month == 10) && ($day < 15))))) {
+ if ($year < 1582 || $year == 1582 && ($month < 10 || ($month == 10) && ($day < 15))) {
$correction = 3;
}
@@ -726,7 +718,7 @@ protected function getDateParts($timestamp = null, $fast = null)
$timestamp += 31536000;
$leapyear = self::isYearLeapYear($i);
- if ($leapyear === true) {
+ if ($leapyear) {
$timestamp += 86400;
}
@@ -744,14 +736,14 @@ protected function getDateParts($timestamp = null, $fast = null)
$day = $timestamp;
$timestamp += self::$_monthTable[$i] * 86400;
- if (($leapyear === true) and ($i == 1)) {
+ if ($leapyear && $i == 1) {
$timestamp += 86400;
}
if ($timestamp >= 0) {
$month = $i;
$numday = self::$_monthTable[$i];
- if (($leapyear === true) and ($i == 1)) {
+ if ($leapyear && $i == 1) {
++$numday;
}
break;
@@ -771,7 +763,7 @@ protected function getDateParts($timestamp = null, $fast = null)
$timestamp -= 31536000;
$leapyear = self::isYearLeapYear($i);
- if ($leapyear === true) {
+ if ($leapyear) {
$timestamp -= 86400;
}
@@ -789,14 +781,14 @@ protected function getDateParts($timestamp = null, $fast = null)
$day = $timestamp;
$timestamp -= self::$_monthTable[$i] * 86400;
- if (($leapyear === true) and ($i == 1)) {
+ if ($leapyear && $i == 1) {
$timestamp -= 86400;
}
if ($timestamp < 0) {
$month = $i;
$numday = self::$_monthTable[$i];
- if (($leapyear === true) and ($i == 1)) {
+ if ($leapyear && $i == 1) {
++$numday;
}
break;
@@ -805,7 +797,7 @@ protected function getDateParts($timestamp = null, $fast = null)
$timestamp = $day;
$numberdays = ceil(($timestamp + 1) / 86400);
- $timestamp = $timestamp - ($numberdays - 1) * 86400;
+ $timestamp -= ($numberdays - 1) * 86400;
$hours = floor($timestamp / 3600);
}
@@ -866,23 +858,21 @@ protected function getDateParts($timestamp = null, $fast = null)
*/
protected function weekNumber($year, $month, $day)
{
- if ((1901 < $year) and ($year < 2038)) {
+ if (1901 < $year && $year < 2038) {
return (int) date('W', mktime(0, 0, 0, $month, $day, $year));
}
$dayofweek = self::dayOfWeek($year, $month, $day);
$firstday = self::dayOfWeek($year, 1, 1);
- if (($month == 1) and (($firstday < 1) or ($firstday > 4)) and ($day < 4)) {
+ if ($month == 1 && ($firstday < 1 || $firstday > 4) && $day < 4) {
$firstday = self::dayOfWeek($year - 1, 1, 1);
$month = 12;
$day = 31;
-
- } else if (($month == 12) and ((self::dayOfWeek($year + 1, 1, 1) < 5) and
- (self::dayOfWeek($year + 1, 1, 1) > 0))) {
+ } elseif ($month == 12 && (self::dayOfWeek($year + 1, 1, 1) < 5 && self::dayOfWeek($year + 1, 1, 1) > 0)) {
return 1;
}
- return intval (((self::dayOfWeek($year, 1, 1) < 5) and (self::dayOfWeek($year, 1, 1) > 0)) +
+ return (int) ((self::dayOfWeek($year, 1, 1) < 5 && self::dayOfWeek($year, 1, 1) > 0) +
4 * ($month - 1) + (2 * ($month - 1) + ($day - 1) + $firstday - $dayofweek + 6) * 36 / 256);
}
@@ -945,7 +935,7 @@ protected function calcSun($location, $horizon, $rise = false)
// get quadrant
$solLongitude = $this->_range($solLongitude, $fullCircle);
- if (($solLongitude / $quarterCircle) - intval($solLongitude / $quarterCircle) == 0) {
+ if (($solLongitude / $quarterCircle) - (int) ($solLongitude / $quarterCircle) == 0) {
$solLongitude += 4.84814E-6;
}
@@ -956,7 +946,7 @@ protected function calcSun($location, $horizon, $rise = false)
// adjust quadrant
if ($solLongitude > $threeQuarterCircle) {
$solAscension += $fullCircle;
- } else if ($solLongitude > $quarterCircle) {
+ } elseif ($solLongitude > $quarterCircle) {
$solAscension += $halfCircle;
}
@@ -991,15 +981,15 @@ protected function calcSun($location, $horizon, $rise = false)
$universalTime *= 24 / $fullCircle;
// convert to time
- $hour = intval($universalTime);
+ $hour = (int) $universalTime;
$universalTime = ($universalTime - $hour) * 60;
- $min = intval($universalTime);
+ $min = (int) $universalTime;
$universalTime = ($universalTime - $min) * 60;
- $sec = intval($universalTime);
+ $sec = (int) $universalTime;
return $this->mktime($hour, $min, $sec, $this->date('m', $this->_unixTimestamp),
$this->date('j', $this->_unixTimestamp), $this->date('Y', $this->_unixTimestamp),
- -1, true);
+ -1);
}
/**
@@ -1019,25 +1009,19 @@ public function setTimezone($zone = null)
}
// throw an error on false input, but only if the new date extension is available
- if (function_exists('timezone_open')) {
- if (!@timezone_open($zone)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("timezone ($zone) is not a known timezone", 0, null, $zone);
- }
+ if (function_exists('timezone_open') && !@timezone_open($zone)) {
+ require_once 'Zend/Date/Exception.php';
+ throw new Zend_Date_Exception("timezone ($zone) is not a known timezone", 0, null, $zone);
}
// this can generate an error if the date extension is not available and a false timezone is given
$result = @date_default_timezone_set($zone);
- if ($result === true) {
+ if ($result) {
$this->_offset = mktime(0, 0, 0, 1, 2, 1970) - gmmktime(0, 0, 0, 1, 2, 1970);
$this->_timezone = $zone;
}
date_default_timezone_set($oldzone);
- if (($zone == 'UTC') or ($zone == 'GMT')) {
- $this->_dst = false;
- } else {
- $this->_dst = true;
- }
+ $this->_dst = ($zone == 'UTC' || $zone == 'GMT') ? false : true;
return $this;
}
@@ -1065,7 +1049,7 @@ public function getGmtOffset()
$date = $this->getDateParts($this->getUnixTimestamp(), true);
$zone = @date_default_timezone_get();
$result = @date_default_timezone_set($this->_timezone);
- if ($result === true) {
+ if ($result) {
$offset = $this->mktime($date['hours'], $date['minutes'], $date['seconds'],
$date['mon'], $date['mday'], $date['year'], false)
- $this->mktime($date['hours'], $date['minutes'], $date['seconds'],
diff --git a/library/Zend/Db.php b/library/Zend/Db.php
index 40f26dbae1..3ac335f62f 100644
--- a/library/Zend/Db.php
+++ b/library/Zend/Db.php
@@ -207,14 +207,10 @@ public static function factory($adapter, $config = array())
* adapter name and separate config object.
*/
if ($adapter instanceof Zend_Config) {
- if (isset($adapter->params)) {
+ if (property_exists($adapter, 'params') && $adapter->params !== null) {
$config = $adapter->params->toArray();
}
- if (isset($adapter->adapter)) {
- $adapter = (string) $adapter->adapter;
- } else {
- $adapter = null;
- }
+ $adapter = property_exists($adapter, 'adapter') && $adapter->adapter !== null ? (string) $adapter->adapter : null;
}
/*
diff --git a/library/Zend/Db/Adapter/Abstract.php b/library/Zend/Db/Adapter/Abstract.php
index 9f857c6a54..ecaa8b0ef2 100644
--- a/library/Zend/Db/Adapter/Abstract.php
+++ b/library/Zend/Db/Adapter/Abstract.php
@@ -199,12 +199,10 @@ public function __construct($config)
$options[$key] = $value;
}
}
- if (array_key_exists('driver_options', $config)) {
- if (!empty($config['driver_options'])) {
- // can't use array_merge() because keys might be integers
- foreach ((array) $config['driver_options'] as $key => $value) {
- $driverOptions[$key] = $value;
- }
+ if (array_key_exists('driver_options', $config) && !empty($config['driver_options'])) {
+ // can't use array_merge() because keys might be integers
+ foreach ((array) $config['driver_options'] as $key => $value) {
+ $driverOptions[$key] = $value;
}
}
@@ -364,7 +362,7 @@ public function setProfiler($profiler)
if ($profilerIsObject = is_object($profiler)) {
if ($profiler instanceof Zend_Db_Profiler) {
$profilerInstance = $profiler;
- } else if ($profiler instanceof Zend_Config) {
+ } elseif ($profiler instanceof Zend_Config) {
$profiler = $profiler->toArray();
} else {
/**
@@ -386,7 +384,7 @@ public function setProfiler($profiler)
if (isset($profiler['instance'])) {
$profilerInstance = $profiler['instance'];
}
- } else if (!$profilerIsObject) {
+ } elseif (!$profilerIsObject) {
$enabled = (bool) $profiler;
}
@@ -545,21 +543,17 @@ public function insert($table, array $bind)
if ($val instanceof Zend_Db_Expr) {
$vals[] = $val->__toString();
unset($bind[$col]);
+ } elseif ($this->supportsParameters('positional')) {
+ $vals[] = '?';
+ } elseif ($this->supportsParameters('named')) {
+ unset($bind[$col]);
+ $bind[':col'.$i] = $val;
+ $vals[] = ':col'.$i;
+ $i++;
} else {
- if ($this->supportsParameters('positional')) {
- $vals[] = '?';
- } else {
- if ($this->supportsParameters('named')) {
- unset($bind[$col]);
- $bind[':col'.$i] = $val;
- $vals[] = ':col'.$i;
- $i++;
- } else {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception(get_class($this) ." doesn't support positional or named binding");
- }
- }
+ /** @see Zend_Db_Adapter_Exception */
+ require_once 'Zend/Db/Adapter/Exception.php';
+ throw new Zend_Db_Adapter_Exception(get_class($this) ." doesn't support positional or named binding");
}
}
@@ -574,8 +568,7 @@ public function insert($table, array $bind)
$bind = array_values($bind);
}
$stmt = $this->query($sql, $bind);
- $result = $stmt->rowCount();
- return $result;
+ return $stmt->rowCount();
}
/**
@@ -599,21 +592,17 @@ public function update($table, array $bind, $where = '')
if ($val instanceof Zend_Db_Expr) {
$val = $val->__toString();
unset($bind[$col]);
+ } elseif ($this->supportsParameters('positional')) {
+ $val = '?';
+ } elseif ($this->supportsParameters('named')) {
+ unset($bind[$col]);
+ $bind[':col'.$i] = $val;
+ $val = ':col'.$i;
+ $i++;
} else {
- if ($this->supportsParameters('positional')) {
- $val = '?';
- } else {
- if ($this->supportsParameters('named')) {
- unset($bind[$col]);
- $bind[':col'.$i] = $val;
- $val = ':col'.$i;
- $i++;
- } else {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception(get_class($this) ." doesn't support positional or named binding");
- }
- }
+ /** @see Zend_Db_Adapter_Exception */
+ require_once 'Zend/Db/Adapter/Exception.php';
+ throw new Zend_Db_Adapter_Exception(get_class($this) ." doesn't support positional or named binding");
}
$set[] = $this->quoteIdentifier($col, true) . ' = ' . $val;
}
@@ -626,18 +615,12 @@ public function update($table, array $bind, $where = '')
$sql = "UPDATE "
. $this->quoteIdentifier($table, true)
. ' SET ' . implode(', ', $set)
- . (($where) ? " WHERE $where" : '');
-
+ . (($where !== '' && $where !== '0') ? " WHERE $where" : '');
/**
* Execute the statement and return the number of affected rows
*/
- if ($this->supportsParameters('positional')) {
- $stmt = $this->query($sql, array_values($bind));
- } else {
- $stmt = $this->query($sql, $bind);
- }
- $result = $stmt->rowCount();
- return $result;
+ $stmt = $this->supportsParameters('positional') ? $this->query($sql, array_values($bind)) : $this->query($sql, $bind);
+ return $stmt->rowCount();
}
/**
@@ -656,14 +639,13 @@ public function delete($table, $where = '')
*/
$sql = "DELETE FROM "
. $this->quoteIdentifier($table, true)
- . (($where) ? " WHERE $where" : '');
+ . (($where !== '' && $where !== '0') ? " WHERE $where" : '');
/**
* Execute the statement and return the number of affected rows
*/
$stmt = $this->query($sql);
- $result = $stmt->rowCount();
- return $result;
+ return $stmt->rowCount();
}
/**
@@ -695,9 +677,7 @@ protected function _whereExpr($where)
}
$term = '(' . $term . ')';
}
-
- $where = implode(' AND ', $where);
- return $where;
+ return implode(' AND ', $where);
}
/**
@@ -735,8 +715,7 @@ public function fetchAll($sql, $bind = array(), $fetchMode = null)
$fetchMode = $this->_fetchMode;
}
$stmt = $this->query($sql, $bind);
- $result = $stmt->fetchAll($fetchMode);
- return $result;
+ return $stmt->fetchAll($fetchMode);
}
/**
@@ -754,8 +733,7 @@ public function fetchRow($sql, $bind = array(), $fetchMode = null)
$fetchMode = $this->_fetchMode;
}
$stmt = $this->query($sql, $bind);
- $result = $stmt->fetch($fetchMode);
- return $result;
+ return $stmt->fetch($fetchMode);
}
/**
@@ -792,8 +770,7 @@ public function fetchAssoc($sql, $bind = array())
public function fetchCol($sql, $bind = array())
{
$stmt = $this->query($sql, $bind);
- $result = $stmt->fetchAll(Zend_Db::FETCH_COLUMN, 0);
- return $result;
+ return $stmt->fetchAll(Zend_Db::FETCH_COLUMN, 0);
}
/**
@@ -826,8 +803,7 @@ public function fetchPairs($sql, $bind = array())
public function fetchOne($sql, $bind = array())
{
$stmt = $this->query($sql, $bind);
- $result = $stmt->fetchColumn(0);
- return $result;
+ return $stmt->fetchColumn(0);
}
/**
@@ -879,7 +855,7 @@ public function quote($value, $type = null)
$quotedValue = '0';
switch ($this->_numericDataTypes[$type]) {
case Zend_Db::INT_TYPE: // 32-bit integer
- $quotedValue = (string) intval($value);
+ $quotedValue = (string) (int) $value;
break;
case Zend_Db::BIGINT_TYPE: // 64-bit integer
// ANSI SQL-style hex literals (e.g. x'[\dA-F]+')
@@ -1009,11 +985,7 @@ protected function _quoteIdentifierAs($ident, $alias = null, $auto = false, $as
if (is_array($ident)) {
$segments = array();
foreach ($ident as $segment) {
- if ($segment instanceof Zend_Db_Expr) {
- $segments[] = $segment->__toString();
- } else {
- $segments[] = $this->_quoteIdentifier($segment, $auto);
- }
+ $segments[] = $segment instanceof Zend_Db_Expr ? $segment->__toString() : $this->_quoteIdentifier($segment, $auto);
}
if ($alias !== null && end($ident) == $alias) {
$alias = null;
@@ -1038,7 +1010,7 @@ protected function _quoteIdentifierAs($ident, $alias = null, $auto = false, $as
*/
protected function _quoteIdentifier($value, $auto=false)
{
- if ($auto === false || $this->_autoQuoteIdentifiers === true) {
+ if (!$auto || $this->_autoQuoteIdentifiers) {
$q = $this->getQuoteIdentifierSymbol();
return ($q . str_replace("$q", "$q$q", $value) . $q);
}
diff --git a/library/Zend/Db/Adapter/Db2.php b/library/Zend/Db/Adapter/Db2.php
index dac2b1b7b9..fdeaa62d05 100644
--- a/library/Zend/Db/Adapter/Db2.php
+++ b/library/Zend/Db/Adapter/Db2.php
@@ -132,13 +132,7 @@ protected function _connect()
}
$this->_determineI5();
- if ($this->_config['persistent']) {
- // use persistent connection
- $conn_func_name = 'db2_pconnect';
- } else {
- // use "normal" connection
- $conn_func_name = 'db2_connect';
- }
+ $conn_func_name = $this->_config['persistent'] ? 'db2_pconnect' : 'db2_connect';
if (!isset($this->_config['driver_options']['autocommit'])) {
// set execution mode
@@ -303,11 +297,8 @@ public function getQuoteIdentifierSymbol()
$info = db2_server_info($this->_connection);
if ($info) {
$identQuote = $info->IDENTIFIER_QUOTE_CHAR;
- } else {
- // db2_server_info() does not return result on some i5 OS version
- if ($this->_isI5) {
- $identQuote ="'";
- }
+ } elseif ($this->_isI5) {
+ $identQuote ="'";
}
return $identQuote;
}
@@ -328,11 +319,7 @@ public function listTables($schema = null)
$tables = array();
if (!$this->_isI5) {
- if ($schema) {
- $stmt = db2_tables($this->_connection, null, $schema);
- } else {
- $stmt = db2_tables($this->_connection);
- }
+ $stmt = $schema ? db2_tables($this->_connection, null, $schema) : db2_tables($this->_connection);
while ($row = db2_fetch_assoc($stmt)) {
$tables[] = $row['TABLE_NAME'];
}
@@ -454,7 +441,9 @@ public function describeTable($tableName, $schemaName = null)
$colseq = 11;
foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
+ $primary = false;
+ $primaryPosition = null;
+ $identity = false;
if ($row[$tabconstType] == 'P') {
$primary = true;
$primaryPosition = $row[$colseq];
@@ -472,7 +461,7 @@ public function describeTable($tableName, $schemaName = null)
'SCHEMA_NAME' => $this->foldCase($row[$tabschema]),
'TABLE_NAME' => $this->foldCase($row[$tabname]),
'COLUMN_NAME' => $this->foldCase($row[$colname]),
- 'COLUMN_POSITION' => (!$this->_isI5) ? $row[$colno]+1 : $row[$colno],
+ 'COLUMN_POSITION' => ($this->_isI5) ? $row[$colno] : $row[$colno]+1,
'DATA_TYPE' => $row[$typename],
'DEFAULT' => $row[$default],
'NULLABLE' => (bool) ($row[$nulls] == 'Y'),
@@ -662,7 +651,7 @@ public function setFetchMode($mode)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count <= 0) {
/**
* @see Zend_Db_Adapter_Db2_Exception
@@ -671,7 +660,7 @@ public function limit($sql, $count, $offset = 0)
throw new Zend_Db_Adapter_Db2_Exception("LIMIT argument count=$count is not valid");
}
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/**
* @see Zend_Db_Adapter_Db2_Exception
@@ -681,8 +670,7 @@ public function limit($sql, $count, $offset = 0)
}
if ($offset == 0) {
- $limit_sql = $sql . " FETCH FIRST $count ROWS ONLY";
- return $limit_sql;
+ return $sql . " FETCH FIRST $count ROWS ONLY";
}
/**
@@ -710,12 +698,8 @@ public function limit($sql, $count, $offset = 0)
*/
public function supportsParameters($type)
{
- if ($type == 'positional') {
- return true;
- }
-
// if its 'named' or anything else
- return false;
+ return $type == 'positional';
}
/**
@@ -761,16 +745,11 @@ public function isI5()
protected function _determineI5()
{
// first us the compiled flag.
- $this->_isI5 = (php_uname('s') == 'OS400') ? true : false;
+ $this->_isI5 = php_uname('s') == 'OS400';
// if this is set, then us it
if (isset($this->_config['os'])){
- if (strtolower($this->_config['os']) === 'i5') {
- $this->_isI5 = true;
- } else {
- // any other value passed in, its null
- $this->_isI5 = false;
- }
+ $this->_isI5 = strtolower($this->_config['os']) === 'i5';
}
}
@@ -819,8 +798,7 @@ protected function _i5LastInsertId($objectName = null, $idType = null)
if ($objectName === null) {
$sql = 'SELECT IDENTITY_VAL_LOCAL() AS VAL FROM QSYS2.QSQPTABL';
- $value = $this->fetchOne($sql);
- return $value;
+ return $this->fetchOne($sql);
}
if (strtoupper($idType) === 'S'){
diff --git a/library/Zend/Db/Adapter/Mysqli.php b/library/Zend/Db/Adapter/Mysqli.php
index a82d478362..acf67a5d82 100644
--- a/library/Zend/Db/Adapter/Mysqli.php
+++ b/library/Zend/Db/Adapter/Mysqli.php
@@ -225,15 +225,15 @@ public function describeTable($tableName, $schemaName = null)
if (preg_match('/^((?:var)?char)\((\d+)\)/', (string) $row['Type'], $matches)) {
$row['Type'] = $matches[1];
$row['Length'] = $matches[2];
- } else if (preg_match('/^decimal\((\d+),(\d+)\)/', (string) $row['Type'], $matches)) {
+ } elseif (preg_match('/^decimal\((\d+),(\d+)\)/', (string) $row['Type'], $matches)) {
$row['Type'] = 'decimal';
$row['Precision'] = $matches[1];
$row['Scale'] = $matches[2];
- } else if (preg_match('/^float\((\d+),(\d+)\)/', (string) $row['Type'], $matches)) {
+ } elseif (preg_match('/^float\((\d+),(\d+)\)/', (string) $row['Type'], $matches)) {
$row['Type'] = 'float';
$row['Precision'] = $matches[1];
$row['Scale'] = $matches[2];
- } else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', (string) $row['Type'], $matches)) {
+ } elseif (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', (string) $row['Type'], $matches)) {
$row['Type'] = $matches[1];
/**
* The optional argument of a MySQL int type is not precision
@@ -243,11 +243,7 @@ public function describeTable($tableName, $schemaName = null)
if (strtoupper($row['Key']) == 'PRI') {
$row['Primary'] = true;
$row['PrimaryPosition'] = $p;
- if ($row['Extra'] == 'auto_increment') {
- $row['Identity'] = true;
- } else {
- $row['Identity'] = false;
- }
+ $row['Identity'] = $row['Extra'] == 'auto_increment';
++$p;
}
$desc[$this->foldCase($row['Field'])] = array(
@@ -291,17 +287,9 @@ protected function _connect()
throw new Zend_Db_Adapter_Mysqli_Exception('The Mysqli extension is required for this adapter but the extension is not loaded');
}
- if (isset($this->_config['port'])) {
- $port = (integer) $this->_config['port'];
- } else {
- $port = null;
- }
+ $port = isset($this->_config['port']) ? (integer) $this->_config['port'] : null;
- if (isset($this->_config['socket'])) {
- $socket = $this->_config['socket'];
- } else {
- $socket = null;
- }
+ $socket = isset($this->_config['socket']) ? $this->_config['socket'] : null;
$this->_connection = mysqli_init();
@@ -330,7 +318,7 @@ protected function _connect()
$socket
);
- if ($_isConnected === false || mysqli_connect_errno()) {
+ if (!$_isConnected || mysqli_connect_errno()) {
$this->closeConnection();
/**
@@ -496,7 +484,7 @@ public function setFetchMode($mode)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count <= 0) {
/**
* @see Zend_Db_Adapter_Mysqli_Exception
@@ -505,7 +493,7 @@ public function limit($sql, $count, $offset = 0)
throw new Zend_Db_Adapter_Mysqli_Exception("LIMIT argument count=$count is not valid");
}
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/**
* @see Zend_Db_Adapter_Mysqli_Exception
diff --git a/library/Zend/Db/Adapter/Oracle.php b/library/Zend/Db/Adapter/Oracle.php
index a03968a3ff..38eb14f12b 100644
--- a/library/Zend/Db/Adapter/Oracle.php
+++ b/library/Zend/Db/Adapter/Oracle.php
@@ -258,8 +258,7 @@ public function lastSequenceId($sequenceName)
{
$this->_connect();
$sql = 'SELECT '.$this->quoteIdentifier($sequenceName, true).'.CURRVAL FROM dual';
- $value = $this->fetchOne($sql);
- return $value;
+ return $this->fetchOne($sql);
}
/**
@@ -274,8 +273,7 @@ public function nextSequenceId($sequenceName)
{
$this->_connect();
$sql = 'SELECT '.$this->quoteIdentifier($sequenceName, true).'.NEXTVAL FROM dual';
- $value = $this->fetchOne($sql);
- return $value;
+ return $this->fetchOne($sql);
}
/**
@@ -318,8 +316,7 @@ public function lastInsertId($tableName = null, $primaryKey = null)
public function listTables()
{
$this->_connect();
- $data = $this->fetchCol('SELECT table_name FROM all_tables');
- return $data;
+ return $this->fetchCol('SELECT table_name FROM all_tables');
}
/**
@@ -417,7 +414,9 @@ public function describeTable($tableName, $schemaName = null)
$desc = array();
foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
+ $primary = false;
+ $primaryPosition = null;
+ $identity = false;
if ($row[$constraint_type] == 'P') {
$primary = true;
$primaryPosition = $row[$position];
@@ -538,7 +537,7 @@ public function setFetchMode($mode)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count <= 0) {
/**
* @see Zend_Db_Adapter_Oracle_Exception
@@ -547,7 +546,7 @@ public function limit($sql, $count, $offset = 0)
throw new Zend_Db_Adapter_Oracle_Exception("LIMIT argument count=$count is not valid");
}
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/**
* @see Zend_Db_Adapter_Oracle_Exception
@@ -631,7 +630,7 @@ public function getServerVersion()
$version = oci_server_version($this->_connection);
if ($version !== false) {
$matches = null;
- if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
+ if (preg_match('/((?:\d{1,2}\.){1,3}\d{1,2})/', $version, $matches)) {
return $matches[1];
} else {
return null;
diff --git a/library/Zend/Db/Adapter/Oracle/Exception.php b/library/Zend/Db/Adapter/Oracle/Exception.php
index bf19dd8096..b9d7f9b8e0 100644
--- a/library/Zend/Db/Adapter/Oracle/Exception.php
+++ b/library/Zend/Db/Adapter/Oracle/Exception.php
@@ -41,16 +41,16 @@ class Zend_Db_Adapter_Oracle_Exception extends Zend_Db_Adapter_Exception
function __construct($error = null, $code = 0) {
if (is_array($error)) {
- if (!isset($error['offset'])) {
- $this->message = $error['code'] .' '. $error['message'];
- } else {
- $this->message = $error['code'] .' '. $error['message']." "
- . substr($error['sqltext'], 0, $error['offset'])
- . "*"
- . substr($error['sqltext'], $error['offset']);
- }
- $this->code = $error['code'];
- } else if (is_string($error)) {
+ if (!isset($error['offset'])) {
+ $this->message = $error['code'] .' '. $error['message'];
+ } else {
+ $this->message = $error['code'] .' '. $error['message']." "
+ . substr($error['sqltext'], 0, $error['offset'])
+ . "*"
+ . substr($error['sqltext'], $error['offset']);
+ }
+ $this->code = $error['code'];
+ } elseif (is_string($error)) {
$this->message = $error;
}
if (!$this->code && $code) {
diff --git a/library/Zend/Db/Adapter/Pdo/Abstract.php b/library/Zend/Db/Adapter/Pdo/Abstract.php
index 4db0a5df17..3db3d548f8 100644
--- a/library/Zend/Db/Adapter/Pdo/Abstract.php
+++ b/library/Zend/Db/Adapter/Pdo/Abstract.php
@@ -45,6 +45,7 @@
abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
{
+ protected $_pdoType;
/**
* Default class name for a DB statement.
*
@@ -391,7 +392,7 @@ public function getServerVersion()
return null;
}
$matches = null;
- if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', (string) $version, $matches)) {
+ if (preg_match('/((?:\d{1,2}\.){1,3}\d{1,2})/', (string) $version, $matches)) {
return $matches[1];
} else {
return null;
diff --git a/library/Zend/Db/Adapter/Pdo/Ibm.php b/library/Zend/Db/Adapter/Pdo/Ibm.php
index 2f9c5c8e17..e82dfa6f70 100644
--- a/library/Zend/Db/Adapter/Pdo/Ibm.php
+++ b/library/Zend/Db/Adapter/Pdo/Ibm.php
@@ -259,11 +259,7 @@ public function insert($table, array $bind)
$this->_connect();
$newbind = array();
if (is_array($bind)) {
- foreach ($bind as $name => $value) {
- if($value !== null) {
- $newbind[$name] = $value;
- }
- }
+ $newbind = array_filter($bind, fn($value) => $value !== null);
}
return parent::insert($table, $newbind);
@@ -304,9 +300,7 @@ public function lastInsertId($tableName = null, $primaryKey = null)
return $this->lastSequenceId($sequenceName);
}
- $id = $this->getConnection()->lastInsertId();
-
- return $id;
+ return $this->getConnection()->lastInsertId();
}
/**
@@ -344,9 +338,9 @@ public function getServerVersion()
try {
$stmt = $this->query('SELECT service_level, fixpack_num FROM TABLE (sysproc.env_get_inst_info()) as INSTANCEINFO');
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- if (count($result)) {
+ if ($result !== []) {
$matches = null;
- if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', (string) $result[0][0], $matches)) {
+ if (preg_match('/((?:\d{1,2}\.){1,3}\d{1,2})/', (string) $result[0][0], $matches)) {
return $matches[1];
} else {
return null;
diff --git a/library/Zend/Db/Adapter/Pdo/Ibm/Db2.php b/library/Zend/Db/Adapter/Pdo/Ibm/Db2.php
index a58746d69c..6375a1fcab 100644
--- a/library/Zend/Db/Adapter/Pdo/Ibm/Db2.php
+++ b/library/Zend/Db/Adapter/Pdo/Ibm/Db2.php
@@ -62,8 +62,7 @@ public function __construct($adapter)
*/
public function listTables()
{
- $sql = "SELECT tabname "
- . "FROM SYSCAT.TABLES ";
+ $sql = 'SELECT tabname FROM SYSCAT.TABLES ';
return $this->_adapter->fetchCol($sql);
}
@@ -120,7 +119,9 @@ public function describeTable($tableName, $schemaName = null)
$colseq = 11;
foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
+ $primary = false;
+ $primaryPosition = null;
+ $identity = false;
if ($row[$tabconstype] == 'P') {
$primary = true;
$primaryPosition = $row[$colseq];
@@ -165,13 +166,13 @@ public function describeTable($tableName, $schemaName = null)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count < 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
} else {
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
@@ -179,8 +180,7 @@ public function limit($sql, $count, $offset = 0)
}
if ($offset == 0 && $count > 0) {
- $limit_sql = $sql . " FETCH FIRST $count ROWS ONLY";
- return $limit_sql;
+ return $sql . " FETCH FIRST $count ROWS ONLY";
}
/**
* DB2 does not implement the LIMIT clause as some RDBMS do.
@@ -209,8 +209,7 @@ public function limit($sql, $count, $offset = 0)
public function lastSequenceId($sequenceName)
{
$sql = 'SELECT PREVVAL FOR '.$this->_adapter->quoteIdentifier($sequenceName).' AS VAL FROM SYSIBM.SYSDUMMY1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
+ return $this->_adapter->fetchOne($sql);
}
/**
@@ -222,7 +221,6 @@ public function lastSequenceId($sequenceName)
public function nextSequenceId($sequenceName)
{
$sql = 'SELECT NEXTVAL FOR '.$this->_adapter->quoteIdentifier($sequenceName).' AS VAL FROM SYSIBM.SYSDUMMY1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
+ return $this->_adapter->fetchOne($sql);
}
}
diff --git a/library/Zend/Db/Adapter/Pdo/Ibm/Ids.php b/library/Zend/Db/Adapter/Pdo/Ibm/Ids.php
index 4d4b689f0a..60fe80518b 100644
--- a/library/Zend/Db/Adapter/Pdo/Ibm/Ids.php
+++ b/library/Zend/Db/Adapter/Pdo/Ibm/Ids.php
@@ -62,8 +62,7 @@ public function __construct($adapter)
*/
public function listTables()
{
- $sql = "SELECT tabname "
- . "FROM systables ";
+ $sql = 'SELECT tabname FROM systables ';
return $this->_adapter->fetchCol($sql);
}
@@ -189,7 +188,7 @@ protected function _getDataType($typeNo)
);
if ($typeNo - 256 >= 0) {
- $typeNo = $typeNo - 256;
+ $typeNo -= 256;
}
return $typemap[$typeNo];
@@ -219,7 +218,7 @@ protected function _getPrimaryInfo($tabid)
// this should return only 1 row
// unless there is no primary key,
// in which case, the empty array is returned
- if ($results) {
+ if ($results !== []) {
$row = $results[0];
} else {
return $cols;
@@ -247,16 +246,16 @@ protected function _getPrimaryInfo($tabid)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count < 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- } else if ($count == 0) {
- $limit_sql = str_ireplace("SELECT", "SELECT * FROM (SELECT", $sql);
- $limit_sql .= ") WHERE 0 = 1";
+ } elseif ($count == 0) {
+ $limit_sql = str_ireplace("SELECT", "SELECT * FROM (SELECT", $sql);
+ $limit_sql .= ") WHERE 0 = 1";
} else {
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
@@ -281,8 +280,7 @@ public function lastSequenceId($sequenceName)
{
$sql = 'SELECT '.$this->_adapter->quoteIdentifier($sequenceName).'.CURRVAL FROM '
.'systables WHERE tabid = 1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
+ return $this->_adapter->fetchOne($sql);
}
/**
@@ -295,7 +293,6 @@ public function nextSequenceId($sequenceName)
{
$sql = 'SELECT '.$this->_adapter->quoteIdentifier($sequenceName).'.NEXTVAL FROM '
.'systables WHERE tabid = 1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
+ return $this->_adapter->fetchOne($sql);
}
}
diff --git a/library/Zend/Db/Adapter/Pdo/Mssql.php b/library/Zend/Db/Adapter/Pdo/Mssql.php
index 7f1dfdd3bf..68430b74b7 100644
--- a/library/Zend/Db/Adapter/Pdo/Mssql.php
+++ b/library/Zend/Db/Adapter/Pdo/Mssql.php
@@ -121,9 +121,7 @@ protected function _dsn()
foreach ($dsn as $key => $val) {
$dsn[$key] = "$key=$val";
}
-
- $dsn = $this->_pdoType . ':' . implode(';', $dsn);
- return $dsn;
+ return $this->_pdoType . ':' . implode(';', $dsn);
}
/**
@@ -220,11 +218,9 @@ public function listTables()
*/
public function describeTable($tableName, $schemaName = null)
{
- if ($schemaName != null) {
- if (strpos($schemaName, '.') !== false) {
- $result = explode('.', $schemaName);
- $schemaName = $result[1];
- }
+ if ($schemaName != null && strpos($schemaName, '.') !== false) {
+ $result = explode('.', $schemaName);
+ $schemaName = $result[1];
}
/**
* Discover metadata information about this table.
@@ -277,11 +273,7 @@ public function describeTable($tableName, $schemaName = null)
}
$isPrimary = array_key_exists($row[$column_name], $primaryKeyColumn);
- if ($isPrimary) {
- $primaryPosition = $primaryKeyColumn[$row[$column_name]];
- } else {
- $primaryPosition = null;
- }
+ $primaryPosition = $isPrimary ? $primaryKeyColumn[$row[$column_name]] : null;
$desc[$this->foldCase($row[$column_name])] = array(
'SCHEMA_NAME' => null, // @todo
@@ -316,14 +308,14 @@ public function describeTable($tableName, $schemaName = null)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count <= 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
}
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
@@ -412,7 +404,7 @@ public function getServerVersion()
try {
$stmt = $this->query("SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR)");
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- if (count($result)) {
+ if ($result !== []) {
return $result[0][0];
}
return null;
diff --git a/library/Zend/Db/Adapter/Pdo/Mysql.php b/library/Zend/Db/Adapter/Pdo/Mysql.php
index 51c5c2eb60..ff498a6b20 100644
--- a/library/Zend/Db/Adapter/Pdo/Mysql.php
+++ b/library/Zend/Db/Adapter/Pdo/Mysql.php
@@ -184,23 +184,28 @@ public function describeTable($tableName, $schemaName = null)
$i = 1;
$p = 1;
foreach ($result as $row) {
- list($length, $scale, $precision, $unsigned, $primary, $primaryPosition, $identity)
- = array(null, null, null, null, false, null, false);
+ $length = null;
+ $scale = null;
+ $precision = null;
+ $unsigned = null;
+ $primary = false;
+ $primaryPosition = null;
+ $identity = false;
if (preg_match('/unsigned/', (string) $row[$type])) {
$unsigned = true;
}
if (preg_match('/^((?:var)?char)\((\d+)\)/', (string) $row[$type], $matches)) {
$row[$type] = $matches[1];
$length = $matches[2];
- } else if (preg_match('/^decimal\((\d+),(\d+)\)/', (string) $row[$type], $matches)) {
+ } elseif (preg_match('/^decimal\((\d+),(\d+)\)/', (string) $row[$type], $matches)) {
$row[$type] = 'decimal';
$precision = $matches[1];
$scale = $matches[2];
- } else if (preg_match('/^float\((\d+),(\d+)\)/', (string) $row[$type], $matches)) {
+ } elseif (preg_match('/^float\((\d+),(\d+)\)/', (string) $row[$type], $matches)) {
$row[$type] = 'float';
$precision = $matches[1];
$scale = $matches[2];
- } else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', (string) $row[$type], $matches)) {
+ } elseif (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', (string) $row[$type], $matches)) {
$row[$type] = $matches[1];
// The optional argument of a MySQL int type is not precision
// or length; it is only a hint for display width.
@@ -208,11 +213,7 @@ public function describeTable($tableName, $schemaName = null)
if (strtoupper($row[$key]) == 'PRI') {
$primary = true;
$primaryPosition = $p;
- if ($row[$extra] == 'auto_increment') {
- $identity = true;
- } else {
- $identity = false;
- }
+ $identity = $row[$extra] == 'auto_increment';
++$p;
}
$desc[$this->foldCase($row[$field])] = array(
@@ -247,14 +248,14 @@ public function describeTable($tableName, $schemaName = null)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count <= 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
}
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
diff --git a/library/Zend/Db/Adapter/Pdo/Oci.php b/library/Zend/Db/Adapter/Pdo/Oci.php
index 893e1dc6cd..619430b956 100644
--- a/library/Zend/Db/Adapter/Pdo/Oci.php
+++ b/library/Zend/Db/Adapter/Pdo/Oci.php
@@ -143,8 +143,7 @@ public function quoteTableAs($ident, $alias = null, $auto = false)
*/
public function listTables()
{
- $data = $this->fetchCol('SELECT table_name FROM all_tables');
- return $data;
+ return $this->fetchCol('SELECT table_name FROM all_tables');
}
/**
@@ -242,7 +241,9 @@ public function describeTable($tableName, $schemaName = null)
$desc = array();
foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
+ $primary = false;
+ $primaryPosition = null;
+ $identity = false;
if ($row[$constraint_type] == 'P') {
$primary = true;
$primaryPosition = $row[$position];
@@ -282,8 +283,7 @@ public function describeTable($tableName, $schemaName = null)
public function lastSequenceId($sequenceName)
{
$this->_connect();
- $value = $this->fetchOne('SELECT '.$this->quoteIdentifier($sequenceName, true).'.CURRVAL FROM dual');
- return $value;
+ return $this->fetchOne('SELECT '.$this->quoteIdentifier($sequenceName, true).'.CURRVAL FROM dual');
}
/**
@@ -297,8 +297,7 @@ public function lastSequenceId($sequenceName)
public function nextSequenceId($sequenceName)
{
$this->_connect();
- $value = $this->fetchOne('SELECT '.$this->quoteIdentifier($sequenceName, true).'.NEXTVAL FROM dual');
- return $value;
+ return $this->fetchOne('SELECT '.$this->quoteIdentifier($sequenceName, true).'.NEXTVAL FROM dual');
}
/**
@@ -344,14 +343,14 @@ public function lastInsertId($tableName = null, $primaryKey = null)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count <= 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
}
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
diff --git a/library/Zend/Db/Adapter/Pdo/Pgsql.php b/library/Zend/Db/Adapter/Pdo/Pgsql.php
index 5a96fd830a..5fad0fa399 100644
--- a/library/Zend/Db/Adapter/Pdo/Pgsql.php
+++ b/library/Zend/Db/Adapter/Pdo/Pgsql.php
@@ -207,7 +207,9 @@ public function describeTable($tableName, $schemaName = null)
$defaultValue = $matches[1];
}
}
- list($primary, $primaryPosition, $identity) = array(false, null, false);
+ $primary = false;
+ $primaryPosition = null;
+ $identity = false;
if ($row[$contype] == 'p') {
$primary = true;
$primaryPosition = array_search($row[$attnum], explode(',', (string) $row[$conkey])) + 1;
@@ -244,7 +246,7 @@ public function describeTable($tableName, $schemaName = null)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count <= 0) {
/**
* @see Zend_Db_Adapter_Exception
@@ -253,7 +255,7 @@ public function limit($sql, $count, $offset = 0)
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
}
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/**
* @see Zend_Db_Adapter_Exception
@@ -282,10 +284,9 @@ public function lastSequenceId($sequenceName)
{
$this->_connect();
$sequenceName = str_replace($this->getQuoteIdentifierSymbol(), '', (string) $sequenceName);
- $value = $this->fetchOne("SELECT CURRVAL("
+ return $this->fetchOne("SELECT CURRVAL("
. $this->quote($this->quoteIdentifier($sequenceName, true))
. ")");
- return $value;
}
/**
@@ -300,10 +301,9 @@ public function nextSequenceId($sequenceName)
{
$this->_connect();
$sequenceName = str_replace($this->getQuoteIdentifierSymbol(), '', (string) $sequenceName);
- $value = $this->fetchOne("SELECT NEXTVAL("
+ return $this->fetchOne("SELECT NEXTVAL("
. $this->quote($this->quoteIdentifier($sequenceName, true))
. ")");
- return $value;
}
/**
diff --git a/library/Zend/Db/Adapter/Pdo/Sqlite.php b/library/Zend/Db/Adapter/Pdo/Sqlite.php
index 5c342b6eb1..ed09cfc020 100644
--- a/library/Zend/Db/Adapter/Pdo/Sqlite.php
+++ b/library/Zend/Db/Adapter/Pdo/Sqlite.php
@@ -223,12 +223,16 @@ public function describeTable($tableName, $schemaName = null)
$p = 1;
foreach ($result as $key => $row) {
- list($length, $scale, $precision, $primary, $primaryPosition, $identity) =
- array(null, null, null, false, null, false);
+ $length = null;
+ $scale = null;
+ $precision = null;
+ $primary = false;
+ $primaryPosition = null;
+ $identity = false;
if (preg_match('/^((?:var)?char)\((\d+)\)/i', (string) $row[$type], $matches)) {
$row[$type] = $matches[1];
$length = $matches[2];
- } else if (preg_match('/^decimal\((\d+),(\d+)\)/i', (string) $row[$type], $matches)) {
+ } elseif (preg_match('/^decimal\((\d+),(\d+)\)/i', (string) $row[$type], $matches)) {
$row[$type] = 'DECIMAL';
$precision = $matches[1];
$scale = $matches[2];
@@ -272,14 +276,14 @@ public function describeTable($tableName, $schemaName = null)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count <= 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
}
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
diff --git a/library/Zend/Db/Adapter/Sqlsrv.php b/library/Zend/Db/Adapter/Sqlsrv.php
index 0b25241707..9286e9d023 100644
--- a/library/Zend/Db/Adapter/Sqlsrv.php
+++ b/library/Zend/Db/Adapter/Sqlsrv.php
@@ -149,11 +149,7 @@ protected function _connect()
// A value may be a constant.
if (is_string($value)) {
$constantName = strtoupper($value);
- if (defined($constantName)) {
- $connectionInfo[$option] = constant($constantName);
- } else {
- $connectionInfo[$option] = $value;
- }
+ $connectionInfo[$option] = defined($constantName) ? constant($constantName) : $value;
}
}
}
@@ -491,11 +487,7 @@ public function describeTable($tableName, $schemaName = null)
}
$isPrimary = array_key_exists($row[$column_name], $primaryKeyColumn);
- if ($isPrimary) {
- $primaryPosition = $primaryKeyColumn[$row[$column_name]];
- } else {
- $primaryPosition = null;
- }
+ $primaryPosition = $isPrimary ? $primaryKeyColumn[$row[$column_name]] : null;
$desc[$this->foldCase($row[$column_name])] = array(
'SCHEMA_NAME' => null, // @todo
@@ -600,13 +592,13 @@ public function setFetchMode($mode)
*/
public function limit($sql, $count, $offset = 0)
{
- $count = intval($count);
+ $count = (int) $count;
if ($count <= 0) {
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
}
- $offset = intval($offset);
+ $offset = (int) $offset;
if ($offset < 0) {
/** @see Zend_Db_Adapter_Exception */
require_once 'Zend/Db/Adapter/Exception.php';
@@ -618,11 +610,7 @@ public function limit($sql, $count, $offset = 0)
} else {
$orderby = stristr($sql, 'ORDER BY');
- if (!$orderby) {
- $over = 'ORDER BY (SELECT 0)';
- } else {
- $over = preg_replace('/\"[^,]*\".\"([^,]*)\"/i', '"inner_tbl"."$1"', $orderby);
- }
+ $over = $orderby ? preg_replace('/\"[^,]*\".\"([^,]*)\"/i', '"inner_tbl"."$1"', $orderby) : 'ORDER BY (SELECT 0)';
// Remove ORDER BY clause from $sql
$sql = preg_replace('/\s+ORDER BY(.*)/', '', $sql);
@@ -652,12 +640,8 @@ public function limit($sql, $count, $offset = 0)
*/
public function supportsParameters($type)
{
- if ($type == 'positional') {
- return true;
- }
-
// if its 'named' or anything else
- return false;
+ return $type == 'positional';
}
/**
diff --git a/library/Zend/Db/Profiler.php b/library/Zend/Db/Profiler.php
index b5114bc32f..059a000c9d 100644
--- a/library/Zend/Db/Profiler.php
+++ b/library/Zend/Db/Profiler.php
@@ -162,11 +162,7 @@ public function getEnabled()
*/
public function setFilterElapsedSecs($minimumSeconds = null)
{
- if (null === $minimumSeconds) {
- $this->_filterElapsedSecs = null;
- } else {
- $this->_filterElapsedSecs = (integer) $minimumSeconds;
- }
+ $this->_filterElapsedSecs = null === $minimumSeconds ? null : (integer) $minimumSeconds;
return $this;
}
@@ -384,11 +380,7 @@ public function getQueryProfiles($queryType = null, $showUnfinished = false)
{
$queryProfiles = array();
foreach ($this->_queryProfiles as $key => $qp) {
- if ($queryType === null) {
- $condition = true;
- } else {
- $condition = ($qp->getQueryType() & $queryType);
- }
+ $condition = $queryType === null ? true : $qp->getQueryType() & $queryType;
if (($qp->hasEnded() || $showUnfinished) && $condition) {
$queryProfiles[$key] = $qp;
@@ -415,11 +407,7 @@ public function getTotalElapsedSecs($queryType = null)
{
$elapsedSecs = 0;
foreach ($this->_queryProfiles as $key => $qp) {
- if (null === $queryType) {
- $condition = true;
- } else {
- $condition = ($qp->getQueryType() & $queryType);
- }
+ $condition = null === $queryType ? true : $qp->getQueryType() & $queryType;
if (($qp->hasEnded()) && $condition) {
$elapsedSecs += $qp->getElapsedSecs();
}
diff --git a/library/Zend/Db/Profiler/Firebug.php b/library/Zend/Db/Profiler/Firebug.php
index 5d543f32a5..8425b339a4 100644
--- a/library/Zend/Db/Profiler/Firebug.php
+++ b/library/Zend/Db/Profiler/Firebug.php
@@ -90,7 +90,6 @@ public function setEnabled($enable)
parent::setEnabled($enable);
if ($this->getEnabled()) {
-
if (!$this->_message) {
$this->_message = new Zend_Wildfire_Plugin_FirePhp_TableMessage($this->_label);
$this->_message->setBuffered(true);
@@ -99,14 +98,9 @@ public function setEnabled($enable)
$this->_message->setOption('includeLineNumbers', false);
Zend_Wildfire_Plugin_FirePhp::getInstance()->send($this->_message);
}
-
- } else {
-
- if ($this->_message) {
- $this->_message->setDestroy(true);
- $this->_message = null;
- }
-
+ } elseif ($this->_message) {
+ $this->_message->setDestroy(true);
+ $this->_message = null;
}
return $this;
diff --git a/library/Zend/Db/Select.php b/library/Zend/Db/Select.php
index 1c33c04ab1..8b30552425 100644
--- a/library/Zend/Db/Select.php
+++ b/library/Zend/Db/Select.php
@@ -559,11 +559,7 @@ public function having($cond, $value = null, $type = null)
$cond = $this->_adapter->quoteInto($cond, $value, $type);
}
- if ($this->_parts[self::HAVING]) {
- $this->_parts[self::HAVING][] = self::SQL_AND . " ($cond)";
- } else {
- $this->_parts[self::HAVING][] = "($cond)";
- }
+ $this->_parts[self::HAVING][] = $this->_parts[self::HAVING] ? self::SQL_AND . " ($cond)" : "($cond)";
return $this;
}
@@ -586,11 +582,7 @@ public function orHaving($cond, $value = null, $type = null)
$cond = $this->_adapter->quoteInto($cond, $value, $type);
}
- if ($this->_parts[self::HAVING]) {
- $this->_parts[self::HAVING][] = self::SQL_OR . " ($cond)";
- } else {
- $this->_parts[self::HAVING][] = "($cond)";
- }
+ $this->_parts[self::HAVING][] = $this->_parts[self::HAVING] ? self::SQL_OR . " ($cond)" : "($cond)";
return $this;
}
@@ -786,7 +778,7 @@ protected function _join($type, $name, $cond, $cols, $schema = null)
throw new Zend_Db_Select_Exception("Invalid join type '$type'");
}
- if (count($this->_parts[self::UNION])) {
+ if (count($this->_parts[self::UNION]) > 0) {
require_once 'Zend/Db/Select/Exception.php';
throw new Zend_Db_Select_Exception("Invalid use of table with " . self::SQL_UNION);
}
@@ -979,7 +971,7 @@ protected function _tableCols($correlationName, $cols, $afterCorrelationName = n
$columnValues[] = array($currentCorrelationName, $col, is_string($alias) ? $alias : null);
}
- if ($columnValues) {
+ if ($columnValues !== []) {
// should we attempt to prepend or insert these values?
if ($afterCorrelationName === true || is_string($afterCorrelationName)) {
@@ -1001,12 +993,12 @@ protected function _tableCols($correlationName, $cols, $afterCorrelationName = n
// apply current values to current stack
foreach ($columnValues as $columnValue) {
- array_push($this->_parts[self::COLUMNS], $columnValue);
+ $this->_parts[self::COLUMNS][] = $columnValue;
}
// finish ensuring that all previous values are applied (if they exist)
while ($tmpColumns) {
- array_push($this->_parts[self::COLUMNS], array_shift($tmpColumns));
+ $this->_parts[self::COLUMNS][] = array_shift($tmpColumns);
}
}
}
@@ -1022,7 +1014,7 @@ protected function _tableCols($correlationName, $cols, $afterCorrelationName = n
*/
protected function _where($condition, $value = null, $type = null, $bool = true)
{
- if (count($this->_parts[self::UNION])) {
+ if (count($this->_parts[self::UNION]) > 0) {
require_once 'Zend/Db/Select/Exception.php';
throw new Zend_Db_Select_Exception("Invalid use of where clause with " . self::SQL_UNION);
}
@@ -1033,11 +1025,7 @@ protected function _where($condition, $value = null, $type = null, $bool = true)
$cond = "";
if ($this->_parts[self::WHERE]) {
- if ($bool === true) {
- $cond = self::SQL_AND . ' ';
- } else {
- $cond = self::SQL_OR . ' ';
- }
+ $cond = $bool ? self::SQL_AND . ' ' : self::SQL_OR . ' ';
}
return $cond . "($condition)";
@@ -1100,7 +1088,7 @@ protected function _renderDistinct($sql)
*/
protected function _renderColumns($sql)
{
- if (!count($this->_parts[self::COLUMNS])) {
+ if (count($this->_parts[self::COLUMNS]) === 0) {
return null;
}
@@ -1259,12 +1247,12 @@ protected function _renderOrder($sql)
$order = array();
foreach ($this->_parts[self::ORDER] as $term) {
if (is_array($term)) {
- if(is_numeric($term[0]) && strval(intval($term[0])) == $term[0]) {
+ if(is_numeric($term[0]) && strval((int) $term[0]) == $term[0]) {
$order[] = (int)trim($term[0]) . ' ' . $term[1];
} else {
$order[] = $this->_adapter->quoteIdentifier($term[0], true) . ' ' . $term[1];
}
- } elseif (is_numeric($term) && strval(intval($term)) == $term) {
+ } elseif (is_numeric($term) && strval((int) $term) == $term) {
$order[] = (int)trim($term);
} else {
$order[] = $this->_adapter->quoteIdentifier($term, true);
@@ -1342,7 +1330,7 @@ public function __call($method, array $args)
*/
if (preg_match('/^join([a-zA-Z]*?)Using$/', $method, $matches)) {
$type = strtolower($matches[1]);
- if ($type) {
+ if ($type !== '' && $type !== '0') {
$type .= ' join';
if (!in_array($type, self::$_joinTypes)) {
require_once 'Zend/Db/Select/Exception.php';
@@ -1356,7 +1344,9 @@ public function __call($method, array $args)
$type = self::INNER_JOIN;
}
array_unshift($args, $type);
- return call_user_func_array(array($this, '_joinUsing'), $args);
+ return call_user_func_array(function ($type, $name, $cond, $cols = '*', $schema = \null) : \Zend_Db_Select {
+ return $this->_joinUsing($type, $name, $cond, $cols, $schema);
+ }, $args);
}
require_once 'Zend/Db/Select/Exception.php';
diff --git a/library/Zend/Db/Statement.php b/library/Zend/Db/Statement.php
index be5e2d5912..671ef04d3b 100644
--- a/library/Zend/Db/Statement.php
+++ b/library/Zend/Db/Statement.php
@@ -137,28 +137,26 @@ protected function _parseParameters($sql)
$sql = $this->_stripQuoted($sql);
// split into text and params
- $this->_sqlSplit = preg_split('/(\?|\:[a-zA-Z0-9_]+)/',
+ $this->_sqlSplit = preg_split('/(\?|\:\w+)/',
$sql, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
// map params
$this->_sqlParam = array();
foreach ($this->_sqlSplit as $key => $val) {
if ($val == '?') {
- if ($this->_adapter->supportsParameters('positional') === false) {
+ if (!$this->_adapter->supportsParameters('positional')) {
/**
* @see Zend_Db_Statement_Exception
*/
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception("Invalid bind-variable position '$val'");
}
- } else if ($val[0] == ':') {
- if ($this->_adapter->supportsParameters('named') === false) {
- /**
- * @see Zend_Db_Statement_Exception
- */
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception("Invalid bind-variable name '$val'");
- }
+ } elseif ($val[0] == ':' && !$this->_adapter->supportsParameters('named')) {
+ /**
+ * @see Zend_Db_Statement_Exception
+ */
+ require_once 'Zend/Db/Statement/Exception.php';
+ throw new Zend_Db_Statement_Exception("Invalid bind-variable name '$val'");
}
$this->_sqlParam[] = $val;
}
@@ -253,11 +251,11 @@ public function bindParam($parameter, &$variable, $type = null, $length = null,
if ($intval >= 1 || $intval <= count($this->_sqlParam)) {
$position = $intval;
}
- } else if ($this->_adapter->supportsParameters('named')) {
+ } elseif ($this->_adapter->supportsParameters('named')) {
if ($parameter[0] != ':') {
$parameter = ':' . $parameter;
}
- if (in_array($parameter, $this->_sqlParam) !== false) {
+ if (in_array($parameter, $this->_sqlParam)) {
$position = $parameter;
}
}
@@ -318,7 +316,7 @@ public function execute(array $params = null)
} else {
$qp->bindParams($this->_bindParam);
}
- $qp->start($this->_queryId);
+ $qp->start();
$retval = $this->_execute($params);
diff --git a/library/Zend/Db/Statement/Db2.php b/library/Zend/Db/Statement/Db2.php
index c23a9f3a95..5edc9d315b 100644
--- a/library/Zend/Db/Statement/Db2.php
+++ b/library/Zend/Db/Statement/Db2.php
@@ -90,11 +90,7 @@ public function _bindParam($parameter, &$variable, $type = null, $length = null,
$type = DB2_PARAM_IN;
}
- if (isset($options['data-type'])) {
- $datatype = $options['data-type'];
- } else {
- $datatype = DB2_CHAR;
- }
+ $datatype = isset($options['data-type']) ? $options['data-type'] : DB2_CHAR;
if (!db2_bind_param($this->_stmt, $parameter, "variable", $type, $datatype)) {
/**
@@ -198,13 +194,9 @@ public function _execute(array $params = null)
}
$retval = true;
- if ($params !== null) {
- $retval = @db2_execute($this->_stmt, $params);
- } else {
- $retval = @db2_execute($this->_stmt);
- }
+ $retval = $params !== null ? @db2_execute($this->_stmt, $params) : @db2_execute($this->_stmt);
- if ($retval === false) {
+ if (!$retval) {
/**
* @see Zend_Db_Statement_Db2_Exception
*/
@@ -215,7 +207,7 @@ public function _execute(array $params = null)
}
$this->_keys = array();
- if ($field_num = $this->columnCount()) {
+ if (($field_num = $this->columnCount()) !== 0) {
for ($i = 0; $i < $field_num; $i++) {
$name = db2_field_name($this->_stmt, $i);
$this->_keys[] = $name;
@@ -289,8 +281,7 @@ public function fetch($style = null, $cursor = null, $offset = null)
*/
public function fetchObject($class = 'stdClass', array $config = array())
{
- $obj = $this->fetch(Zend_Db::FETCH_OBJ);
- return $obj;
+ return $this->fetch(Zend_Db::FETCH_OBJ);
}
/**
diff --git a/library/Zend/Db/Statement/Mysqli.php b/library/Zend/Db/Statement/Mysqli.php
index fecd67f92d..8707526f2c 100644
--- a/library/Zend/Db/Statement/Mysqli.php
+++ b/library/Zend/Db/Statement/Mysqli.php
@@ -135,7 +135,7 @@ public function closeCursor()
*/
public function columnCount()
{
- if (isset($this->_meta) && $this->_meta) {
+ if ($this->_meta !== null && $this->_meta) {
return $this->_meta->field_count;
}
return 0;
@@ -192,7 +192,7 @@ public function _execute(array $params = null)
$params = $this->_bindParam;
}
// send $params as input parameters to the statement
- if ($params) {
+ if ($params !== []) {
array_unshift($params, str_repeat('s', count($params)));
$stmtParams = array();
foreach ($params as $k => &$value) {
@@ -291,9 +291,7 @@ public function fetch($style = null, $cursor = null, $offset = null)
// dereference the result values, otherwise things like fetchAll()
// return the same values for every entry (because of the reference).
$values = array();
- foreach ($this->_values as $key => $val) {
- $values[] = $val;
- }
+ $values = $this->_values;
$row = false;
switch ($style) {
diff --git a/library/Zend/Db/Statement/Oracle.php b/library/Zend/Db/Statement/Oracle.php
index a157a8a439..9a1acc0c47 100644
--- a/library/Zend/Db/Statement/Oracle.php
+++ b/library/Zend/Db/Statement/Oracle.php
@@ -121,7 +121,7 @@ protected function _bindParam($parameter, &$variable, $type = null, $length = nu
}
$retval = @oci_bind_by_name($this->_stmt, $parameter, $variable, $length, $type);
- if ($retval === false) {
+ if (!$retval) {
/**
* @see Zend_Db_Adapter_Oracle_Exception
*/
@@ -255,7 +255,7 @@ public function _execute(array $params = null)
}
$retval = @oci_execute($this->_stmt, $this->_adapter->_getExecuteMode());
- if ($retval === false) {
+ if (!$retval) {
/**
* @see Zend_Db_Adapter_Oracle_Exception
*/
@@ -264,7 +264,7 @@ public function _execute(array $params = null)
}
$this->_keys = Array();
- if ($field_num = oci_num_fields($this->_stmt)) {
+ if (($field_num = oci_num_fields($this->_stmt)) !== 0) {
for ($i = 1; $i <= $field_num; $i++) {
$name = oci_field_name($this->_stmt, $i);
$this->_keys[] = $name;
@@ -394,7 +394,7 @@ public function fetchAll($style = null, $col = 0)
case Zend_Db::FETCH_OBJ:
break;
case Zend_Db::FETCH_COLUMN:
- $flags = $flags &~ OCI_FETCHSTATEMENT_BY_ROW;
+ $flags &= ~ OCI_FETCHSTATEMENT_BY_ROW;
$flags |= OCI_FETCHSTATEMENT_BY_COLUMN;
$flags |= OCI_NUM;
break;
@@ -414,7 +414,7 @@ public function fetchAll($style = null, $col = 0)
$result = Array();
if ($flags != OCI_FETCHSTATEMENT_BY_ROW) { /* not Zend_Db::FETCH_OBJ */
- if (! ($rows = oci_fetch_all($this->_stmt, $result, 0, -1, $flags) )) {
+ if (($rows = oci_fetch_all($this->_stmt, $result, 0, -1, $flags)) === 0) {
if ($error = oci_error($this->_stmt)) {
/**
* @see Zend_Db_Adapter_Oracle_Exception
@@ -422,7 +422,7 @@ public function fetchAll($style = null, $col = 0)
require_once 'Zend/Db/Statement/Oracle/Exception.php';
throw new Zend_Db_Statement_Oracle_Exception($error);
}
- if (!$rows) {
+ if ($rows === 0) {
return array();
}
}
diff --git a/library/Zend/Db/Statement/Pdo.php b/library/Zend/Db/Statement/Pdo.php
index b11bc6c7b1..7f999ac44b 100644
--- a/library/Zend/Db/Statement/Pdo.php
+++ b/library/Zend/Db/Statement/Pdo.php
@@ -105,7 +105,7 @@ protected function _bindParam($parameter, &$variable, $type = null, $length = nu
$type = PDO::PARAM_BOOL;
} elseif ($variable === null) {
$type = PDO::PARAM_NULL;
- } elseif (is_integer($variable)) {
+ } elseif (is_int($variable)) {
$type = PDO::PARAM_INT;
} else {
$type = PDO::PARAM_STR;
@@ -245,7 +245,7 @@ public function _execute(array $params = null)
* @return mixed Array, object, or scalar depending on fetch mode.
* @throws Zend_Db_Statement_Exception
*/
- public function fetch($style = null, $cursor = null, $offset = null)
+ public function fetch($style = null, $cursor = PDO::FETCH_ORI_NEXT, $offset = 0)
{
if ($style === null) {
$style = $this->_fetchMode;
@@ -263,6 +263,7 @@ public function fetch($style = null, $cursor = null, $offset = null)
*
* @return IteratorIterator
*/
+ #[\ReturnTypeWillChange]
public function getIterator()
{
return new IteratorIterator($this->_stmt);
diff --git a/library/Zend/Db/Table.php b/library/Zend/Db/Table.php
index 6f676439de..25bdc04c90 100644
--- a/library/Zend/Db/Table.php
+++ b/library/Zend/Db/Table.php
@@ -62,15 +62,12 @@ public function __construct($config = array(), $definition = null)
E_USER_NOTICE
);
$config = array(self::ADAPTER => $config);
+ } elseif ($definition instanceof Zend_Db_Table_Definition
+ && $definition->hasTableConfig($config)) {
+ // this will have DEFINITION_CONFIG_NAME & DEFINITION
+ $config = $definition->getTableConfig($config);
} else {
- // process this as table with or without a definition
- if ($definition instanceof Zend_Db_Table_Definition
- && $definition->hasTableConfig($config)) {
- // this will have DEFINITION_CONFIG_NAME & DEFINITION
- $config = $definition->getTableConfig($config);
- } else {
- $config = array(self::NAME => $config);
- }
+ $config = array(self::NAME => $config);
}
}
diff --git a/library/Zend/Db/Table/Abstract.php b/library/Zend/Db/Table/Abstract.php
index 66aa60545a..6212ea152a 100644
--- a/library/Zend/Db/Table/Abstract.php
+++ b/library/Zend/Db/Table/Abstract.php
@@ -262,7 +262,7 @@ public function __construct($config = array())
$config = array(self::ADAPTER => $config);
}
- if ($config) {
+ if ($config !== []) {
$this->setOptions($config);
}
@@ -773,7 +773,7 @@ protected function _setupTableName()
{
if (! $this->_name) {
$this->_name = get_class($this);
- } else if (strpos($this->_name, '.')) {
+ } elseif (strpos($this->_name, '.')) {
list($this->_schema, $this->_name) = explode('.', $this->_name);
}
}
@@ -789,7 +789,7 @@ protected function _setupTableName()
*/
protected function _setupMetadata()
{
- if ($this->metadataCacheInClass() && (count($this->_metadata) > 0)) {
+ if ($this->metadataCacheInClass() && ($this->_metadata !== [])) {
return true;
}
@@ -888,9 +888,9 @@ protected function _setupPrimaryKey()
require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("A table must have a primary key, but none was found for table '{$this->_name}'");
}
- } else if (!is_array($this->_primary)) {
+ } elseif (!is_array($this->_primary)) {
$this->_primary = array(1 => $this->_primary);
- } else if (isset($this->_primary[0])) {
+ } elseif (isset($this->_primary[0])) {
array_unshift($this->_primary, null);
unset($this->_primary[0]);
}
@@ -939,11 +939,7 @@ protected function _getReferenceMapNormalized()
// normalize COLUMNS and REF_COLUMNS to arrays
case self::COLUMNS:
case self::REF_COLUMNS:
- if (!is_array($value)) {
- $referenceMapNormalized[$rule][$key] = array($value);
- } else {
- $referenceMapNormalized[$rule][$key] = $value;
- }
+ $referenceMapNormalized[$rule][$key] = is_array($value) ? $value : array($value);
break;
// other values are copied as-is
@@ -1050,13 +1046,12 @@ public function insert(array $data)
* position of the data. The following values are considered empty:
* null, false, true, '', array()
*/
- if (array_key_exists($pkIdentity, $data)) {
- if ($data[$pkIdentity] === null // null
- || $data[$pkIdentity] === '' // empty string
- || is_bool($data[$pkIdentity]) // boolean
- || (is_array($data[$pkIdentity]) && empty($data[$pkIdentity]))) { // empty array
- unset($data[$pkIdentity]);
- }
+ if (array_key_exists($pkIdentity, $data) && ($data[$pkIdentity] === null // null
+ || $data[$pkIdentity] === '' // empty string
+ || is_bool($data[$pkIdentity]) // boolean
+ || ($data[$pkIdentity] === []))) {
+ // empty array
+ unset($data[$pkIdentity]);
}
/**
@@ -1151,7 +1146,8 @@ public function _cascadeUpdate($parentTableClassname, array $oldPrimaryKey, arra
case self::CASCADE:
$newRefs = array();
$where = array();
- for ($i = 0; $i < count($map[self::COLUMNS]); ++$i) {
+ $itemsCount = count($map[self::COLUMNS]);
+ for ($i = 0; $i < $itemsCount; ++$i) {
$col = $this->_db->foldCase($map[self::COLUMNS][$i]);
$refCol = $this->_db->foldCase($map[self::REF_COLUMNS][$i]);
if (array_key_exists($refCol, $newPrimaryKey)) {
@@ -1230,7 +1226,8 @@ public function _cascadeDelete($parentTableClassname, array $primaryKey)
// CASCADE or CASCADE_RECURSE
if (in_array($map[self::ON_DELETE], array(self::CASCADE, self::CASCADE_RECURSE))) {
- for ($i = 0; $i < count($map[self::COLUMNS]); ++$i) {
+ $itemsCount = count($map[self::COLUMNS]);
+ for ($i = 0; $i < $itemsCount; ++$i) {
$col = $this->_db->foldCase($map[self::COLUMNS][$i]);
$refCol = $this->_db->foldCase($map[self::REF_COLUMNS][$i]);
$type = $this->_metadata[$col]['DATA_TYPE'];
@@ -1285,10 +1282,9 @@ public function _cascadeDelete($parentTableClassname, array $primaryKey)
* @return Zend_Db_Table_Rowset_Abstract Row(s) matching the criteria.
* @throws Zend_Db_Table_Exception
*/
- public function find()
+ public function find(...$args)
{
$this->_setupPrimaryKey();
- $args = func_get_args();
$keyNames = array_values((array) $this->_primary);
if (count($args) < count($keyNames)) {
@@ -1313,7 +1309,7 @@ public function find()
}
if ($numberTerms == 0) {
$numberTerms = $keyValuesCount;
- } else if ($keyValuesCount != $numberTerms) {
+ } elseif ($keyValuesCount != $numberTerms) {
require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("Missing value(s) for the primary key");
}
@@ -1327,7 +1323,7 @@ public function find()
}
$whereClause = null;
- if (count($whereList)) {
+ if ($whereList !== []) {
$whereOrTerms = array();
$tableName = $this->_db->quoteTableAs($this->_name, null, true);
foreach ($whereList as $keyValueSets) {
@@ -1492,7 +1488,7 @@ public function createRow(array $data = array(), $defaultSource = null)
if ($defaultSource == self::DEFAULT_DB) {
foreach ($this->_metadata as $metadataName => $metadata) {
if (($metadata['DEFAULT'] != null) &&
- ($metadata['NULLABLE'] !== true || ($metadata['NULLABLE'] === true && isset($this->_defaultValues[$metadataName]) && $this->_defaultValues[$metadataName] === true)) &&
+ ($metadata['NULLABLE'] !== true || ($metadata['NULLABLE'] && isset($this->_defaultValues[$metadataName]) && $this->_defaultValues[$metadataName] === true)) &&
(!(isset($this->_defaultValues[$metadataName]) && $this->_defaultValues[$metadataName] === false))) {
$defaults[$metadataName] = $metadata['DEFAULT'];
}
@@ -1575,8 +1571,7 @@ protected function _order(Zend_Db_Table_Select $select, $order)
protected function _fetch(Zend_Db_Table_Select $select)
{
$stmt = $this->_db->query($select);
- $data = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
- return $data;
+ return $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
}
/**
diff --git a/library/Zend/Db/Table/Row/Abstract.php b/library/Zend/Db/Table/Row/Abstract.php
index 0ae6f8d028..38c3960e30 100644
--- a/library/Zend/Db/Table/Row/Abstract.php
+++ b/library/Zend/Db/Table/Row/Abstract.php
@@ -450,7 +450,7 @@ protected function _doInsert()
/**
* A read-only row cannot be saved.
*/
- if ($this->_readOnly === true) {
+ if ($this->_readOnly) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception('This row has been marked read-only');
}
@@ -508,7 +508,7 @@ protected function _doUpdate()
/**
* A read-only row cannot be saved.
*/
- if ($this->_readOnly === true) {
+ if ($this->_readOnly) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception('This row has been marked read-only');
}
@@ -539,7 +539,7 @@ protected function _doUpdate()
* Execute cascading updates against dependent tables.
* Do this only if primary key value(s) were changed.
*/
- if (count($pkDiffData) > 0) {
+ if ($pkDiffData !== []) {
$depTables = $this->_getTable()->getDependentTables();
if (!empty($depTables)) {
$pkNew = $this->_getPrimaryKey(true);
@@ -557,7 +557,7 @@ protected function _doUpdate()
* Use the $diffData variable, so the UPDATE statement
* includes SET terms only for data values that changed.
*/
- if (count($diffData) > 0) {
+ if ($diffData !== []) {
$this->_getTable()->update($diffData, $where);
}
@@ -597,7 +597,7 @@ public function delete()
/**
* A read-only row cannot be deleted.
*/
- if ($this->_readOnly === true) {
+ if ($this->_readOnly) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception('This row has been marked read-only');
}
@@ -712,12 +712,8 @@ protected function _getPrimaryKey($useDirty = true)
}
$primary = array_flip($this->_primary);
- if ($useDirty) {
- $array = array_intersect_key($this->_data, $primary);
- } else {
- $array = array_intersect_key($this->_cleanData, $primary);
- }
- if (count($primary) != count($array)) {
+ $array = $useDirty ? array_intersect_key($this->_data, $primary) : array_intersect_key($this->_cleanData, $primary);
+ if (count($primary) !== count($array)) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception("The specified Table '$this->_tableClass' does not have the same primary key as the Row");
}
@@ -770,7 +766,7 @@ protected function _refresh()
$where = $this->_getWhereQuery();
$row = $this->_getTable()->fetchRow($where);
- if (null === $row) {
+ if (!$row instanceof \Zend_Db_Table_Row_Abstract) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception('Cannot refresh row as parent is missing');
}
@@ -852,7 +848,7 @@ protected function _postDelete()
*/
protected function _prepareReference(Zend_Db_Table_Abstract $dependentTable, Zend_Db_Table_Abstract $parentTable, $ruleKey)
{
- $parentTableName = (get_class($parentTable) === 'Zend_Db_Table') ? $parentTable->getDefinitionConfigName() : get_class($parentTable);
+ $parentTableName = ($parentTable instanceof \Zend_Db_Table) ? $parentTable->getDefinitionConfigName() : get_class($parentTable);
$map = $dependentTable->getReference($parentTableName, $ruleKey);
if (!isset($map[Zend_Db_Table_Abstract::REF_COLUMNS])) {
@@ -906,8 +902,9 @@ public function findDependentRowset($dependentTable, $ruleKey = null, Zend_Db_Ta
}
$map = $this->_prepareReference($dependentTable, $this->_getTable(), $ruleKey);
+ $itemsCount = count($map[Zend_Db_Table_Abstract::COLUMNS]);
- for ($i = 0; $i < count($map[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
+ for ($i = 0; $i < $itemsCount; ++$i) {
$parentColumnName = $db->foldCase($map[Zend_Db_Table_Abstract::REF_COLUMNS][$i]);
$value = $this->_data[$parentColumnName];
// Use adapter from dependent table to ensure correct query construction
@@ -962,9 +959,10 @@ public function findParentRow($parentTable, $ruleKey = null, Zend_Db_Table_Selec
}
$map = $this->_prepareReference($this->_getTable(), $parentTable, $ruleKey);
+ $itemsCount = count($map[Zend_Db_Table_Abstract::COLUMNS]);
// iterate the map, creating the proper wheres
- for ($i = 0; $i < count($map[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
+ for ($i = 0; $i < $itemsCount; ++$i) {
$dependentColumnName = $db->foldCase($map[Zend_Db_Table_Abstract::COLUMNS][$i]);
$value = $this->_data[$dependentColumnName];
// Use adapter from parent table to ensure correct query construction
@@ -1059,8 +1057,9 @@ public function findManyToManyRowset($matchTable, $intersectionTable, $callerRef
$matchSchema = isset($matchInfo['schema']) ? $matchInfo['schema'] : null;
$matchMap = $this->_prepareReference($intersectionTable, $matchTable, $matchRefRule);
+ $itemsCount = count($matchMap[Zend_Db_Table_Abstract::COLUMNS]);
- for ($i = 0; $i < count($matchMap[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
+ for ($i = 0; $i < $itemsCount; ++$i) {
$interCol = $interDb->quoteIdentifier('i' . '.' . $matchMap[Zend_Db_Table_Abstract::COLUMNS][$i], true);
$matchCol = $interDb->quoteIdentifier('m' . '.' . $matchMap[Zend_Db_Table_Abstract::REF_COLUMNS][$i], true);
$joinCond[] = "$interCol = $matchCol";
@@ -1072,8 +1071,9 @@ public function findManyToManyRowset($matchTable, $intersectionTable, $callerRef
->setIntegrityCheck(false);
$callerMap = $this->_prepareReference($intersectionTable, $this->_getTable(), $callerRefRule);
+ $itemsCount = count($callerMap[Zend_Db_Table_Abstract::COLUMNS]);
- for ($i = 0; $i < count($callerMap[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
+ for ($i = 0; $i < $itemsCount; ++$i) {
$callerColumnName = $db->foldCase($callerMap[Zend_Db_Table_Abstract::REF_COLUMNS][$i]);
$value = $this->_data[$callerColumnName];
$interColumnName = $interDb->foldCase($callerMap[Zend_Db_Table_Abstract::COLUMNS][$i]);
@@ -1103,8 +1103,7 @@ public function findManyToManyRowset($matchTable, $intersectionTable, $callerRef
throw new Zend_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e);
}
}
- $rowset = new $rowsetClass($config);
- return $rowset;
+ return new $rowsetClass($config);
}
/**
@@ -1120,11 +1119,7 @@ public function __call($method, array $args)
{
$matches = array();
- if (count($args) && $args[0] instanceof Zend_Db_Table_Select) {
- $select = $args[0];
- } else {
- $select = null;
- }
+ $select = count($args) && $args[0] instanceof Zend_Db_Table_Select ? $args[0] : null;
/**
* Recognize methods for Has-Many cases:
diff --git a/library/Zend/Db/Table/Rowset/Abstract.php b/library/Zend/Db/Table/Rowset/Abstract.php
index abace7bbde..d5b2a32672 100644
--- a/library/Zend/Db/Table/Rowset/Abstract.php
+++ b/library/Zend/Db/Table/Rowset/Abstract.php
@@ -242,7 +242,7 @@ public function rewind()
*/
public function current()
{
- if ($this->valid() === false) {
+ if (!$this->valid()) {
return null;
}
@@ -431,10 +431,8 @@ protected function _loadAndReturnRow($position)
if ( $this->_table instanceof Zend_Db_Table_Abstract ) {
$info = $this->_table->info();
- if ( $this->_rows[$position] instanceof Zend_Db_Table_Row_Abstract ) {
- if ($info['cols'] == array_keys($this->_data[$position])) {
- $this->_rows[$position]->setTable($this->getTable());
- }
+ if ( $this->_rows[$position] instanceof Zend_Db_Table_Row_Abstract && $info['cols'] == array_keys($this->_data[$position]) ) {
+ $this->_rows[$position]->setTable($this->getTable());
}
} else {
$this->_rows[$position]->setTable(null);
diff --git a/library/Zend/Db/Table/Select.php b/library/Zend/Db/Table/Select.php
index c352836c99..a7f2802dab 100644
--- a/library/Zend/Db/Table/Select.php
+++ b/library/Zend/Db/Table/Select.php
@@ -129,7 +129,7 @@ public function isReadOnly()
$fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
$cols = $this->_info[Zend_Db_Table_Abstract::COLS];
- if (!count($fields)) {
+ if (count($fields) === 0) {
return $readOnly;
}
@@ -197,7 +197,7 @@ public function assemble()
if (count($this->_parts[self::UNION]) == 0) {
// If no fields are specified we assume all fields from primary table
- if (!count($fields)) {
+ if (count($fields) === 0) {
$this->from($primary, self::SQL_WILDCARD, $schema);
$fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
}
@@ -209,11 +209,9 @@ public function assemble()
list($table, $column) = $columnEntry;
// Check each column to ensure it only references the primary table
- if ($column) {
- if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) {
- require_once 'Zend/Db/Table/Select/Exception.php';
- throw new Zend_Db_Table_Select_Exception('Select query cannot join with another table');
- }
+ if ($column && (!isset($from[$table]) || $from[$table]['tableName'] != $primary)) {
+ require_once 'Zend/Db/Table/Select/Exception.php';
+ throw new Zend_Db_Table_Select_Exception('Select query cannot join with another table');
}
}
}
diff --git a/library/Zend/Dojo/BuildLayer.php b/library/Zend/Dojo/BuildLayer.php
index 74e05c5489..99b20c7224 100644
--- a/library/Zend/Dojo/BuildLayer.php
+++ b/library/Zend/Dojo/BuildLayer.php
@@ -299,7 +299,7 @@ public function setProfileOptions(array $options)
*/
public function addProfileOptions(array $options)
{
- $this->_profileOptions = $this->_profileOptions + $options;
+ $this->_profileOptions += $options;
return $this;
}
@@ -475,9 +475,7 @@ public function generateLayerScript()
}
}
- $content .= "})();";
-
- return $content;
+ return $content . "})();";
}
/**
@@ -529,7 +527,6 @@ protected function _filterJsonProfileToJavascript($profile)
require_once 'Zend/Json.php';
$profile = Zend_Json::encode($profile);
$profile = trim($profile, '"');
- $profile = preg_replace('/' . preg_quote('\\') . '/', '', $profile);
- return $profile;
+ return preg_replace('/' . preg_quote('\\', '/') . '/', '', $profile);
}
}
diff --git a/library/Zend/Dojo/Data.php b/library/Zend/Dojo/Data.php
index 8d59e78400..4ca4252951 100644
--- a/library/Zend/Dojo/Data.php
+++ b/library/Zend/Dojo/Data.php
@@ -251,11 +251,7 @@ public function getIdentifier()
*/
public function setLabel($label)
{
- if (null === $label) {
- $this->_label = null;
- } else {
- $this->_label = (string) $label;
- }
+ $this->_label = null === $label ? null : (string) $label;
return $this;
}
@@ -539,11 +535,7 @@ protected function _normalizeItem($item, $id)
}
if (is_object($item)) {
- if (method_exists($item, 'toArray')) {
- $item = $item->toArray();
- } else {
- $item = get_object_vars($item);
- }
+ $item = method_exists($item, 'toArray') ? $item->toArray() : get_object_vars($item);
}
if ((null === $id) && !array_key_exists($identifier, $item)) {
diff --git a/library/Zend/Dojo/Form.php b/library/Zend/Dojo/Form.php
index c6da435ba8..6161a17aaa 100644
--- a/library/Zend/Dojo/Form.php
+++ b/library/Zend/Dojo/Form.php
@@ -79,10 +79,8 @@ public function loadDefaultDecorators()
*/
public function setView(Zend_View_Interface $view = null)
{
- if (null !== $view) {
- if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
- $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
- }
+ if (null !== $view && false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
+ $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
}
return parent::setView($view);
}
diff --git a/library/Zend/Dojo/Form/Decorator/DijitContainer.php b/library/Zend/Dojo/Form/Decorator/DijitContainer.php
index ea09895761..b3abf1c8fb 100644
--- a/library/Zend/Dojo/Form/Decorator/DijitContainer.php
+++ b/library/Zend/Dojo/Form/Decorator/DijitContainer.php
@@ -105,11 +105,7 @@ public function getDijitParams()
{
if (null === $this->_dijitParams) {
$attribs = $this->getElement()->getAttribs();
- if (array_key_exists('dijitParams', $attribs)) {
- $this->_dijitParams = $attribs['dijitParams'];
- } else {
- $this->_dijitParams = array();
- }
+ $this->_dijitParams = array_key_exists('dijitParams', $attribs) ? $attribs['dijitParams'] : array();
$options = $this->getOptions();
if (array_key_exists('dijitParams', $options)) {
@@ -135,10 +131,8 @@ public function getTitle()
{
if (null === $this->_title) {
$title = null;
- if (null !== ($element = $this->getElement())) {
- if (method_exists($element, 'getLegend')) {
- $title = $element->getLegend();
- }
+ if (null !== ($element = $this->getElement()) && method_exists($element, 'getLegend')) {
+ $title = $element->getLegend();
}
if (empty($title) && (null !== ($title = $this->getOption('legend')))) {
$this->removeOption('legend');
@@ -170,7 +164,7 @@ public function render($content)
{
$element = $this->getElement();
$view = $element->getView();
- if (null === $view) {
+ if (!$view instanceof \Zend_View_Interface) {
return $content;
}
diff --git a/library/Zend/Dojo/Form/Decorator/DijitElement.php b/library/Zend/Dojo/Form/Decorator/DijitElement.php
index 3dc00f11e2..7a7f29879b 100644
--- a/library/Zend/Dojo/Form/Decorator/DijitElement.php
+++ b/library/Zend/Dojo/Form/Decorator/DijitElement.php
@@ -151,7 +151,7 @@ public function render($content)
{
$element = $this->getElement();
$view = $element->getView();
- if (null === $view) {
+ if (!$view instanceof \Zend_View_Interface) {
require_once 'Zend/Form/Decorator/Exception.php';
throw new Zend_Form_Decorator_Exception('DijitElement decorator cannot render without a registered view object');
}
diff --git a/library/Zend/Dojo/Form/Decorator/DijitForm.php b/library/Zend/Dojo/Form/Decorator/DijitForm.php
index a78b1b03d7..65749c9b95 100644
--- a/library/Zend/Dojo/Form/Decorator/DijitForm.php
+++ b/library/Zend/Dojo/Form/Decorator/DijitForm.php
@@ -49,7 +49,7 @@ public function render($content)
{
$element = $this->getElement();
$view = $element->getView();
- if (null === $view) {
+ if (!$view instanceof \Zend_View_Interface) {
return $content;
}
diff --git a/library/Zend/Dojo/Form/DisplayGroup.php b/library/Zend/Dojo/Form/DisplayGroup.php
index e757ab7249..56b33989a8 100644
--- a/library/Zend/Dojo/Form/DisplayGroup.php
+++ b/library/Zend/Dojo/Form/DisplayGroup.php
@@ -58,10 +58,8 @@ public function __construct($name, Zend_Loader_PluginLoader $loader, $options =
*/
public function setView(Zend_View_Interface $view = null)
{
- if (null !== $view) {
- if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
- $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
- }
+ if (null !== $view && false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
+ $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
}
return parent::setView($view);
}
diff --git a/library/Zend/Dojo/Form/Element/Dijit.php b/library/Zend/Dojo/Form/Element/Dijit.php
index ef4596ed52..4e2cfa1c7a 100644
--- a/library/Zend/Dojo/Form/Element/Dijit.php
+++ b/library/Zend/Dojo/Form/Element/Dijit.php
@@ -179,10 +179,8 @@ public function loadDefaultDecorators()
*/
public function setView(Zend_View_Interface $view = null)
{
- if (null !== $view) {
- if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
- $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
- }
+ if (null !== $view && false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
+ $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
}
return parent::setView($view);
}
diff --git a/library/Zend/Dojo/Form/Element/DijitMulti.php b/library/Zend/Dojo/Form/Element/DijitMulti.php
index 9cff377bd5..0f7b391d9a 100644
--- a/library/Zend/Dojo/Form/Element/DijitMulti.php
+++ b/library/Zend/Dojo/Form/Element/DijitMulti.php
@@ -245,15 +245,13 @@ public function registerInArrayValidator()
*/
public function isValid($value, $context = null)
{
- if ($this->registerInArrayValidator()) {
- if (!$this->getValidator('InArray')) {
- $options = $this->getMultiOptions();
- $this->addValidator(
- 'InArray',
- true,
- array(array_keys($options))
- );
- }
+ if ($this->registerInArrayValidator() && !$this->getValidator('InArray')) {
+ $options = $this->getMultiOptions();
+ $this->addValidator(
+ 'InArray',
+ true,
+ array(array_keys($options))
+ );
}
return parent::isValid($value, $context);
}
diff --git a/library/Zend/Dojo/Form/Element/ValidationTextBox.php b/library/Zend/Dojo/Form/Element/ValidationTextBox.php
index c196a6d18d..3b4a55b27b 100644
--- a/library/Zend/Dojo/Form/Element/ValidationTextBox.php
+++ b/library/Zend/Dojo/Form/Element/ValidationTextBox.php
@@ -134,7 +134,9 @@ public function setConstraints(array $constraints)
{
$tmp = $this->getConstraints();
$constraints = array_merge($tmp, $constraints);
- array_walk_recursive($constraints, array($this, '_castBoolToString'));
+ array_walk_recursive($constraints, function ($item, string $key) : void {
+ $this->_castBoolToString($item, $key);
+ });
$this->setDijitParam('constraints', $constraints);
return $this;
}
diff --git a/library/Zend/Dojo/View/Helper/ComboBox.php b/library/Zend/Dojo/View/Helper/ComboBox.php
index 749e1ec71d..b56490bd0c 100644
--- a/library/Zend/Dojo/View/Helper/ComboBox.php
+++ b/library/Zend/Dojo/View/Helper/ComboBox.php
@@ -75,8 +75,7 @@ public function comboBox($id, $value = null, array $params = array(), array $att
if (is_string($store)) {
$html .= $store;
}
- $html .= $this->_createFormElement($id, $value, $params, $attribs);
- return $html;
+ return $html . $this->_createFormElement($id, $value, $params, $attribs);
}
unset($params['store']);
} elseif (array_key_exists('store', $params)) {
@@ -90,14 +89,11 @@ public function comboBox($id, $value = null, array $params = array(), array $att
$storeParams['params'] = $params['storeParams'];
unset($params['storeParams']);
}
- if (false !== ($store = $this->_renderStore($storeParams, $id))) {
- if (is_string($store)) {
- $html .= $store;
- }
+ if (false !== ($store = $this->_renderStore($storeParams, $id)) && is_string($store)) {
+ $html .= $store;
}
}
- $html .= $this->_createFormElement($id, $value, $params, $attribs);
- return $html;
+ return $html . $this->_createFormElement($id, $value, $params, $attribs);
}
// required for correct type casting in declerative mode
diff --git a/library/Zend/Dojo/View/Helper/Dijit.php b/library/Zend/Dojo/View/Helper/Dijit.php
index c3c108f790..f38cd0c7fd 100644
--- a/library/Zend/Dojo/View/Helper/Dijit.php
+++ b/library/Zend/Dojo/View/Helper/Dijit.php
@@ -154,11 +154,10 @@ protected function _createLayoutContainer($id, $content, array $params, array $a
$attribs = $this->_prepareDijit($attribs, $params, 'layout', $dijit);
$nodeType = $this->getRootNode();
- $html = '<' . $nodeType . $this->_htmlAttribs($attribs) . '>'
+
+ return '<' . $nodeType . $this->_htmlAttribs($attribs) . '>'
. $content
. "$nodeType>\n";
-
- return $html;
}
/**
@@ -181,11 +180,9 @@ public function _createFormElement($id, $value, array $params, array $attribs, $
$attribs['type'] = $this->_elementType;
$attribs = $this->_prepareDijit($attribs, $params, 'element', $dijit);
-
- $html = '_htmlAttribs($attribs)
. $this->getClosingBracket();
- return $html;
}
/**
@@ -283,7 +280,9 @@ protected function _createDijit($dijit, $id, array $params)
{
$params['dojoType'] = $dijit;
- array_walk_recursive($params, array($this, '_castBoolToString'));
+ array_walk_recursive($params, function ($item, string $key) : void {
+ $this->_castBoolToString($item, $key);
+ });
$this->dojo->setDijit($id, $params);
}
diff --git a/library/Zend/Dojo/View/Helper/Dojo.php b/library/Zend/Dojo/View/Helper/Dojo.php
index ecd4d1c481..ed4efae2a2 100644
--- a/library/Zend/Dojo/View/Helper/Dojo.php
+++ b/library/Zend/Dojo/View/Helper/Dojo.php
@@ -151,7 +151,7 @@ public static function setUseProgrammatic($style = self::PROGRAMMATIC_SCRIPT)
*/
public static function useDeclarative()
{
- return (false === self::$_useProgrammatic);
+ return (!self::$_useProgrammatic);
}
/**
@@ -161,7 +161,7 @@ public static function useDeclarative()
*/
public static function useProgrammatic()
{
- return (false !== self::$_useProgrammatic);
+ return (self::$_useProgrammatic);
}
/**
diff --git a/library/Zend/Dojo/View/Helper/Dojo/Container.php b/library/Zend/Dojo/View/Helper/Dojo/Container.php
index 172bbcd550..c8a54943e2 100644
--- a/library/Zend/Dojo/View/Helper/Dojo/Container.php
+++ b/library/Zend/Dojo/View/Helper/Dojo/Container.php
@@ -430,7 +430,7 @@ public function getCdnBase()
public function setCdnVersion($version = null)
{
$this->enable();
- if (preg_match('/^[1-9]\.[0-9]{1,2}(\.[0-9]{1,2})?$/', (string) $version)) {
+ if (preg_match('/^[1-9]\.\d{1,2}(\.\d{1,2})?$/', (string) $version)) {
$this->_cdnVersion = $version;
}
return $this;
@@ -508,7 +508,7 @@ public function getLocalPath()
*/
public function useLocalPath()
{
- return (null === $this->_localPath) ? false : true;
+ return null !== $this->_localPath;
}
/**
@@ -960,22 +960,18 @@ public function __toString()
$this->_isXhtml = $this->view->doctype()->isXhtml();
- if (Zend_Dojo_View_Helper_Dojo::useDeclarative()) {
- if (null === $this->getDjConfigOption('parseOnLoad')) {
- $this->setDjConfigOption('parseOnLoad', true);
- }
+ if (Zend_Dojo_View_Helper_Dojo::useDeclarative() && null === $this->getDjConfigOption('parseOnLoad')) {
+ $this->setDjConfigOption('parseOnLoad', true);
}
if (!empty($this->_dijits)) {
$this->registerDijitLoader();
}
-
- $html = $this->_renderStylesheets() . PHP_EOL
+ return $this->_renderStylesheets() . PHP_EOL
. $this->_renderDjConfig() . PHP_EOL
. $this->_renderDojoScriptTag() . PHP_EOL
. $this->_renderLayers() . PHP_EOL
. $this->_renderExtras();
- return $html;
}
/**
@@ -1000,12 +996,8 @@ protected function _getLocalRelativePath()
*/
protected function _renderStylesheets()
{
- if ($this->useCdn()) {
- $base = $this->getCdnBase()
- . $this->getCdnVersion();
- } else {
- $base = $this->_getLocalRelativePath();
- }
+ $base = $this->useCdn() ? $this->getCdnBase()
+ . $this->getCdnVersion() : $this->_getLocalRelativePath();
$registeredStylesheets = $this->getStylesheetModules();
foreach ($registeredStylesheets as $stylesheet) {
@@ -1032,10 +1024,9 @@ protected function _renderStylesheets()
foreach ($stylesheets as $stylesheet) {
$style .= ' @import "' . $stylesheet . '";' . PHP_EOL;
}
- $style .= (($this->_isXhtml) ? '-->' : '-->') . PHP_EOL
- . '';
- return $style;
+ return $style . ((($this->_isXhtml) ? '-->' : '-->') . PHP_EOL
+ . '');
}
/**
@@ -1051,13 +1042,12 @@ protected function _renderDjConfig()
}
require_once 'Zend/Json.php';
- $scriptTag = '';
-
- return $scriptTag;
}
/**
@@ -1078,9 +1068,7 @@ protected function _renderDojoScriptTag()
} else {
$source = $this->getLocalPath();
}
-
- $scriptTag = '';
- return $scriptTag;
+ return '';
}
/**
@@ -1165,13 +1153,11 @@ protected function _renderExtras()
if (preg_match('/^\s*$/s', $content)) {
return '';
}
-
- $html = '';
- return $html;
}
/**
diff --git a/library/Zend/Dojo/View/Helper/Editor.php b/library/Zend/Dojo/View/Helper/Editor.php
index c31179bc9e..434ae700ae 100644
--- a/library/Zend/Dojo/View/Helper/Editor.php
+++ b/library/Zend/Dojo/View/Helper/Editor.php
@@ -98,11 +98,7 @@ public function editor($id, $value = null, $params = array(), $attribs = array()
}
$hiddenName = $id;
- if (array_key_exists('id', $attribs)) {
- $hiddenId = $attribs['id'];
- } else {
- $hiddenId = $hiddenName;
- }
+ $hiddenId = array_key_exists('id', $attribs) ? $attribs['id'] : $hiddenName;
$hiddenId = $this->_normalizeId($hiddenId);
$textareaName = $this->_normalizeEditorName($hiddenName);
diff --git a/library/Zend/Dojo/View/Helper/SimpleTextarea.php b/library/Zend/Dojo/View/Helper/SimpleTextarea.php
index 04bbbb7072..53127ae6c8 100644
--- a/library/Zend/Dojo/View/Helper/SimpleTextarea.php
+++ b/library/Zend/Dojo/View/Helper/SimpleTextarea.php
@@ -68,10 +68,8 @@ public function simpleTextarea($id, $value = null, array $params = array(), arra
$attribs = $this->_prepareDijit($attribs, $params, 'textarea');
- $html = '