From 0bb492776ebc95fe26629b019b45a3e2130b73c0 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Tue, 12 Feb 2019 15:23:38 -0500 Subject: [PATCH] less array_push --- htdocs/add_attr_form.php | 4 ++-- htdocs/add_oclass_form.php | 2 +- htdocs/copy.php | 12 ++++++------ htdocs/mass_delete.php | 4 ++-- htdocs/rdelete.php | 2 +- htdocs/update_confirm.php | 2 +- lib/AJAXTree.php | 4 ++-- lib/Attribute.php | 2 +- lib/HTMLTree.php | 2 +- lib/PageRender.php | 8 ++++---- lib/Query.php | 4 ++-- lib/Template.php | 34 +++++++++++++++++----------------- lib/TemplateRender.php | 6 +++--- lib/Tree.php | 2 +- lib/TreeItem.php | 2 +- lib/Visitor.php | 4 ++-- lib/config_default.php | 2 +- lib/ds.php | 2 +- lib/ds_ldap.php | 4 ++-- lib/export_functions.php | 8 ++++---- lib/functions.php | 12 ++++++------ lib/schema_functions.php | 38 +++++++++++++++++++------------------- lib/xmlTemplates.php | 8 ++++---- 23 files changed, 84 insertions(+), 84 deletions(-) diff --git a/htdocs/add_attr_form.php b/htdocs/add_attr_form.php index 80e19db..a3a35f8 100644 --- a/htdocs/add_attr_form.php +++ b/htdocs/add_attr_form.php @@ -43,10 +43,10 @@ if (get_request('meth','REQUEST') != 'ajax') { { if ($app['server']->isAttrBinary($attribute->getName())) { - array_push($attr['binary'], $attribute); + $attr['binary'][] = $attribute; } else { - array_push($attr['avail'], $attribute); + $attr['avail'][] = $attribute; } } diff --git a/htdocs/add_oclass_form.php b/htdocs/add_oclass_form.php index fcc55c1..8d138f2 100644 --- a/htdocs/add_oclass_form.php +++ b/htdocs/add_oclass_form.php @@ -58,7 +58,7 @@ foreach ($ldap['attrs']['must'] as $attr) { if (is_null($request['template']->getAttribute($attr))) { - array_push($ldap['attrs']['need'], $attribute_factory->newAttribute($attr, array('values' => array()), $app['server']->getIndex())); + $ldap['attrs']['need'][] = $attribute_factory->newAttribute($attr, array('values' => array()), $app['server']->getIndex()); } } diff --git a/htdocs/copy.php b/htdocs/copy.php index 57cd2b4..0d43291 100644 --- a/htdocs/copy.php +++ b/htdocs/copy.php @@ -150,7 +150,7 @@ function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) { return FALSE; } - array_push($copy_message,sprintf('%s %s: %s %s',_('Copy successful'),_('DN'),$dnDST,_('has been created.'))); + $copy_message[] = sprintf('%s %s: %s %s', _('Copy successful'), _('DN'), $dnDST, _('has been created.')); $hadError = false; foreach ($children as $child_dn) { @@ -169,7 +169,7 @@ function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) { if ($delete_result) { - array_push($copy_message, sprintf('%s %s: %s %s', _('Delete successful'), _('DN'), $dnDST, _('has been deleted.'))); + $copy_message[] = sprintf('%s %s: %s %s', _('Delete successful'), _('DN'), $dnDST, _('has been deleted.')); } } @@ -178,15 +178,15 @@ function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) { if ($copy_result) { - array_push($copy_message, sprintf('%s %s: %s %s', + $copy_message[] = sprintf('%s %s: %s %s', $remove ? _('Move successful') : _('Copy successful'), - _('DN'), $dnDST, _('has been created.'))); + _('DN'), $dnDST, _('has been created.')); } else { - array_push($copy_message, sprintf('%s %s: %s %s', + $copy_message[] = sprintf('%s %s: %s %s', $remove ? _('Move NOT successful') : _('Copy NOT successful'), - _('DN'), $dnDST, _('has NOT been created.'))); + _('DN'), $dnDST, _('has NOT been created.')); } } diff --git a/htdocs/mass_delete.php b/htdocs/mass_delete.php index dd7e8ac..7316d5d 100644 --- a/htdocs/mass_delete.php +++ b/htdocs/mass_delete.php @@ -43,7 +43,7 @@ foreach ($request['dn'] as $dn) { # We search all children, not only the visible children in the tree if (! in_array_ignore_case($dn,$request['children'])) { $request['children'] = array_merge($request['children'],$app['server']->getContainerContents($dn,null,0,'(objectClass=*)',LDAP_DEREF_NEVER)); - array_push($request['parent'],$dn); + $request['parent'][] = $dn; } } @@ -94,7 +94,7 @@ if (count($request['children'])) { foreach ($request['search'] as $value) { - array_push($request['delete'], $value['dn']); + $request['delete'][] = $value['dn']; } echo ''; diff --git a/htdocs/rdelete.php b/htdocs/rdelete.php index 1368354..f2aa73b 100644 --- a/htdocs/rdelete.php +++ b/htdocs/rdelete.php @@ -30,7 +30,7 @@ foreach ($request['dn'] as $dn) 'type' => 'error')); } else { - array_push($request['parent'], $dn); + $request['parent'][] = $dn; } } diff --git a/htdocs/update_confirm.php b/htdocs/update_confirm.php index 3345b6b..6ab5c66 100644 --- a/htdocs/update_confirm.php +++ b/htdocs/update_confirm.php @@ -278,7 +278,7 @@ function getMustAttrs($oclasses) { { foreach ($soc->getMustAttrs() as $sma) { - array_push($mustattrs, $sma->getName()); + $mustattrs[] = $sma->getName(); } } } diff --git a/lib/AJAXTree.php b/lib/AJAXTree.php index 5b8b9e5..935dd4b 100644 --- a/lib/AJAXTree.php +++ b/lib/AJAXTree.php @@ -177,7 +177,7 @@ class AJAXTree extends HTMLTree { $this->addEntry($child); } - array_push($children,$this->getEntry($child)); + $children[] = $this->getEntry($child); } $first_child = $this->create_before_child($parent_entry,$code); @@ -373,7 +373,7 @@ class AJAXTree extends HTMLTree { { if ($value->isOpened()) { - array_push($result, $value->getDN()); + $result[] = $value->getDN(); } } diff --git a/lib/Attribute.php b/lib/Attribute.php index 83ad05c..3d62c53 100644 --- a/lib/Attribute.php +++ b/lib/Attribute.php @@ -861,7 +861,7 @@ class Attribute { # Store our Aliases foreach ($sattr->getAliases() as $alias) { - array_push($this->aliases, strtolower($alias)); + $this->aliases[] = strtolower($alias); } if ($sattr->getIsSingleValue()) diff --git a/lib/HTMLTree.php b/lib/HTMLTree.php index 014697f..c10fde0 100644 --- a/lib/HTMLTree.php +++ b/lib/HTMLTree.php @@ -422,7 +422,7 @@ class HTMLTree extends Tree { $bases = $server->getContainerTop($logged_in_dn); if (is_array($bases) && count($bases)) { - array_push($logged_in_dn_array, $bases); + $logged_in_dn_array[] = $bases; } $rdn = $logged_in_dn; diff --git a/lib/PageRender.php b/lib/PageRender.php index eb90681..9e06d10 100644 --- a/lib/PageRender.php +++ b/lib/PageRender.php @@ -229,7 +229,7 @@ class PageRender extends Visitor { if (! $attribute2) { if (($pv = get_request(strtolower($joinattr),'REQUEST')) && isset($pv[$attribute->getName()][$i])) { - array_push($values,$pv[$attribute->getName()][$i]); + $values[] = $pv[$attribute->getName()][$i]; if (! $pv[$attribute->getName()][$i]) { @@ -237,7 +237,7 @@ class PageRender extends Visitor { } } else { - array_push($values,''); + $values[] = ''; $blank++; } @@ -245,7 +245,7 @@ class PageRender extends Visitor { return; } elseif (count($attribute2->getValues()) != 1) { - array_push($values,''); + $values[] = ''; $blank++; system_message(array( @@ -256,7 +256,7 @@ class PageRender extends Visitor { } else { - array_push($values, $attribute2->getValue(0)); + $values[] = $attribute2->getValue(0); } } diff --git a/lib/Query.php b/lib/Query.php index 93e9be5..327c58e 100644 --- a/lib/Query.php +++ b/lib/Query.php @@ -267,7 +267,7 @@ class Query extends xmlTemplate { foreach ($this->attributes as $attribute) { - array_push($result, $attribute->getName()); + $result[] = $attribute->getName(); } } else { @@ -295,7 +295,7 @@ class Query extends xmlTemplate { foreach ($this->attributes as $attribute) { - array_push($result, $attribute->getName()); + $result[] = $attribute->getName(); } } else { diff --git a/lib/Template.php b/lib/Template.php index b376768..eca7c2a 100644 --- a/lib/Template.php +++ b/lib/Template.php @@ -120,7 +120,7 @@ class Template extends xmlTemplate { # If we havent recorded this objectclass already, do so now. if (is_object($soc) && ! in_array($soc->getName(), $objectclasses)) { - array_push($objectclasses, $soc->getName(FALSE)); + $objectclasses[] = $soc->getName(FALSE); } elseif ( ! is_object($soc) && ! $_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_warning')) { system_message(array( @@ -138,7 +138,7 @@ class Template extends xmlTemplate { # If we havent recorded this objectclass already, do so now. if (is_object($soc) && ! in_array($soc->getName(), $objectclasses)) { - array_push($objectclasses, $soc->getName(FALSE)); + $objectclasses[] = $soc->getName(FALSE); } } } @@ -960,7 +960,7 @@ class Template extends xmlTemplate { foreach ($this->attributes as $index => $attribute) { if ($attribute->getLDAPtype() == strtolower($type)) { - array_push($result, $attribute->getName()); + $result[] = $attribute->getName(); } } @@ -1006,7 +1006,7 @@ class Template extends xmlTemplate { { if ($attribute->isRDN()) { - array_push($return, $attribute); + $return[] = $attribute; } } @@ -1213,7 +1213,7 @@ class Template extends xmlTemplate { continue; } - array_push($result,$attribute); + $result[] = $attribute; } return $result; @@ -1234,7 +1234,7 @@ class Template extends xmlTemplate { { if ($attribute->isVisible()) { - array_push($result, $attribute); + $result[] = $attribute; } } @@ -1256,7 +1256,7 @@ class Template extends xmlTemplate { { if ($attribute->isInternal()) { - array_push($result, $attribute); + $result[] = $attribute; } } @@ -1606,7 +1606,7 @@ class Template extends xmlTemplate { if ($soc->getType() == 'structural' && (! $inherited)) { - array_push($this->structural_oclass, $oclass); + $this->structural_oclass[] = $oclass; } # Make sure our MUST attributes are marked as such for this template. @@ -1651,7 +1651,7 @@ class Template extends xmlTemplate { if ( ! in_array($objectclassattr, $allattrs)) { - array_push($allattrs, $objectclassattr); + $allattrs[] = $objectclassattr; } } } @@ -1676,13 +1676,13 @@ class Template extends xmlTemplate { if ( ! in_array($objectclassattr, $allattrs)) { - array_push($allattrs, $objectclassattr); + $allattrs[] = $objectclassattr; } } } # Keep a list to objectclasses we have processed, so we dont get into a loop. - array_push($oclass_processed,$oclass); + $oclass_processed[] = $oclass; $supoclasses = $soc->getSupClasses(); if (count($supoclasses) || count($superclasslist)) { @@ -1761,7 +1761,7 @@ class Template extends xmlTemplate { # Ensure that our objectclasses has "top". if (isset($return['objectclass']) && ! in_array('top',$return['objectclass'])) { - array_push($return['objectclass'], 'top'); + $return['objectclass'][] = 'top'; } if ($attrsOnly) @@ -1821,7 +1821,7 @@ class Template extends xmlTemplate { { if ( ! in_array($value->getName(), $attr_to_keep)) { - array_push($attr_to_keep, $value->getName()); + $attr_to_keep[] = $value->getName(); } } @@ -1829,7 +1829,7 @@ class Template extends xmlTemplate { { if ( ! in_array($value->getName(), $attr_to_keep)) { - array_push($attr_to_keep, $value->getName()); + $attr_to_keep[] = $value->getName(); } } } @@ -1909,7 +1909,7 @@ class Template extends xmlTemplate { { if ($attribute->isForceDelete()) { - array_push($result, $attribute); + $result[] = $attribute; } } @@ -1934,7 +1934,7 @@ class Template extends xmlTemplate { if (in_array_ignore_case('extensibleobject',$this->getObjectClasses())) { foreach ($server->SchemaAttributes() as $sattr) { $attribute = $attribute_factory->newAttribute($sattr->getName(),array('values'=>array()),$server->getIndex(),null); - array_push($attributes,$attribute); + $attributes[] = $attribute; } } else { @@ -1951,7 +1951,7 @@ class Template extends xmlTemplate { if (is_null($this->getAttribute($attr))) { $attribute = $attribute_factory->newAttribute($attr, array('values' => array()), $server->getIndex(), NULL); - array_push($attributes, $attribute); + $attributes[] = $attribute; } } } diff --git a/lib/TemplateRender.php b/lib/TemplateRender.php index 8332266..cab9dd2 100644 --- a/lib/TemplateRender.php +++ b/lib/TemplateRender.php @@ -1234,7 +1234,7 @@ class TemplateRender extends PageRender { { if (in_array($attribute->getName(), $modified)) { - array_push($modified_attrs, $attribute->getFriendlyName()); + $modified_attrs[] = $attribute->getFriendlyName(); } } @@ -2038,12 +2038,12 @@ class TemplateRender extends PageRender { if ($attribute->isRequired()) { - array_push($attrs['required'], $attribute); + $attrs['required'][] = $attribute; } elseif (! $attribute->getValues()) { - array_push($attrs['optional'], $attribute); + $attrs['optional'][] = $attribute; } } diff --git a/lib/Tree.php b/lib/Tree.php index 4aecd72..cf1a8a4 100644 --- a/lib/Tree.php +++ b/lib/Tree.php @@ -128,7 +128,7 @@ abstract class Tree { { if ($details->isBaseDN() AND (( ! $this->getServer()->getValue('server', 'hide_noaccess_base')) OR $details->isInLdap())) { - array_push($return, $details); + $return[] = $details; } } diff --git a/lib/TreeItem.php b/lib/TreeItem.php index 0b8de68..510dd85 100644 --- a/lib/TreeItem.php +++ b/lib/TreeItem.php @@ -193,7 +193,7 @@ class TreeItem { return; } - array_push($this->children,$dn); + $this->children[] = $dn; $this->childsort = true; } diff --git a/lib/Visitor.php b/lib/Visitor.php index 033ced2..6c322ab 100644 --- a/lib/Visitor.php +++ b/lib/Visitor.php @@ -41,7 +41,7 @@ abstract class Visitor { $call = "$method$fnct$class"; - array_push($methods,$call); + $methods[] = $call; while ($class && ! method_exists($this,$call)) { if (defined('DEBUGTMP') && DEBUGTMP) @@ -50,7 +50,7 @@ abstract class Visitor { $class = get_parent_class($class); $call = "$method$fnct$class"; - array_push($methods,$call); + $methods[] = $call; } if (defined('DEBUGTMP') && DEBUGTMP) diff --git a/lib/config_default.php b/lib/config_default.php index 056e358..6f75902 100644 --- a/lib/config_default.php +++ b/lib/config_default.php @@ -653,7 +653,7 @@ class Config { { if (isset($values['untested']) && $values['untested']) { - array_push($result, sprintf('%s.%s', $option, $param)); + $result[] = sprintf('%s.%s', $option, $param); } } } diff --git a/lib/ds.php b/lib/ds.php index 10422cb..e96d1ef 100644 --- a/lib/ds.php +++ b/lib/ds.php @@ -143,7 +143,7 @@ abstract class DS { { if (isset($values['untested']) && $values['untested']) { - array_push($result, sprintf('%s.%s', $option, $param)); + $result[] = sprintf('%s.%s', $option, $param); } } } diff --git a/lib/ds_ldap.php b/lib/ds_ldap.php index 6951828..f2e63a9 100644 --- a/lib/ds_ldap.php +++ b/lib/ds_ldap.php @@ -1216,7 +1216,7 @@ class ldap extends DS { if ($results) { foreach ($results as $index => $entry) { $child_dn = $entry['dn']; - array_push($return,$child_dn); + $return[] = $child_dn; } } @@ -2872,7 +2872,7 @@ class ldap extends DS { foreach ($results as $result) { - array_push($dn_array, $result['dn']); + $dn_array[] = $result['dn']; } $dn_array = array_unique($dn_array); diff --git a/lib/export_functions.php b/lib/export_functions.php index 0906e76..ad9f284 100644 --- a/lib/export_functions.php +++ b/lib/export_functions.php @@ -144,9 +144,9 @@ abstract class Export { if (get_request('sys_attr')) { if (! in_array('*',$query['attrs'])) { - array_push($query['attrs'], '*'); + $query['attrs'][] = '*'; } - array_push($query['attrs'],'+'); + $query['attrs'][] = '+'; } if (! $base) @@ -273,14 +273,14 @@ class ExportCSV extends Export { $entries = array(); foreach ($this->results as $base => $results) { foreach ($results as $dndetails) { - array_push($entries,$dndetails); + $entries[] = $dndetails; unset($dndetails['dn']); foreach (array_keys($dndetails) as $key) { if ( ! in_array($key, $headers)) { - array_push($headers, $key); + $headers[] = $key; } } diff --git a/lib/functions.php b/lib/functions.php index bca6e7f..a76706a 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -47,7 +47,7 @@ $app['function_files'] = array( if (file_exists(LIBDIR.'functions.custom.php')) { - array_push($app['function_files'], LIBDIR . 'functions.custom.php'); + $app['function_files'][] = LIBDIR . 'functions.custom.php'; } /** @@ -617,15 +617,15 @@ function debug_log($msg,$level,$indent) { foreach ($args as $key) { if (is_array($key)) { - array_push($fargs, serialize($key)); + $fargs[] = serialize($key); } elseif (is_object($key)) { - array_push($fargs, sprintf('OBJECT:%s', get_class($key))); + $fargs[] = sprintf('OBJECT:%s', get_class($key)); } else { - array_push($fargs, $key); + $fargs[] = $key; } } @@ -837,7 +837,7 @@ function system_message($msg,$redirect=null) { } } - array_push($_SESSION['sysmsg'],$msg); + $_SESSION['sysmsg'][] = $msg; if ($redirect) { if (preg_match('/\?/',$redirect)) @@ -1803,7 +1803,7 @@ function get_next_number($base,$attr,$increment=false,$filter=false,$startmin=nu $values = array_change_key_case($values); foreach ($values[$attr] as $value) { - array_push($autonum, $value); + $autonum[] = $value; } } diff --git a/lib/schema_functions.php b/lib/schema_functions.php index 4d858bd..fd04378 100644 --- a/lib/schema_functions.php +++ b/lib/schema_functions.php @@ -214,7 +214,7 @@ class ObjectClass extends SchemaItem { case 'SUP': if ($strings[$i+1] != '(') { $i++; - array_push($this->sup_classes,preg_replace("/'/",'',$strings[$i])); + $this->sup_classes[] = preg_replace("/'/", '', $strings[$i]); } else { $i++; @@ -222,7 +222,7 @@ class ObjectClass extends SchemaItem { $i++; if ($strings[$i] != '$') { - array_push($this->sup_classes, preg_replace("/'/", '', $strings[$i])); + $this->sup_classes[] = preg_replace("/'/", '', $strings[$i]); } } while (! preg_match('/\)+\)?/',$strings[$i+1])); @@ -275,12 +275,12 @@ class ObjectClass extends SchemaItem { $attr = new ObjectClass_ObjectClassAttribute($string,$this->name); if ($server->isForceMay($attr->getName())) { - array_push($this->force_may,$attr); - array_push($this->may_attrs,$attr); + $this->force_may[] = $attr; + $this->may_attrs[] = $attr; } else { - array_push($this->must_attrs, $attr); + $this->must_attrs[] = $attr; } } @@ -302,7 +302,7 @@ class ObjectClass extends SchemaItem { foreach ($attrs as $string) { $attr = new ObjectClass_ObjectClassAttribute($string,$this->name); - array_push($this->may_attrs,$attr); + $this->may_attrs[] = $attr; } if (DEBUG_ENABLED) @@ -362,12 +362,12 @@ class ObjectClass extends SchemaItem { $string = preg_replace('/\)+$/', '', $string); } - array_push($attrs,$string); + $attrs[] = $string; } elseif (preg_match('/^\(.*\)$/',$string)) { $string = preg_replace('/^\(/','',$string); $string = preg_replace('/\)+$/','',$string); - array_push($attrs,$string); + $attrs[] = $string; } else { # Handle the opening cases first @@ -376,7 +376,7 @@ class ObjectClass extends SchemaItem { } elseif (preg_match('/^\(./',$string)) { $string = preg_replace('/^\(/','',$string); - array_push($attrs,$string); + $attrs[] = $string; $i++; } @@ -398,7 +398,7 @@ class ObjectClass extends SchemaItem { $i++; } - array_push($attrs,$string); + $attrs[] = $string; } } @@ -430,7 +430,7 @@ class ObjectClass extends SchemaItem { $return = array(); foreach ($this->sup_classes as $object_class) { - array_push($return,$object_class); + $return[] = $object_class; $oc = $server->getSchemaObjectClass($object_class); @@ -578,7 +578,7 @@ class ObjectClass extends SchemaItem { foreach ($this->getMustAttrs($parents) as $attr) { - array_push($attr_names, $attr->getName()); + $attr_names[] = $attr->getName(); } return $attr_names; @@ -609,7 +609,7 @@ class ObjectClass extends SchemaItem { foreach ($this->getMayAttrs($parents) as $attr) { - array_push($attr_names, $attr->getName()); + $attr_names[] = $attr->getName(); } return $attr_names; @@ -638,7 +638,7 @@ class ObjectClass extends SchemaItem { } } - array_push($this->children_objectclasses,$name); + $this->children_objectclasses[] = $name; } /** @@ -1386,7 +1386,7 @@ class AttributeType extends SchemaItem { debug_log('Entered (%%)', 9, 0, __FILE__, __LINE__, __METHOD__, $fargs); } - array_push($this->aliases,$alias); + $this->aliases[] = $alias; } /** @@ -1469,7 +1469,7 @@ class AttributeType extends SchemaItem { } } - array_push($this->used_in_object_classes,$name); + $this->used_in_object_classes[] = $name; } /** @@ -1507,7 +1507,7 @@ class AttributeType extends SchemaItem { } } - array_push($this->required_by_object_classes,$name); + $this->required_by_object_classes[] = $name; } /** @@ -1731,7 +1731,7 @@ class MatchingRule extends SchemaItem { } } - array_push($this->used_by_attrs,$attr); + $this->used_by_attrs[] = $attr; return true; } @@ -1826,7 +1826,7 @@ class MatchingRuleUse extends SchemaItem { $new_attr = $strings[$i]; $new_attr = preg_replace("/^\'/",'',$new_attr); $new_attr = preg_replace("/\'$/",'',$new_attr); - array_push($this->used_by_attrs,$new_attr); + $this->used_by_attrs[] = $new_attr; $i++; } } diff --git a/lib/xmlTemplates.php b/lib/xmlTemplates.php index 48ce7d5..299bf9b 100644 --- a/lib/xmlTemplates.php +++ b/lib/xmlTemplates.php @@ -241,7 +241,7 @@ abstract class xmlTemplates { { if (is_null($type) || ( ! is_null($type) && $template->isType($type))) { - array_push($result, $template); + $result[] = $template; } } } @@ -290,7 +290,7 @@ abstract class xmlTemplates { foreach ($this->templates as $template) { - array_push($result, $template->getFileName()); + $result[] = $template->getFileName(); } return $result; @@ -549,7 +549,7 @@ abstract class xmlTemplate { if (is_null($attrid)) { - array_push($this->attributes, $attribute); + $this->attributes[] = $attribute; } return $attribute; @@ -570,7 +570,7 @@ abstract class xmlTemplate { foreach ($this->attributes as $attribute) { - array_push($result, $attribute->getName()); + $result[] = $attribute->getName(); } return $result;