Merge pull request #11752 from owncloud/use-function-outside-of-loop

Use function outside of loop
This commit is contained in:
Lukas Reschke 2014-10-24 13:54:09 +02:00
commit 77b8e1543a
8 changed files with 21 additions and 13 deletions

View File

@ -716,10 +716,11 @@ class OC_Mount_Config {
} }
} }
if (count($dependencyGroup) > 0) { $dependencyGroupCount = count($dependencyGroup);
if ($dependencyGroupCount > 0) {
$backends = ''; $backends = '';
for ($i = 0; $i < count($dependencyGroup); $i++) { for ($i = 0; $i < $dependencyGroupCount; $i++) {
if ($i > 0 && $i === count($dependencyGroup) - 1) { if ($i > 0 && $i === $dependencyGroupCount - 1) {
$backends .= $l->t(' and '); $backends .= $l->t(' and ');
} elseif ($i > 0) { } elseif ($i > 0) {
$backends .= ', '; $backends .= ', ';

View File

@ -685,7 +685,8 @@ class Wizard extends LDAPUtility {
$this->ldap->getDN($cr, $er); $this->ldap->getDN($cr, $er);
$attrs = $this->ldap->getAttributes($cr, $er); $attrs = $this->ldap->getAttributes($cr, $er);
$result = array(); $result = array();
for($i = 0; $i < count($possibleAttrs); $i++) { $possibleAttrsCount = count($possibleAttrs);
for($i = 0; $i < $possibleAttrsCount; $i++) {
if(isset($attrs[$possibleAttrs[$i]])) { if(isset($attrs[$possibleAttrs[$i]])) {
$result[$possibleAttrs[$i]] = $attrs[$possibleAttrs[$i]]['count']; $result[$possibleAttrs[$i]] = $attrs[$possibleAttrs[$i]]['count'];
} }

View File

@ -54,8 +54,8 @@ $wizTabs[] = array('tpl' => 'part.wizard-server', 'cap' => $l->t('Server'))
$wizTabs[] = array('tpl' => 'part.wizard-userfilter', 'cap' => $l->t('User Filter')); $wizTabs[] = array('tpl' => 'part.wizard-userfilter', 'cap' => $l->t('User Filter'));
$wizTabs[] = array('tpl' => 'part.wizard-loginfilter', 'cap' => $l->t('Login Filter')); $wizTabs[] = array('tpl' => 'part.wizard-loginfilter', 'cap' => $l->t('Login Filter'));
$wizTabs[] = array('tpl' => 'part.wizard-groupfilter', 'cap' => $l->t('Group Filter')); $wizTabs[] = array('tpl' => 'part.wizard-groupfilter', 'cap' => $l->t('Group Filter'));
$wizTabsCount = count($wizTabs);
for($i = 0; $i < count($wizTabs); $i++) { for($i = 0; $i < $wizTabsCount; $i++) {
$tab = new OCP\Template('user_ldap', $wizTabs[$i]['tpl']); $tab = new OCP\Template('user_ldap', $wizTabs[$i]['tpl']);
if($i === 0) { if($i === 0) {
$tab->assign('serverConfigurationPrefixes', $prefixes); $tab->assign('serverConfigurationPrefixes', $prefixes);

View File

@ -82,8 +82,9 @@ class MiddlewareDispatcher {
*/ */
public function beforeController(Controller $controller, $methodName){ public function beforeController(Controller $controller, $methodName){
// we need to count so that we know which middlewares we have to ask in // we need to count so that we know which middlewares we have to ask in
// case theres an exception // case there is an exception
for($i=0; $i<count($this->middlewares); $i++){ $middlewareCount = count($this->middlewares);
for($i = 0; $i < $middlewareCount; $i++){
$this->middlewareCounter++; $this->middlewareCounter++;
$middleware = $this->middlewares[$i]; $middleware = $this->middlewares[$i];
$middleware->beforeController($controller, $methodName); $middleware->beforeController($controller, $methodName);

View File

@ -182,7 +182,9 @@ class ArrayParser {
if (substr($body, -1, 1) !== ',') { if (substr($body, -1, 1) !== ',') {
$body .= ','; $body .= ',';
} }
for ($i = 0; $i < strlen($body); $i++) {
$bodyLength = strlen($body);
for ($i = 0; $i < $bodyLength; $i++) {
$char = substr($body, $i, 1); $char = substr($body, $i, 1);
if ($char === '\\') { if ($char === '\\') {
if ($escaped) { if ($escaped) {

View File

@ -89,9 +89,10 @@ class OC_DB_StatementWrapper {
$cArg = 0; $cArg = 0;
$inSubstring = false; $inSubstring = false;
$queryLength = strlen($query);
// Create new query // Create new query
for ($i = 0; $i < strlen ($query); $i++) { for ($i = 0; $i < $queryLength; $i++) {
if ($inSubstring == false) { if ($inSubstring == false) {
// Defines when we should start inserting values // Defines when we should start inserting values
if (substr ($query, $i, 9) == 'SUBSTRING') { if (substr ($query, $i, 9) == 'SUBSTRING') {

View File

@ -129,8 +129,9 @@ class OC_OCSClient{
$data = simplexml_load_string($xml); $data = simplexml_load_string($xml);
libxml_disable_entity_loader($loadEntities); libxml_disable_entity_loader($loadEntities);
$tmp=$data->data->content; $tmp = $data->data->content;
for($i = 0; $i < count($tmp); $i++) { $tmpCount = count($tmp);
for($i = 0; $i < $tmpCount; $i++) {
$app=array(); $app=array();
$app['id']=(string)$tmp[$i]->id; $app['id']=(string)$tmp[$i]->id;
$app['name']=(string)$tmp[$i]->name; $app['name']=(string)$tmp[$i]->name;

View File

@ -72,7 +72,8 @@ class OC_VObject{
*/ */
public static function unescapeSemicolons($value) { public static function unescapeSemicolons($value) {
$array = explode(';', $value); $array = explode(';', $value);
for($i=0;$i<count($array);$i++) { $arrayCount = count($array);
for($i = 0; $i < $arrayCount; $i++) {
if(substr($array[$i], -2, 2)=="\\\\") { if(substr($array[$i], -2, 2)=="\\\\") {
if(isset($array[$i+1])) { if(isset($array[$i+1])) {
$array[$i] = substr($array[$i], 0, count($array[$i])-2).';'.$array[$i+1]; $array[$i] = substr($array[$i], 0, count($array[$i])-2).';'.$array[$i+1];