Skip to content

Commit

Permalink
Remove unused variables and code
Browse files Browse the repository at this point in the history
  • Loading branch information
shama committed Sep 6, 2012
1 parent f1c2b1f commit bc40ac7
Show file tree
Hide file tree
Showing 22 changed files with 19 additions and 38 deletions.
2 changes: 0 additions & 2 deletions lib/Cake/Controller/Component/Acl/PhpAcl.php
Expand Up @@ -318,10 +318,8 @@ public function resolve($aco) {
* @return void * @return void
*/ */
public function build(array $allow, array $deny = array()) { public function build(array $allow, array $deny = array()) {
$stack = array();
$this->_tree = array(); $this->_tree = array();
$tree = array(); $tree = array();
$root = &$tree;


foreach ($allow as $dotPath => $aros) { foreach ($allow as $dotPath => $aros) {
if (is_string($aros)) { if (is_string($aros)) {
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Controller/Controller.php
Expand Up @@ -557,7 +557,6 @@ protected function _mergeControllerVars() {


if ($mergeParent || !empty($pluginController)) { if ($mergeParent || !empty($pluginController)) {
$appVars = get_class_vars($this->_mergeParent); $appVars = get_class_vars($this->_mergeParent);
$uses = $appVars['uses'];
$merge = array('components', 'helpers'); $merge = array('components', 'helpers');
$this->_mergeVars($merge, $this->_mergeParent, true); $this->_mergeVars($merge, $this->_mergeParent, true);
} }
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Core/Configure.php
Expand Up @@ -185,7 +185,6 @@ public static function read($var = null) {
*/ */
public static function delete($var = null) { public static function delete($var = null) {
$keys = explode('.', $var); $keys = explode('.', $var);
$last = array_pop($keys);
self::$_values = Hash::remove(self::$_values, $var); self::$_values = Hash::remove(self::$_values, $var);
} }


Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -603,7 +603,6 @@ public function unbindTranslation(Model $Model, $fields = null) {
if (is_string($fields)) { if (is_string($fields)) {
$fields = array($fields); $fields = array($fields);
} }
$RuntimeModel = $this->translateModel($Model);
$associations = array(); $associations = array();


foreach ($fields as $key => $value) { foreach ($fields as $key => $value) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Model/CakeSchema.php
Expand Up @@ -271,7 +271,7 @@ public function read($options = array()) {
unset($currentTables[$key]); unset($currentTables[$key]);
} }
if (!empty($Object->hasAndBelongsToMany)) { if (!empty($Object->hasAndBelongsToMany)) {
foreach ($Object->hasAndBelongsToMany as $Assoc => $assocData) { foreach ($Object->hasAndBelongsToMany as $assocData) {
if (isset($assocData['with'])) { if (isset($assocData['with'])) {
$class = $assocData['with']; $class = $assocData['with'];
} }
Expand Down Expand Up @@ -597,7 +597,7 @@ protected function _columns(&$Obj) {
$db = $Obj->getDataSource(); $db = $Obj->getDataSource();
$fields = $Obj->schema(true); $fields = $Obj->schema(true);


$columns = $props = array(); $columns = array();
foreach ($fields as $name => $value) { foreach ($fields as $name => $value) {
if ($Obj->primaryKey == $name) { if ($Obj->primaryKey == $name) {
$value['key'] = 'primary'; $value['key'] = 'primary';
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Model/Datasource/CakeSession.php
Expand Up @@ -449,7 +449,6 @@ public static function clear() {
*/ */
protected static function _configureSession() { protected static function _configureSession() {
$sessionConfig = Configure::read('Session'); $sessionConfig = Configure::read('Session');
$iniSet = function_exists('ini_set');


if (isset($sessionConfig['defaults'])) { if (isset($sessionConfig['defaults'])) {
$defaults = self::_defaultConfig($sessionConfig['defaults']); $defaults = self::_defaultConfig($sessionConfig['defaults']);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Postgres.php
Expand Up @@ -438,7 +438,7 @@ public function index($model) {
) )
AND c.oid = i.indrelid AND i.indexrelid = c2.oid AND c.oid = i.indrelid AND i.indexrelid = c2.oid
ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname", false); ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname", false);
foreach ($indexes as $i => $info) { foreach ($indexes as $info) {
$key = array_pop($info); $key = array_pop($info);
if ($key['indisprimary']) { if ($key['indisprimary']) {
$key['relname'] = 'PRIMARY'; $key['relname'] = 'PRIMARY';
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Sqlite.php
Expand Up @@ -474,7 +474,7 @@ public function index($model) {
if (is_bool($indexes)) { if (is_bool($indexes)) {
return array(); return array();
} }
foreach ($indexes as $i => $info) { foreach ($indexes as $info) {
$key = array_pop($info); $key = array_pop($info);
$keyInfo = $this->query('PRAGMA index_info("' . $key['name'] . '")'); $keyInfo = $this->query('PRAGMA index_info("' . $key['name'] . '")');
foreach ($keyInfo as $keyCol) { foreach ($keyInfo as $keyCol) {
Expand Down
12 changes: 6 additions & 6 deletions lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -1294,9 +1294,9 @@ public function queryAssociation(Model $model, &$linkModel, $type, $association,
} }
} }
if ($type === 'hasAndBelongsToMany') { if ($type === 'hasAndBelongsToMany') {
$uniqueIds = $merge = array(); $merge = array();


foreach ($fetch as $j => $data) { foreach ($fetch as $data) {
if (isset($data[$with]) && $data[$with][$foreignKey] === $row[$modelAlias][$modelPK]) { if (isset($data[$with]) && $data[$with][$foreignKey] === $row[$modelAlias][$modelPK]) {
if ($habtmFieldsCount <= 2) { if ($habtmFieldsCount <= 2) {
unset($data[$with]); unset($data[$with]);
Expand Down Expand Up @@ -1445,7 +1445,7 @@ protected function _mergeAssociation(&$data, &$merge, $association, $type, $self
$data[$association] = array(); $data[$association] = array();
} }
} else { } else {
foreach ($merge as $i => $row) { foreach ($merge as $row) {
$insert = array(); $insert = array();
if (count($row) === 1) { if (count($row) === 1) {
$insert = $row[$association]; $insert = $row[$association];
Expand Down Expand Up @@ -2413,7 +2413,7 @@ public function conditions($conditions, $quoteValues = true, $where = true, $mod
} }
$clauses = '/^WHERE\\x20|^GROUP\\x20BY\\x20|^HAVING\\x20|^ORDER\\x20BY\\x20/i'; $clauses = '/^WHERE\\x20|^GROUP\\x20BY\\x20|^HAVING\\x20|^ORDER\\x20BY\\x20/i';


if (preg_match($clauses, $conditions, $match)) { if (preg_match($clauses, $conditions)) {
$clause = ''; $clause = '';
} }
$conditions = $this->_quoteFields($conditions); $conditions = $this->_quoteFields($conditions);
Expand Down Expand Up @@ -2908,7 +2908,7 @@ public function insertMulti($table, $fields, $values) {
$columnMap[$key] = $pdoMap[$type]; $columnMap[$key] = $pdoMap[$type];
} }


foreach ($values as $row => $value) { foreach ($values as $value) {
$i = 1; $i = 1;
foreach ($value as $col => $val) { foreach ($value as $col => $val) {
$statement->bindValue($i, $val, $columnMap[$col]); $statement->bindValue($i, $val, $columnMap[$col]);
Expand Down Expand Up @@ -3205,7 +3205,7 @@ public function introspectType($value) {


$isAllFloat = $isAllInt = true; $isAllFloat = $isAllInt = true;
$containsFloat = $containsInt = $containsString = false; $containsFloat = $containsInt = $containsString = false;
foreach ($value as $key => $valElement) { foreach ($value as $valElement) {
$valElement = trim($valElement); $valElement = trim($valElement);
if (!is_float($valElement) && !preg_match('/^[\d]+\.[\d]+$/', $valElement)) { if (!is_float($valElement) && !preg_match('/^[\d]+\.[\d]+$/', $valElement)) {
$isAllFloat = false; $isAllFloat = false;
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Model/Model.php
Expand Up @@ -2363,7 +2363,7 @@ public function delete($id = null, $cascade = true) {


$updateCounterCache = false; $updateCounterCache = false;
if (!empty($this->belongsTo)) { if (!empty($this->belongsTo)) {
foreach ($this->belongsTo as $parent => $assoc) { foreach ($this->belongsTo as $assoc) {
if (!empty($assoc['counterCache'])) { if (!empty($assoc['counterCache'])) {
$updateCounterCache = true; $updateCounterCache = true;
break; break;
Expand Down Expand Up @@ -2449,7 +2449,7 @@ protected function _deleteDependent($id, $cascade) {
* @return void * @return void
*/ */
protected function _deleteLinks($id) { protected function _deleteLinks($id) {
foreach ($this->hasAndBelongsToMany as $assoc => $data) { foreach ($this->hasAndBelongsToMany as $data) {
list($plugin, $joinModel) = pluginSplit($data['with']); list($plugin, $joinModel) = pluginSplit($data['with']);
$records = $this->{$joinModel}->find('all', array( $records = $this->{$joinModel}->find('all', array(
'conditions' => array($this->{$joinModel}->escapeField($data['foreignKey']) => $id), 'conditions' => array($this->{$joinModel}->escapeField($data['foreignKey']) => $id),
Expand Down Expand Up @@ -3042,7 +3042,7 @@ public function invalidate($field, $value = true) {
public function isForeignKey($field) { public function isForeignKey($field) {
$foreignKeys = array(); $foreignKeys = array();
if (!empty($this->belongsTo)) { if (!empty($this->belongsTo)) {
foreach ($this->belongsTo as $assoc => $data) { foreach ($this->belongsTo as $data) {
$foreignKeys[] = $data['foreignKey']; $foreignKeys[] = $data['foreignKey'];
} }
} }
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeRequest.php
Expand Up @@ -675,7 +675,7 @@ public function subdomains($tldLength = 1) {
public function accepts($type = null) { public function accepts($type = null) {
$raw = $this->parseAccept(); $raw = $this->parseAccept();
$accept = array(); $accept = array();
foreach ($raw as $value => $types) { foreach ($raw as $types) {
$accept = array_merge($accept, $types); $accept = array_merge($accept, $types);
} }
if ($type === null) { if ($type === null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/ClassRegistry.php
Expand Up @@ -175,7 +175,7 @@ public static function init($class, $strict = false) {
} }


if (!isset($instance)) { if (!isset($instance)) {
trigger_error(__d('cake_dev', '(ClassRegistry::init() could not create instance of %1$s class %2$s ', $class, $type), E_USER_WARNING); trigger_error(__d('cake_dev', '(ClassRegistry::init() could not create instance of %s', $class), E_USER_WARNING);
return $false; return $false;
} }
} }
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Utility/Debugger.php
Expand Up @@ -213,7 +213,6 @@ public static function showError($code, $description, $file = null, $line = null
if (empty($line)) { if (empty($line)) {
$line = '??'; $line = '??';
} }
$path = self::trimPath($file);


$info = compact('code', 'description', 'file', 'line'); $info = compact('code', 'description', 'file', 'line');
if (!in_array($info, $self->errors)) { if (!in_array($info, $self->errors)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Folder.php
Expand Up @@ -367,7 +367,7 @@ public function chmod($path, $mode = false, $recursive = true, $exceptions = arr
$paths = $this->tree($path); $paths = $this->tree($path);


foreach ($paths as $type) { foreach ($paths as $type) {
foreach ($type as $key => $fullpath) { foreach ($type as $fullpath) {
$check = explode(DS, $fullpath); $check = explode(DS, $fullpath);
$count = count($check); $count = count($check);


Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Utility/Hash.php
Expand Up @@ -432,7 +432,6 @@ public static function contains(array $data, array $needle) {
} }
$stack = array(); $stack = array();


$i = 1;
while (!empty($needle)) { while (!empty($needle)) {
$key = key($needle); $key = key($needle);
$val = $needle[$key]; $val = $needle[$key];
Expand Down
3 changes: 1 addition & 2 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -194,7 +194,7 @@ protected function _introspectModel($model, $key, $field = null) {


if ($key === 'fields') { if ($key === 'fields') {
if (!isset($this->fieldset[$model]['fields'])) { if (!isset($this->fieldset[$model]['fields'])) {
$fields = $this->fieldset[$model]['fields'] = $object->schema(); $this->fieldset[$model]['fields'] = $object->schema();
foreach ($object->hasAndBelongsToMany as $alias => $assocData) { foreach ($object->hasAndBelongsToMany as $alias => $assocData) {
$this->fieldset[$object->alias]['fields'][$alias] = array('type' => 'multiple'); $this->fieldset[$object->alias]['fields'][$alias] = array('type' => 'multiple');
} }
Expand Down Expand Up @@ -320,7 +320,6 @@ public function create($model = null, $options = array()) {


$key = null; $key = null;
if ($model !== false) { if ($model !== false) {
$object = $this->_getModel($model);
$key = $this->_introspectModel($model, 'key'); $key = $this->_introspectModel($model, 'key');
$this->setEntity($model, true); $this->setEntity($model, true);
} }
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/View/Helper/MootoolsEngineHelper.php
Expand Up @@ -254,7 +254,6 @@ public function request($url, $options = array()) {
$options['url'] = $url; $options['url'] = $url;
$options = $this->_prepareCallbacks('request', $options); $options = $this->_prepareCallbacks('request', $options);
if (!empty($options['dataExpression'])) { if (!empty($options['dataExpression'])) {
$callbacks[] = 'data';
unset($options['dataExpression']); unset($options['dataExpression']);
} elseif (!empty($data)) { } elseif (!empty($data)) {
$data = $this->object($data); $data = $this->object($data);
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/View/Helper/PrototypeEngineHelper.php
Expand Up @@ -237,7 +237,6 @@ public function request($url, $options = array()) {
$url = '"' . $this->url($url) . '"'; $url = '"' . $this->url($url) . '"';
$options = $this->_mapOptions('request', $options); $options = $this->_mapOptions('request', $options);
$type = '.Request'; $type = '.Request';
$data = null;
if (isset($options['type']) && strtolower($options['type']) == 'json') { if (isset($options['type']) && strtolower($options['type']) == 'json') {
unset($options['type']); unset($options['type']);
} }
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/RssHelper.php
Expand Up @@ -341,7 +341,7 @@ public function elem($name, $attrib = array(), $content = null, $endTag = true)
$nodes->item(0)->setAttribute($key, $value); $nodes->item(0)->setAttribute($key, $value);
} }
} }
foreach ($children as $k => $child) { foreach ($children as $child) {
$child = $elem->createElement($name, $child); $child = $elem->createElement($name, $child);
$nodes->item(0)->appendChild($child); $nodes->item(0)->appendChild($child);
} }
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/View/Helper/TimeHelper.php
Expand Up @@ -358,7 +358,6 @@ public function toRSS($dateString, $timezone = null) {
*/ */
public function timeAgoInWords($dateTime, $options = array()) { public function timeAgoInWords($dateTime, $options = array()) {
$element = null; $element = null;
$stringDate = '';


if (is_array($options) && !empty($options['element'])) { if (is_array($options) && !empty($options['element'])) {
$element = array( $element = array(
Expand Down
2 changes: 0 additions & 2 deletions lib/Cake/View/MediaView.php
Expand Up @@ -101,8 +101,6 @@ public function render($view = null, $layout = null) {


if ($this->_isActive()) { if ($this->_isActive()) {
$extension = strtolower($extension); $extension = strtolower($extension);
$chunkSize = 8192;
$buffer = '';
$fileSize = @filesize($path); $fileSize = @filesize($path);
$handle = fopen($path, 'rb'); $handle = fopen($path, 'rb');


Expand Down
7 changes: 1 addition & 6 deletions lib/Cake/View/View.php
Expand Up @@ -289,11 +289,6 @@ class View extends Object {
*/ */
protected $_eventManager = null; protected $_eventManager = null;


/**
* The view file to be rendered, only used inside _execute()
*/
private $__viewFileName = null;

/** /**
* Whether the event manager was already configured for this object * Whether the event manager was already configured for this object
* *
Expand Down Expand Up @@ -856,7 +851,7 @@ public function __isset($name) {
*/ */
public function loadHelpers() { public function loadHelpers() {
$helpers = HelperCollection::normalizeObjectArray($this->helpers); $helpers = HelperCollection::normalizeObjectArray($this->helpers);
foreach ($helpers as $name => $properties) { foreach ($helpers as $properties) {
list($plugin, $class) = pluginSplit($properties['class']); list($plugin, $class) = pluginSplit($properties['class']);
$this->{$class} = $this->Helpers->load($properties['class'], $properties['settings']); $this->{$class} = $this->Helpers->load($properties['class'], $properties['settings']);
} }
Expand Down

0 comments on commit bc40ac7

Please sign in to comment.