Skip to content

Commit

Permalink
Various improvments to the CakePH Plib files
Browse files Browse the repository at this point in the history
Mostly CS, doc blocks and explicit returning nulls.
  • Loading branch information
ravage84 committed Sep 25, 2015
1 parent 355eb18 commit e690662
Show file tree
Hide file tree
Showing 55 changed files with 123 additions and 120 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/AclShell.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ public function parseIdentifier($identifier) {
* or an array of properties to use in AcoNode::node() * or an array of properties to use in AcoNode::node()
* *
* @param string $class Class type you want (Aro/Aco) * @param string $class Class type you want (Aro/Aco)
* @param string|array $identifier A mixed identifier for finding the node. * @param string|array|null $identifier A mixed identifier for finding the node, otherwise null.
* @return int Integer of NodeId. Will trigger an error if nothing is found. * @return int Integer of NodeId. Will trigger an error if nothing is found.
*/ */
protected function _getNodeId($class, $identifier) { protected function _getNodeId($class, $identifier) {
Expand All @@ -568,7 +568,7 @@ protected function _getNodeId($class, $identifier) {
$identifier = var_export($identifier, true); $identifier = var_export($identifier, true);
} }
$this->error(__d('cake_console', 'Could not find node using reference "%s"', $identifier)); $this->error(__d('cake_console', 'Could not find node using reference "%s"', $identifier));
return; return null;
} }
return Hash::get($node, "0.{$class}.id"); return Hash::get($node, "0.{$class}.id");
} }
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/Task/FixtureTask.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function importOptions($modelName) {
* @param string $model Name of model to bake. * @param string $model Name of model to bake.
* @param string $useTable Name of table to use. * @param string $useTable Name of table to use.
* @param array $importOptions Options for public $import * @param array $importOptions Options for public $import
* @return string Baked fixture content * @return string|null Baked fixture content, otherwise null.
*/ */
public function bake($model, $useTable = false, $importOptions = array()) { public function bake($model, $useTable = false, $importOptions = array()) {
App::uses('CakeSchema', 'Model'); App::uses('CakeSchema', 'Model');
Expand Down Expand Up @@ -243,7 +243,7 @@ public function bake($model, $useTable = false, $importOptions = array()) {
$data = $this->_Schema->read(array('models' => false, 'connection' => $this->connection)); $data = $this->_Schema->read(array('models' => false, 'connection' => $this->connection));
if (!isset($data['tables'][$useTable])) { if (!isset($data['tables'][$useTable])) {
$this->err("<warning>Warning:</warning> Could not find the '${useTable}' table for ${model}."); $this->err("<warning>Warning:</warning> Could not find the '${useTable}' table for ${model}.");
return; return null;
} }


$tableInfo = $data['tables'][$useTable]; $tableInfo = $data['tables'][$useTable];
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/ViewTask.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function execute() {
$this->_interactive(); $this->_interactive();
} }
if (empty($this->args[0])) { if (empty($this->args[0])) {
return; return null;
} }
if (!isset($this->connection)) { if (!isset($this->connection)) {
$this->connection = 'default'; $this->connection = 'default';
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/TestShell.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ public function initialize() {
/** /**
* Parse the CLI options into an array CakeTestDispatcher can use. * Parse the CLI options into an array CakeTestDispatcher can use.
* *
* @return array Array of params for CakeTestDispatcher * @return array|null Array of params for CakeTestDispatcher or null.
*/ */
protected function _parseArgs() { protected function _parseArgs() {
if (empty($this->args)) { if (empty($this->args)) {
return; return null;
} }
$params = array( $params = array(
'core' => false, 'core' => false,
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Templates/default/classes/model.ctp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ foreach ($associations as $assoc):
if (!empty($assoc)): if (!empty($assoc)):
?> ?>


//The Associations below have been created with all possible keys, those that are not needed can be removed // The Associations below have been created with all possible keys, those that are not needed can be removed
<?php <?php
break; break;
endif; endif;
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Console/Templates/default/views/view.ctp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ echo "\t<?php endforeach; ?>\n";
</ul> </ul>
</div> </div>
</div> </div>
<?php endforeach; ?> <?php
endforeach;
1 change: 0 additions & 1 deletion lib/Cake/Controller/Component/Acl/DbAcl.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class DbAcl extends Object implements AclInterface {


/** /**
* Constructor * Constructor
*
*/ */
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
Expand Down
2 changes: 0 additions & 2 deletions lib/Cake/Controller/Component/Acl/PhpAcl.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ public function check($aro, $aco, $action = "*") {


/** /**
* Access Control Object * Access Control Object
*
*/ */
class PhpAco { class PhpAco {


Expand Down Expand Up @@ -361,7 +360,6 @@ public function build(array $allow, array $deny = array()) {


/** /**
* Access Request Object * Access Request Object
*
*/ */
class PhpAro { class PhpAro {


Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Controller/Component/AclComponent.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
* Will call the initialize method on the adapter if setting a new one. * Will call the initialize method on the adapter if setting a new one.
* *
* @param AclInterface|string $adapter Instance of AclInterface or a string name of the class to use. (optional) * @param AclInterface|string $adapter Instance of AclInterface or a string name of the class to use. (optional)
* @return AclInterface|void either null, or the adapter implementation. * @return AclInterface|null Either null, or the adapter implementation.
* @throws CakeException when the given class is not an instance of AclInterface * @throws CakeException when the given class is not an instance of AclInterface
*/ */
public function adapter($adapter = null) { public function adapter($adapter = null) {
Expand All @@ -92,7 +92,7 @@ public function adapter($adapter = null) {
} }
$this->_Instance = $adapter; $this->_Instance = $adapter;
$this->_Instance->initialize($this); $this->_Instance->initialize($this);
return; return null;
} }
return $this->_Instance; return $this->_Instance;
} }
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Controller/Component/AuthComponent.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public function isAuthorized($user = null, CakeRequest $request = null) {
*/ */
public function constructAuthorize() { public function constructAuthorize() {
if (empty($this->authorize)) { if (empty($this->authorize)) {
return; return null;
} }
$this->_authorizeObjects = array(); $this->_authorizeObjects = array();
$config = Hash::normalize((array)$this->authorize); $config = Hash::normalize((array)$this->authorize);
Expand Down Expand Up @@ -772,12 +772,12 @@ public function identify(CakeRequest $request, CakeResponse $response) {
/** /**
* Loads the configured authentication objects. * Loads the configured authentication objects.
* *
* @return mixed either null on empty authenticate value, or an array of loaded objects. * @return mixed Either null on empty authenticate value, or an array of loaded objects.
* @throws CakeException * @throws CakeException
*/ */
public function constructAuthenticate() { public function constructAuthenticate() {
if (empty($this->authenticate)) { if (empty($this->authenticate)) {
return; return null;
} }
$this->_authenticateObjects = array(); $this->_authenticateObjects = array();
$config = Hash::normalize((array)$this->authenticate); $config = Hash::normalize((array)$this->authenticate);
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Controller/Component/CookieComponent.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
* *
* @package Cake.Controller.Component * @package Cake.Controller.Component
* @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html * @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html
*
*/ */
class CookieComponent extends Component { class CookieComponent extends Component {


Expand Down
3 changes: 1 addition & 2 deletions lib/Cake/Controller/Component/RequestHandlerComponent.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* *
* @package Cake.Controller.Component * @package Cake.Controller.Component
* @link http://book.cakephp.org/2.0/en/core-libraries/components/request-handling.html * @link http://book.cakephp.org/2.0/en/core-libraries/components/request-handling.html
*
*/ */
class RequestHandlerComponent extends Component { class RequestHandlerComponent extends Component {


Expand Down Expand Up @@ -280,7 +279,7 @@ public function beforeRedirect(Controller $controller, $url, $status = null, $ex
* "304 Not Modified" header. * "304 Not Modified" header.
* *
* @param Controller $controller Controller instance. * @param Controller $controller Controller instance.
* @return bool false if the render process should be aborted * @return bool False if the render process should be aborted.
*/ */
public function beforeRender(Controller $controller) { public function beforeRender(Controller $controller) {
if ($this->settings['checkHttpCache'] && $this->response->checkNotModified($this->request)) { if ($this->settings['checkHttpCache'] && $this->response->checkNotModified($this->request)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/SessionComponent.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SessionComponent extends Component {
* Get / Set the userAgent * Get / Set the userAgent
* *
* @param string $userAgent Set the userAgent * @param string $userAgent Set the userAgent
* @return void * @return string Current user agent.
*/ */
public function userAgent($userAgent = null) { public function userAgent($userAgent = null) {
return CakeSession::userAgent($userAgent); return CakeSession::userAgent($userAgent);
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Core/Object.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Object {


/** /**
* Constructor, no-op * Constructor, no-op
*
*/ */
public function __construct() { public function __construct() {
} }
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Event/CakeEvent.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class CakeEvent {
* $event = new CakeEvent('Order.afterBuy', $this, array('buyer' => $userData)); * $event = new CakeEvent('Order.afterBuy', $this, array('buyer' => $userData));
* $event = new CakeEvent('User.afterRegister', $UserModel); * $event = new CakeEvent('User.afterRegister', $UserModel);
* ``` * ```
*
*/ */
public function __construct($name, $subject = null, $data = null) { public function __construct($name, $subject = null, $data = null) {
$this->_name = $name; $this->_name = $name;
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Event/CakeEventManager.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ public function detach($callable, $eventKey = null) {
foreach (array_keys($this->_listeners) as $eventKey) { foreach (array_keys($this->_listeners) as $eventKey) {
$this->detach($callable, $eventKey); $this->detach($callable, $eventKey);
} }
return; return null;
} }
if (empty($this->_listeners[$eventKey])) { if (empty($this->_listeners[$eventKey])) {
return; return null;
} }
foreach ($this->_listeners[$eventKey] as $priority => $callables) { foreach ($this->_listeners[$eventKey] as $priority => $callables) {
foreach ($callables as $k => $callback) { foreach ($callables as $k => $callback) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Log/Engine/FileLog.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected function _rotateFile($filename) {
if (!file_exists($filepath) || if (!file_exists($filepath) ||
filesize($filepath) < $this->_size filesize($filepath) < $this->_size
) { ) {
return; return null;
} }


if ($this->_config['rotate'] === 0) { if ($this->_config['rotate'] === 0) {
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Model/AclNode.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class AclNode extends Model {


/** /**
* Constructor * Constructor
*
*/ */
public function __construct() { public function __construct() {
$config = Configure::read('Acl.database'); $config = Configure::read('Acl.database');
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/CakeSession.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ protected static function _validAgentAndTime() {
* Get / Set the user agent * Get / Set the user agent
* *
* @param string|null $userAgent Set the user agent * @param string|null $userAgent Set the user agent
* @return string Current user agent * @return string Current user agent.
*/ */
public static function userAgent($userAgent = null) { public static function userAgent($userAgent = null) {
if ($userAgent) { if ($userAgent) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Model/Datasource/DboSource.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ public function queryAssociation(Model $Model, Model $LinkModel, $type, $associa


$queryTemplate = $this->generateAssociationQuery($Model, $LinkModel, $type, $association, $assocData, $queryData, $external); $queryTemplate = $this->generateAssociationQuery($Model, $LinkModel, $type, $association, $assocData, $queryData, $external);
if (empty($queryTemplate)) { if (empty($queryTemplate)) {
return; return null;
} }


if (!is_array($resultSet)) { if (!is_array($resultSet)) {
Expand Down Expand Up @@ -1952,7 +1952,7 @@ public function renderJoinStatement($data) {
* *
* @param string $type type of query being run. e.g select, create, update, delete, schema, alter. * @param string $type type of query being run. e.g select, create, update, delete, schema, alter.
* @param array $data Array of data to insert into the query. * @param array $data Array of data to insert into the query.
* @return string Rendered SQL expression to be run. * @return string|null Rendered SQL expression to be run, otherwise null.
*/ */
public function renderStatement($type, $data) { public function renderStatement($type, $data) {
extract($data); extract($data);
Expand Down Expand Up @@ -1986,7 +1986,7 @@ public function renderStatement($type, $data) {
} }
return "CREATE TABLE {$table} (\n{$columns}{$indexes}) {$tableParameters};"; return "CREATE TABLE {$table} (\n{$columns}{$indexes}) {$tableParameters};";
case 'alter': case 'alter':
return; return null;
} }
} }


Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Model/Datasource/Session/DatabaseSession.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
/** /**
* Constructor. Looks at Session configuration information and * Constructor. Looks at Session configuration information and
* sets up the session model. * sets up the session model.
*
*/ */
public function __construct() { public function __construct() {
$modelName = Configure::read('Session.handler.model'); $modelName = Configure::read('Session.handler.model');
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Model/Model.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1190,12 +1190,12 @@ public function setSource($tableName) {
* *
* @param string|array|SimpleXmlElement|DomNode $one Array or string of data * @param string|array|SimpleXmlElement|DomNode $one Array or string of data
* @param string $two Value string for the alternative indata method * @param string $two Value string for the alternative indata method
* @return array Data with all of $one's keys and values * @return array|null Data with all of $one's keys and values, otherwise null.
* @link http://book.cakephp.org/2.0/en/models/saving-your-data.html * @link http://book.cakephp.org/2.0/en/models/saving-your-data.html
*/ */
public function set($one, $two = null) { public function set($one, $two = null) {
if (!$one) { if (!$one) {
return; return null;
} }


if (is_object($one)) { if (is_object($one)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeResponse.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ protected function _setCookies() {


/** /**
* Formats the Content-Type header based on the configured contentType and charset * Formats the Content-Type header based on the configured contentType and charset
* the charset will only be set in the header if the response is of type text/* * the charset will only be set in the header if the response is of type text
* *
* @return void * @return void
*/ */
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeSocket.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ protected function _connectionErrorHandler($code, $message) {
*/ */
public function context() { public function context() {
if (!$this->connection) { if (!$this->connection) {
return; return null;
} }
return stream_context_get_options($this->connection); return stream_context_get_options($this->connection);
} }
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Dispatcher.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function dispatch(CakeRequest $request, CakeResponse $response, $addition
return $beforeEvent->result->body(); return $beforeEvent->result->body();
} }
$beforeEvent->result->send(); $beforeEvent->result->send();
return; return null;
} }


$controller = $this->_getController($request, $response); $controller = $this->_getController($request, $response);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Filter/AssetDispatcher.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AssetDispatcher extends DispatcherFilter {
public function beforeDispatch(CakeEvent $event) { public function beforeDispatch(CakeEvent $event) {
$url = urldecode($event->data['request']->url); $url = urldecode($event->data['request']->url);
if (strpos($url, '..') !== false || strpos($url, '.') === false) { if (strpos($url, '..') !== false || strpos($url, '.') === false) {
return; return null;
} }


if ($result = $this->_filterAsset($event)) { if ($result = $this->_filterAsset($event)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Filter/CacheDispatcher.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CacheDispatcher extends DispatcherFilter {
*/ */
public function beforeDispatch(CakeEvent $event) { public function beforeDispatch(CakeEvent $event) {
if (Configure::read('Cache.check') !== true) { if (Configure::read('Cache.check') !== true) {
return; return null;
} }


$path = $event->data['request']->here(); $path = $event->data['request']->here();
Expand Down
7 changes: 3 additions & 4 deletions lib/Cake/Utility/Debugger.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class Debugger {


/** /**
* Constructor. * Constructor.
*
*/ */
public function __construct() { public function __construct() {
$docRef = ini_get('docref_root'); $docRef = ini_get('docref_root');
Expand Down Expand Up @@ -200,7 +199,7 @@ public static function log($var, $level = LOG_DEBUG, $depth = 3) {
* @param string $file File on which error occurred * @param string $file File on which error occurred
* @param int $line Line that triggered the error * @param int $line Line that triggered the error
* @param array $context Context * @param array $context Context
* @return bool true if error was handled * @return bool|null True if error was handled, otherwise null.
* @deprecated 3.0.0 Will be removed in 3.0. This function is superseded by Debugger::outputError(). * @deprecated 3.0.0 Will be removed in 3.0. This function is superseded by Debugger::outputError().
*/ */
public static function showError($code, $description, $file = null, $line = null, $context = null) { public static function showError($code, $description, $file = null, $line = null, $context = null) {
Expand All @@ -217,7 +216,7 @@ public static function showError($code, $description, $file = null, $line = null
if (!in_array($info, $self->errors)) { if (!in_array($info, $self->errors)) {
$self->errors[] = $info; $self->errors[] = $info;
} else { } else {
return; return null;
} }


switch ($code) { switch ($code) {
Expand Down Expand Up @@ -247,7 +246,7 @@ public static function showError($code, $description, $file = null, $line = null
$level = LOG_NOTICE; $level = LOG_NOTICE;
break; break;
default: default:
return; return null;
} }


$data = compact( $data = compact(
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Hash.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public static function format(array $data, array $paths, $format) {
$count = count($paths); $count = count($paths);


if (!$count) { if (!$count) {
return; return null;
} }


for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Utility/Set.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ public static function enum($select, $list = null) {
* @param array $data Source array from which to extract the data * @param array $data Source array from which to extract the data
* @param string $format Format string into which values will be inserted, see sprintf() * @param string $format Format string into which values will be inserted, see sprintf()
* @param array $keys An array containing one or more Set::extract()-style key paths * @param array $keys An array containing one or more Set::extract()-style key paths
* @return array An array of strings extracted from $keys and formatted with $format * @return array|null An array of strings extracted from $keys and formatted with $format, otherwise null.
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::format * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::format
*/ */
public static function format($data, $format, $keys) { public static function format($data, $format, $keys) {
$extracted = array(); $extracted = array();
$count = count($keys); $count = count($keys);


if (!$count) { if (!$count) {
return; return null;
} }


for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/View/Errors/fatal_error.ctp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@
if (extension_loaded('xdebug')) { if (extension_loaded('xdebug')) {
xdebug_print_function_stack(); xdebug_print_function_stack();
} }
?>
3 changes: 2 additions & 1 deletion lib/Cake/View/Errors/missing_action.ctp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ class <?php echo h($controller); ?> extends AppController {
<strong><?php echo __d('cake_dev', 'Notice'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Notice'); ?>: </strong>
<?php echo __d('cake_dev', 'If you want to customize this error message, create %s', APP_DIR . DS . 'View' . DS . 'Errors' . DS . 'missing_action.ctp'); ?> <?php echo __d('cake_dev', 'If you want to customize this error message, create %s', APP_DIR . DS . 'View' . DS . 'Errors' . DS . 'missing_action.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php
echo $this->element('exception_stack_trace');
Loading

0 comments on commit e690662

Please sign in to comment.