Skip to content
Permalink
Browse files

Various improvments to the CakePH Plib files

Mostly CS, doc blocks and explicit returning nulls.
  • Loading branch information...
ravage84 committed Sep 25, 2015
1 parent 355eb18 commit e690662f0e26df0f46cb846504f2ebcf23447643
Showing with 123 additions and 120 deletions.
  1. +2 −2 lib/Cake/Console/Command/AclShell.php
  2. +2 −2 lib/Cake/Console/Command/Task/FixtureTask.php
  3. +1 −1 lib/Cake/Console/Command/Task/ViewTask.php
  4. +2 −2 lib/Cake/Console/Command/TestShell.php
  5. +1 −1 lib/Cake/Console/Templates/default/classes/model.ctp
  6. +2 −1 lib/Cake/Console/Templates/default/views/view.ctp
  7. +0 −1 lib/Cake/Controller/Component/Acl/DbAcl.php
  8. +0 −2 lib/Cake/Controller/Component/Acl/PhpAcl.php
  9. +2 −2 lib/Cake/Controller/Component/AclComponent.php
  10. +3 −3 lib/Cake/Controller/Component/AuthComponent.php
  11. +0 −1 lib/Cake/Controller/Component/CookieComponent.php
  12. +1 −2 lib/Cake/Controller/Component/RequestHandlerComponent.php
  13. +1 −1 lib/Cake/Controller/Component/SessionComponent.php
  14. +0 −1 lib/Cake/Core/Object.php
  15. +0 −1 lib/Cake/Event/CakeEvent.php
  16. +2 −2 lib/Cake/Event/CakeEventManager.php
  17. +1 −1 lib/Cake/Log/Engine/FileLog.php
  18. +0 −1 lib/Cake/Model/AclNode.php
  19. +1 −1 lib/Cake/Model/Datasource/CakeSession.php
  20. +3 −3 lib/Cake/Model/Datasource/DboSource.php
  21. +0 −1 lib/Cake/Model/Datasource/Session/DatabaseSession.php
  22. +2 −2 lib/Cake/Model/Model.php
  23. +1 −1 lib/Cake/Network/CakeResponse.php
  24. +1 −1 lib/Cake/Network/CakeSocket.php
  25. +1 −1 lib/Cake/Routing/Dispatcher.php
  26. +1 −1 lib/Cake/Routing/Filter/AssetDispatcher.php
  27. +1 −1 lib/Cake/Routing/Filter/CacheDispatcher.php
  28. +3 −4 lib/Cake/Utility/Debugger.php
  29. +1 −1 lib/Cake/Utility/Hash.php
  30. +2 −2 lib/Cake/Utility/Set.php
  31. +0 −1 lib/Cake/View/Errors/fatal_error.ctp
  32. +2 −1 lib/Cake/View/Errors/missing_action.ctp
  33. +2 −1 lib/Cake/View/Errors/missing_behavior.ctp
  34. +2 −1 lib/Cake/View/Errors/missing_component.ctp
  35. +2 −1 lib/Cake/View/Errors/missing_controller.ctp
  36. +2 −1 lib/Cake/View/Errors/missing_database.ctp
  37. +3 −2 lib/Cake/View/Errors/missing_datasource.ctp
  38. +2 −1 lib/Cake/View/Errors/missing_datasource_config.ctp
  39. +2 −1 lib/Cake/View/Errors/missing_helper.ctp
  40. +2 −1 lib/Cake/View/Errors/missing_layout.ctp
  41. +2 −1 lib/Cake/View/Errors/missing_plugin.ctp
  42. +3 −2 lib/Cake/View/Errors/missing_table.ctp
  43. +2 −1 lib/Cake/View/Errors/missing_view.ctp
  44. +2 −1 lib/Cake/View/Errors/pdo_error.ctp
  45. +2 −1 lib/Cake/View/Errors/private_action.ctp
  46. +1 −2 lib/Cake/View/Errors/scaffold_error.ctp
  47. +3 −3 lib/Cake/View/Helper/CacheHelper.php
  48. +1 −1 lib/Cake/View/Helper/FlashHelper.php
  49. +3 −3 lib/Cake/View/Helper/FormHelper.php
  50. +1 −1 lib/Cake/View/Helper/HtmlHelper.php
  51. +6 −6 lib/Cake/View/Scaffolds/form.ctp
  52. +11 −11 lib/Cake/View/Scaffolds/index.ctp
  53. +2 −2 lib/Cake/View/Scaffolds/view.ctp
  54. +1 −1 lib/Cake/View/View.php
  55. +27 −27 lib/Cake/basics.php
