Navigation Menu

Skip to content

Commit

Permalink
Cleanup - Unused local variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ndm2 committed Nov 8, 2014
1 parent e732f97 commit b087110
Show file tree
Hide file tree
Showing 32 changed files with 27 additions and 50 deletions.
1 change: 0 additions & 1 deletion src/Auth/DigestAuthenticate.php
Expand Up @@ -102,7 +102,6 @@ public function getUser(Request $request) {
return false;
}

list(, $model) = pluginSplit($this->_config['userModel']);
$user = $this->_findUser($digest['username']);
if (empty($user)) {
return false;
Expand Down
1 change: 0 additions & 1 deletion src/Cache/Engine/RedisEngine.php
Expand Up @@ -87,7 +87,6 @@ public function init(array $config = []) {
* @return bool True if Redis server was connected
*/
protected function _connect() {
$return = false;
try {
$this->_Redis = new \Redis();
if (!empty($this->settings['unix_socket'])) {
Expand Down
2 changes: 0 additions & 2 deletions src/Console/ConsoleIo.php
Expand Up @@ -269,8 +269,6 @@ public function styles($style = null, $definition = null) {
* @return mixed Either the default value, or the user-provided input.
*/
public function askChoice($prompt, $options, $default = null) {
$originalOptions = $options;

if ($options && is_string($options)) {
if (strpos($options, ',')) {
$options = explode(',', $options);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Component/AuthComponent.php
Expand Up @@ -721,7 +721,7 @@ public function identify() {
$result = $auth->authenticate($this->request, $this->response);
if (!empty($result) && is_array($result)) {
$this->_authenticationProvider = $auth;
$event = $this->dispatchEvent('Auth.afterIdentify', [$result]);
$this->dispatchEvent('Auth.afterIdentify', [$result]);
return $result;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -578,7 +578,6 @@ public function respondAs($type, array $options = array()) {
$options += $defaults;

$cType = $type;
$request = $this->request;
$response = $this->response;
if (strpos($type, '/') === false) {
$cType = $response->getMimeType($type);
Expand Down
4 changes: 1 addition & 3 deletions src/Core/ClassLoader.php
Expand Up @@ -103,9 +103,7 @@ protected function _loadMappedFile($prefix, $relativeClass) {
}

foreach ($this->_prefixes[$prefix] as $baseDir) {
$file = $baseDir .
str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass) . '.php';
$file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
$file = $baseDir . str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass) . '.php';

if ($this->_requireFile($file)) {
return $file;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/ObjectRegistry.php
Expand Up @@ -66,7 +66,7 @@ abstract class ObjectRegistry {
* @return mixed
*/
public function load($objectName, $config = []) {
list($plugin, $name) = pluginSplit($objectName);
list(, $name) = pluginSplit($objectName);
$loaded = isset($this->_loaded[$name]);
if ($loaded && !empty($config)) {
$this->_checkDuplicate($name, $config);
Expand Down Expand Up @@ -235,7 +235,7 @@ public function reset() {
* @return void
*/
public function set($objectName, $object) {
list($plugin, $name) = pluginSplit($objectName);
list(, $name) = pluginSplit($objectName);
$this->unload($objectName);
if (isset($this->_eventManager)) {
$this->eventManager()->attach($object);
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Connection.php
Expand Up @@ -258,7 +258,7 @@ public function compileQuery(Query $query, ValueBinder $generator) {
public function run(Query $query) {
$binder = $query->valueBinder();
$binder->resetCount();
list($query, $sql) = $this->driver()->compileQuery($query, $binder);
list(, $sql) = $this->driver()->compileQuery($query, $binder);

$statement = $this->prepare($sql);
$binder->attachTo($statement);
Expand Down
1 change: 0 additions & 1 deletion src/Event/EventManager.php
Expand Up @@ -280,7 +280,6 @@ protected function _callListener(callable $listener, Event $event) {
*/
public function listeners($eventKey) {
$localListeners = array();
$priorities = array();
if (!$this->_isGlobal) {
$localListeners = $this->prioritisedListeners($eventKey);
$localListeners = empty($localListeners) ? array() : $localListeners;
Expand Down
2 changes: 1 addition & 1 deletion src/I18n/Parser/MoFileParser.php
Expand Up @@ -85,7 +85,7 @@ public function parse($resource) {
$messages = [];

for ($i = 0; $i < $count; $i++) {
$singularId = $pluralId = null;
$pluralId = null;
$translated = null;

fseek($stream, $offsetId + $i * 8);
Expand Down
2 changes: 1 addition & 1 deletion src/I18n/Time.php
Expand Up @@ -286,7 +286,7 @@ public function timeAgoInWords(array $options = []) {
list($future['H'], $future['i'], $future['s'], $future['d'], $future['m'], $future['Y']) = explode('/', date('H/i/s/d/m/Y', $futureTime));

list($past['H'], $past['i'], $past['s'], $past['d'], $past['m'], $past['Y']) = explode('/', date('H/i/s/d/m/Y', $pastTime));
$years = $months = $weeks = $days = $hours = $minutes = $seconds = 0;
$weeks = $days = $hours = $minutes = $seconds = 0;

$years = $future['Y'] - $past['Y'];
$months = $future['m'] + ((12 * $years) - $past['m']);
Expand Down
1 change: 0 additions & 1 deletion src/Model/Behavior/TranslateBehavior.php
Expand Up @@ -294,7 +294,6 @@ public function findTranslations(Query $query, array $options) {
*/
protected function _rowMapper($results, $locale) {
return $results->map(function ($row) use ($locale) {
$options = ['setter' => false, 'guard' => false];
$hydrated = !is_array($row);

foreach ($this->_config['fields'] as $field) {
Expand Down
7 changes: 1 addition & 6 deletions src/Model/Behavior/TreeBehavior.php
Expand Up @@ -290,12 +290,7 @@ function ($field) use ($alias) {
public function childCount(Entity $node, $direct = false) {
$config = $this->config();
$alias = $this->_table->alias();
list($parent, $left, $right) = array_map(
function ($field) use ($alias) {
return "$alias.$field";
},
[$config['parent'], $config['left'], $config['right']]
);
$parent = $alias . '.' . $config['parent'];

if ($direct) {
return $this->_scope($this->_table->find())
Expand Down
4 changes: 2 additions & 2 deletions src/Network/Email/Email.php
Expand Up @@ -1769,8 +1769,8 @@ protected function _renderTemplates($content) {

$View->loadHelpers();

list($templatePlugin, $template) = pluginSplit($this->_template);
list($layoutPlugin, $layout) = pluginSplit($this->_layout);
list($templatePlugin) = pluginSplit($this->_template);
list($layoutPlugin) = pluginSplit($this->_layout);
if ($templatePlugin) {
$View->plugin = $templatePlugin;
} elseif ($layoutPlugin) {
Expand Down
1 change: 0 additions & 1 deletion src/Network/Socket.php
Expand Up @@ -361,7 +361,6 @@ public function enableCrypto($type, $clientOrServer = 'client', $enable = true)
if (!array_key_exists($type . '_' . $clientOrServer, $this->_encryptMethods)) {
throw new \InvalidArgumentException('Invalid encryption scheme chosen');
}
$enableCryptoResult = false;
try {
$enableCryptoResult = stream_socket_enable_crypto($this->connection, $enable, $this->_encryptMethods[$type . '_' . $clientOrServer]);
} catch (\Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Association.php
Expand Up @@ -358,7 +358,7 @@ public function property($name = null) {
$this->_propertyName = $name;
}
if ($name === null && !$this->_propertyName) {
list($plugin, $name) = pluginSplit($this->_name);
list(, $name) = pluginSplit($this->_name);
$this->_propertyName = Inflector::underscore($name);
}
return $this->_propertyName;
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Association/BelongsTo.php
Expand Up @@ -74,7 +74,7 @@ public function property($name = null) {
return parent::property($name);
}
if ($name === null && !$this->_propertyName) {
list($plugin, $name) = pluginSplit($this->_name);
list(, $name) = pluginSplit($this->_name);
$this->_propertyName = Inflector::underscore(Inflector::singularize($name));
}
return $this->_propertyName;
Expand Down
1 change: 0 additions & 1 deletion src/ORM/Association/BelongsToMany.php
Expand Up @@ -696,7 +696,6 @@ function () use ($sourceEntity, $targetEntities, $primaryValue, $options) {
return false;
}

$inserted = [];
$property = $this->property();

if (count($inserts)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Association/HasOne.php
Expand Up @@ -62,7 +62,7 @@ public function property($name = null) {
return parent::property($name);
}
if ($name === null && !$this->_propertyName) {
list($plugin, $name) = pluginSplit($this->_name);
list(, $name) = pluginSplit($this->_name);
$this->_propertyName = Inflector::underscore(Inflector::singularize($name));
}
return $this->_propertyName;
Expand Down
4 changes: 2 additions & 2 deletions src/ORM/AssociationCollection.php
Expand Up @@ -47,7 +47,7 @@ class AssociationCollection {
* @return Association The association object being added.
*/
public function add($alias, Association $association) {
list($plugin, $alias) = pluginSplit($alias);
list(, $alias) = pluginSplit($alias);
return $this->_items[strtolower($alias)] = $association;
}

Expand Down Expand Up @@ -107,7 +107,7 @@ public function keys() {
*/
public function type($class) {
$out = array_filter($this->_items, function ($assoc) use ($class) {
list($ns, $name) = namespaceSplit(get_class($assoc));
list(, $name) = namespaceSplit(get_class($assoc));
return $class === $name;
});
return array_values($out);
Expand Down
4 changes: 2 additions & 2 deletions src/ORM/TableRegistry.php
Expand Up @@ -152,7 +152,7 @@ public static function config($alias = null, $options = null) {
* @throws RuntimeException When you try to configure an alias that already exists.
*/
public static function get($name, array $options = []) {
list($plugin, $alias) = pluginSplit($name);
list(, $alias) = pluginSplit($name);
$exists = isset(static::$_instances[$alias]);

if ($exists && !empty($options)) {
Expand Down Expand Up @@ -202,7 +202,7 @@ public static function get($name, array $options = []) {
* @return bool
*/
public static function exists($alias) {
list($plugin, $alias) = pluginSplit($alias);
list(, $alias) = pluginSplit($alias);
return isset(static::$_instances[$alias]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Routing/DispatcherFilter.php
Expand Up @@ -136,7 +136,7 @@ public function implementedEvents() {
*/
public function handle(Event $event) {
$name = $event->name();
list($unused, $method) = explode('.', $name);
list(, $method) = explode('.', $name);
if (empty($this->_config['for']) && empty($this->_config['when'])) {
return $this->{$method}($event);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Shell/BakeShell.php
Expand Up @@ -80,7 +80,7 @@ public function main() {
$this->out('<info>Available bake commands:</info>', 2);
$this->out('- all');
foreach ($this->tasks as $task) {
list($p, $name) = pluginSplit($task);
list(, $name) = pluginSplit($task);
$this->out('- ' . Inflector::underscore($name));
}
$this->out('');
Expand Down Expand Up @@ -133,7 +133,7 @@ protected function _findTasks($tasks, $path, $namespace, $prefix = null) {
$candidates = $this->_findClassFiles($path, $namespace);
$classes = $this->_findTaskClasses($candidates);
foreach ($classes as $class) {
list($ns, $name) = namespaceSplit($class);
list(, $name) = namespaceSplit($class);
$name = substr($name, 0, -4);
$fullName = ($prefix ? $prefix . '.' : '') . $name;
$tasks[$name] = $fullName;
Expand Down
1 change: 0 additions & 1 deletion src/Shell/Task/BakeTask.php
Expand Up @@ -128,7 +128,6 @@ public function callProcess($command) {
$this->error('Could not start subprocess.');
return false;
}
$output = $error = '';
fclose($pipes[0]);

$output = stream_get_contents($pipes[1]);
Expand Down
2 changes: 0 additions & 2 deletions src/Shell/Task/ModelTask.php
Expand Up @@ -225,7 +225,6 @@ public function findBelongsTo($model, array $associations) {
continue;
}

$assoc = false;
if ($fieldName === 'parent_id') {
$className = ($this->plugin) ? $this->plugin . '.' . $model->alias() : $model->alias();
$assoc = [
Expand Down Expand Up @@ -686,7 +685,6 @@ public function listAll() {
* does not have a schemaCollection method.
*/
protected function _getAllTables() {
$tables = [];
$db = ConnectionManager::get($this->connection);
if (!method_exists($db, 'schemaCollection')) {
$this->err(
Expand Down
6 changes: 3 additions & 3 deletions src/Shell/Task/TestTask.php
Expand Up @@ -155,7 +155,7 @@ protected function _getClassOptions($namespace) {
}
$path = $base . str_replace('\\', DS, $namespace);
$folder = new Folder($path);
list($dirs, $files) = $folder->read();
list(, $files) = $folder->read();
foreach ($files as $file) {
$classes[] = str_replace('.php', '', $file);
}
Expand Down Expand Up @@ -235,7 +235,7 @@ public function typeCanDetectFixtures($type) {
*/
public function buildTestSubject($type, $class) {
if (strtolower($type) === 'table') {
list($namespace, $name) = namespaceSplit($class);
list(, $name) = namespaceSplit($class);
$name = str_replace('Table', '', $name);
if ($this->plugin) {
$name = $this->plugin . '.' . $name;
Expand Down Expand Up @@ -419,7 +419,7 @@ public function hasMockClass($type) {
* @return array Constructor snippets for the thing you are building.
*/
public function generateConstructor($type, $fullClassName) {
list($namespace, $className) = namespaceSplit($fullClassName);
list(, $className) = namespaceSplit($fullClassName);
$type = strtolower($type);
$pre = $construct = $post = '';
if ($type === 'table') {
Expand Down
1 change: 0 additions & 1 deletion src/TestSuite/Fixture/FixtureManager.php
Expand Up @@ -222,7 +222,6 @@ public function load($test) {
return;
}

$dbs = $this->_fixtureConnections($fixtures);
try {
$createTables = function ($db, $fixtures) use ($test) {
$tables = $db->schemaCollection()->listTables();
Expand Down
3 changes: 1 addition & 2 deletions src/TestSuite/Fixture/TestFixture.php
Expand Up @@ -90,7 +90,6 @@ class TestFixture {
* @throws \Cake\Core\Exception\Exception on invalid datasource usage.
*/
public function __construct() {
$connection = 'test';
if (!empty($this->connection)) {
$connection = $this->connection;
if (strpos($connection, 'test') !== 0) {
Expand All @@ -113,7 +112,7 @@ public function __construct() {
*/
public function init() {
if ($this->table === null) {
list($namespace, $class) = namespaceSplit(get_class($this));
list(, $class) = namespaceSplit(get_class($this));
preg_match('/^(.*)Fixture$/', $class, $matches);
$table = $class;
if (isset($matches[1])) {
Expand Down
2 changes: 1 addition & 1 deletion src/TestSuite/TestCase.php
Expand Up @@ -563,7 +563,7 @@ public function getMockForModel($alias, array $methods = array(), array $options
$connectionName = $options['className']::defaultConnectionName();
$connection = ConnectionManager::get($connectionName);

list($plugin, $baseClass) = pluginSplit($alias);
list(, $baseClass) = pluginSplit($alias);
$options += ['alias' => $baseClass, 'connection' => $connection];
$options += TableRegistry::config($alias);

Expand Down
2 changes: 1 addition & 1 deletion src/View/CellTrait.php
Expand Up @@ -64,7 +64,7 @@ public function cell($cell, array $data = [], array $options = []) {
list($pluginAndCell, $action) = [$parts[0], 'display'];
}

list($plugin, $cellName) = pluginSplit($pluginAndCell);
list($plugin) = pluginSplit($pluginAndCell);
$className = App::className($pluginAndCell, 'View/Cell', 'Cell');

if (!$className) {
Expand Down
2 changes: 1 addition & 1 deletion src/View/Form/EntityContext.php
Expand Up @@ -125,7 +125,7 @@ protected function _prepare() {
$table = $entity->source();
}
if (!$table && $isEntity && get_class($entity) !== 'Cake\ORM\Entity') {
list($ns, $entityClass) = namespaceSplit(get_class($entity));
list(, $entityClass) = namespaceSplit(get_class($entity));
$table = Inflector::pluralize($entityClass);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/View/View.php
Expand Up @@ -361,8 +361,6 @@ public function initialize() {
* is false.
*/
public function element($name, array $data = array(), array $options = array()) {
$file = $plugin = null;

if (!isset($options['callbacks'])) {
$options['callbacks'] = false;
}
Expand Down

0 comments on commit b087110

Please sign in to comment.