@@ -558,7 +558,7 @@ public function parseIdentifier($identifier) {
* or an array of properties to use in AcoNode::node()
*
* @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.
*/
protected function _getNodeId($class, $identifier) {
@@ -568,7 +568,7 @@ protected function _getNodeId($class, $identifier) {
$identifier = var_export($identifier, true);
}
$this->error(__d('cake_console', 'Could not find node using reference "%s"', $identifier));
return;
return null;
}
return Hash::get($node, "0.{$class}.id");
}
@@ -210,7 +210,7 @@ public function importOptions($modelName) {
* @param string $model Name of model to bake.
* @param string $useTable Name of table to use.
* @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()) {
App::uses('CakeSchema', 'Model');
@@ -243,7 +243,7 @@ public function bake($model, $useTable = false, $importOptions = array()) {
$data = $this->_Schema->read(array('models' => false, 'connection' => $this->connection));
if (!isset($data['tables'][$useTable])) {
$this->err("<warning>Warning:</warning> Could not find the '${useTable}' table for ${model}.");
return;
return null;
}
$tableInfo = $data['tables'][$useTable];
@@ -89,7 +89,7 @@ public function execute() {
$this->_interactive();
}
if (empty($this->args[0])) {
return;
return null;
}
if (!isset($this->connection)) {
$this->connection = 'default';
@@ -179,11 +179,11 @@ public function initialize() {
/**
* 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() {
if (empty($this->args)) {
return;
return null;
}
$params = array(
'core' => false,
@@ -106,7 +106,7 @@ foreach ($associations as $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
break;
endif;
@@ -131,4 +131,5 @@ echo "\t<?php endforeach; ?>\n";
</ul>
</div>
</div>
<?php endforeach; ?>
<?php
endforeach;
@@ -41,7 +41,6 @@ class DbAcl extends Object implements AclInterface {
/**
* Constructor
*
*/
public function __construct() {
parent::__construct();
@@ -196,7 +196,6 @@ public function check($aro, $aco, $action = "*") {
/**
* Access Control Object
*
*/
class PhpAco {
@@ -361,7 +360,6 @@ public function build(array $allow, array $deny = array()) {
/**
* Access Request Object
*
*/
class PhpAro {
@@ -79,7 +79,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
* 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)
* @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
*/
public function adapter($adapter = null) {
@@ -92,7 +92,7 @@ public function adapter($adapter = null) {
}
$this->_Instance = $adapter;
$this->_Instance->initialize($this);
return;
return null;
}
return $this->_Instance;
}
@@ -481,7 +481,7 @@ public function isAuthorized($user = null, CakeRequest $request = null) {
*/
public function constructAuthorize() {
if (empty($this->authorize)) {
return;
return null;
}
$this->_authorizeObjects = array();
$config = Hash::normalize((array)$this->authorize);
@@ -772,12 +772,12 @@ public function identify(CakeRequest $request, CakeResponse $response) {
/**
* 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
*/
public function constructAuthenticate() {
if (empty($this->authenticate)) {
return;
return null;
}
$this->_authenticateObjects = array();
$config = Hash::normalize((array)$this->authenticate);
@@ -27,7 +27,6 @@
*
* @package Cake.Controller.Component
* @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html
*
*/
class CookieComponent extends Component {
@@ -32,7 +32,6 @@
*
* @package Cake.Controller.Component
* @link http://book.cakephp.org/2.0/en/core-libraries/components/request-handling.html
*
*/
class RequestHandlerComponent extends Component {
@@ -280,7 +279,7 @@ public function beforeRedirect(Controller $controller, $url, $status = null, $ex
* "304 Not Modified" header.
*
* @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) {
if ($this->settings['checkHttpCache'] && $this->response->checkNotModified($this->request)) {
@@ -34,7 +34,7 @@ class SessionComponent extends Component {
* Get / Set the userAgent
*
* @param string $userAgent Set the userAgent
* @return void
* @return string Current user agent.
*/
public function userAgent($userAgent = null) {
return CakeSession::userAgent($userAgent);
@@ -31,7 +31,6 @@ class Object {
/**
* Constructor, no-op
*
*/
public function __construct() {
}
@@ -71,7 +71,6 @@ class CakeEvent {
* $event = new CakeEvent('Order.afterBuy', $this, array('buyer' => $userData));
* $event = new CakeEvent('User.afterRegister', $UserModel);
* ```
*
*/
public function __construct($name, $subject = null, $data = null) {
$this->_name = $name;
@@ -172,10 +172,10 @@ public function detach($callable, $eventKey = null) {
foreach (array_keys($this->_listeners) as $eventKey) {
$this->detach($callable, $eventKey);
}
return;
return null;
}
if (empty($this->_listeners[$eventKey])) {
return;
return null;
}
foreach ($this->_listeners[$eventKey] as $priority => $callables) {
foreach ($callables as $k => $callback) {
@@ -196,7 +196,7 @@ protected function _rotateFile($filename) {
if (!file_exists($filepath) ||
filesize($filepath) < $this->_size
) {
return;
return null;
}
if ($this->_config['rotate'] === 0) {
@@ -39,7 +39,6 @@ class AclNode extends Model {
/**
* Constructor
*
*/
public function __construct() {
$config = Configure::read('Acl.database');
@@ -357,7 +357,7 @@ protected static function _validAgentAndTime() {
* Get / 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) {
if ($userAgent) {
@@ -1258,7 +1258,7 @@ public function queryAssociation(Model $Model, Model $LinkModel, $type, $associa
$queryTemplate = $this->generateAssociationQuery($Model, $LinkModel, $type, $association, $assocData, $queryData, $external);
if (empty($queryTemplate)) {
return;
return null;
}
if (!is_array($resultSet)) {
@@ -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 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) {
extract($data);
@@ -1986,7 +1986,7 @@ public function renderStatement($type, $data) {
}
return "CREATE TABLE {$table} (\n{$columns}{$indexes}) {$tableParameters};";
case 'alter':
return;
return null;
}
}
@@ -43,7 +43,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
/**
* Constructor. Looks at Session configuration information and
* sets up the session model.
*
*/
public function __construct() {
$modelName = Configure::read('Session.handler.model');
@@ -1190,12 +1190,12 @@ public function setSource($tableName) {
*
* @param string|array|SimpleXmlElement|DomNode $one Array or string of data
* @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
*/
public function set($one, $two = null) {
if (!$one) {
return;
return null;
}
if (is_object($one)) {
@@ -452,7 +452,7 @@ protected function _setCookies() {
/**
* 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
*/
@@ -216,7 +216,7 @@ protected function _connectionErrorHandler($code, $message) {
*/
public function context() {
if (!$this->connection) {
return;
return null;
}
return stream_context_get_options($this->connection);
}
@@ -152,7 +152,7 @@ public function dispatch(CakeRequest $request, CakeResponse $response, $addition
return $beforeEvent->result->body();
}
$beforeEvent->result->send();
return;
return null;
}
$controller = $this->_getController($request, $response);
@@ -42,7 +42,7 @@ class AssetDispatcher extends DispatcherFilter {
public function beforeDispatch(CakeEvent $event) {
$url = urldecode($event->data['request']->url);
if (strpos($url, '..') !== false || strpos($url, '.') === false) {
return;
return null;
}
if ($result = $this->_filterAsset($event)) {
@@ -39,7 +39,7 @@ class CacheDispatcher extends DispatcherFilter {
*/
public function beforeDispatch(CakeEvent $event) {
if (Configure::read('Cache.check') !== true) {
return;
return null;
}
$path = $event->data['request']->here();
@@ -91,7 +91,6 @@ class Debugger {
/**
* Constructor.
*
*/
public function __construct() {
$docRef = ini_get('docref_root');
@@ -200,7 +199,7 @@ public static function log($var, $level = LOG_DEBUG, $depth = 3) {
* @param string $file File on which error occurred
* @param int $line Line that triggered the error
* @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().
*/
public static function showError($code, $description, $file = null, $line = null, $context = null) {
@@ -217,7 +216,7 @@ public static function showError($code, $description, $file = null, $line = null
if (!in_array($info, $self->errors)) {
$self->errors[] = $info;
} else {
return;
return null;
}
switch ($code) {
@@ -247,7 +246,7 @@ public static function showError($code, $description, $file = null, $line = null
$level = LOG_NOTICE;
break;
default:
return;
return null;
}
$data = compact(
@@ -465,7 +465,7 @@ public static function format(array $data, array $paths, $format) {
$count = count($paths);
if (!$count) {
return;
return null;
}
for ($i = 0; $i < $count; $i++) {
@@ -228,15 +228,15 @@ public static function enum($select, $list = null) {
* @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 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
*/
public static function format($data, $format, $keys) {
$extracted = array();
$count = count($keys);
if (!$count) {
return;
return null;
}
for ($i = 0; $i < $count; $i++) {
@@ -36,4 +36,3 @@
if (extension_loaded('xdebug')) {
xdebug_print_function_stack();
}
?>
@@ -38,4 +38,5 @@ class <?php echo h($controller); ?> extends AppController {
<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'); ?>
</p>
<?php echo $this->element('exception_stack_trace'); ?>
<?php
echo $this->element('exception_stack_trace');
Oops, something went wrong.

0 comments on commit e690662

Please sign in to comment.
You can’t perform that action at this time.