From 4c525a08afc6fb2d0a589864ba9542e1c274025c Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sat, 10 Oct 2015 06:12:49 +0200 Subject: [PATCH] Do not mix void with other return types. --- src/Console/ConsoleOutput.php | 2 +- src/Controller/Component/AuthComponent.php | 14 +++++------ .../Component/RequestHandlerComponent.php | 2 +- src/Controller/Controller.php | 6 ++--- src/Database/Query.php | 4 ++-- src/I18n/I18n.php | 8 +++---- src/I18n/functions.php | 24 +++++++++---------- src/Routing/Dispatcher.php | 4 ++-- src/Routing/Route/Route.php | 2 +- src/Routing/RouteBuilder.php | 4 ++-- src/Routing/Router.php | 2 +- src/Shell/CompletionShell.php | 10 ++++---- src/Shell/I18nShell.php | 2 +- src/TestSuite/Fixture/TestFixture.php | 4 ++-- src/Utility/Hash.php | 6 ++--- src/View/Helper.php | 2 +- src/View/Helper/FlashHelper.php | 2 +- src/View/Helper/FormHelper.php | 4 ++-- src/View/View.php | 16 ++++++------- 19 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/Console/ConsoleOutput.php b/src/Console/ConsoleOutput.php index 16805e2d4fc..a9c88f7e861 100644 --- a/src/Console/ConsoleOutput.php +++ b/src/Console/ConsoleOutput.php @@ -301,7 +301,7 @@ public function styles($style = null, $definition = null) * Get/Set the output type to use. The output type how formatting tags are treated. * * @param int|null $type The output type to use. Should be one of the class constants. - * @return int|void Either null or the value if getting. + * @return int|null Either null or the value if getting. */ public function outputAs($type = null) { diff --git a/src/Controller/Component/AuthComponent.php b/src/Controller/Component/AuthComponent.php index 75c1d71c26f..79af9b6a4e2 100644 --- a/src/Controller/Component/AuthComponent.php +++ b/src/Controller/Component/AuthComponent.php @@ -251,7 +251,7 @@ public function initialize(array $config) * Callback for Controller.startup event. * * @param \Cake\Event\Event $event Event instance. - * @return void|\Cake\Network\Response + * @return \Cake\Network\Response|null */ public function startup(Event $event) { @@ -266,7 +266,7 @@ public function startup(Event $event) * `checkAuthIn` config. * * @param \Cake\Event\Event $event Event instance. - * @return void|\Cake\Network\Response + * @return \Cake\Network\Response|null */ public function authCheck(Event $event) { @@ -347,7 +347,7 @@ protected function _isAllowed(Controller $controller) * is returned. * * @param \Cake\Controller\Controller $controller A reference to the controller object. - * @return void|\Cake\Network\Response Null if current action is login action + * @return \Cake\Network\Response|null Null if current action is login action * else response object returned by authenticate object or Controller::redirect(). */ protected function _unauthenticated(Controller $controller) @@ -657,14 +657,14 @@ public function logout() * Get the current user from storage. * * @param string $key Field to retrieve. Leave null to get entire User record. - * @return array|void Either User record or null if no user is logged in. + * @return array|null Either User record or null if no user is logged in. * @link http://book.cakephp.org/3.0/en/controllers/components/authentication.html#accessing-the-logged-in-user */ public function user($key = null) { $user = $this->storage()->read(); if (!$user) { - return; + return null; } if ($key === null) { @@ -818,13 +818,13 @@ public function constructAuthenticate() * * @param \Cake\Auth\Storage\StorageInterface|null $storage Sets provided * object as storage or if null returns configuread storage object. - * @return \Cake\Auth\Storage\StorageInterface|void + * @return \Cake\Auth\Storage\StorageInterface|null */ public function storage(StorageInterface $storage = null) { if ($storage !== null) { $this->_storage = $storage; - return; + return null; } if ($this->_storage) { diff --git a/src/Controller/Component/RequestHandlerComponent.php b/src/Controller/Component/RequestHandlerComponent.php index 403ab56f957..040b4142f09 100644 --- a/src/Controller/Component/RequestHandlerComponent.php +++ b/src/Controller/Component/RequestHandlerComponent.php @@ -245,7 +245,7 @@ public function convertXml($xml) * @param Event $event The Controller.beforeRedirect event. * @param string|array $url A string or array containing the redirect location * @param \Cake\Network\Response $response The response object. - * @return void|\Cake\Network\Response The response object if the redirect is caught. + * @return \Cake\Network\Response|null The response object if the redirect is caught. */ public function beforeRedirect(Event $event, $url, Response $response) { diff --git a/src/Controller/Controller.php b/src/Controller/Controller.php index 2519ebe1863..bdea08a02e3 100644 --- a/src/Controller/Controller.php +++ b/src/Controller/Controller.php @@ -484,7 +484,7 @@ protected function _loadComponents() * - Calls the controller `beforeFilter`. * - triggers Component `startup` methods. * - * @return void|\Cake\Network\Response + * @return \Cake\Network\Response|null */ public function startupProcess() { @@ -505,7 +505,7 @@ public function startupProcess() * - triggers the component `shutdown` callback. * - calls the Controller's `afterFilter` method. * - * @return void|\Cake\Network\Response + * @return \Cake\Network\Response|null */ public function shutdownProcess() { @@ -522,7 +522,7 @@ public function shutdownProcess() * @param string|array $url A string or array-based URL pointing to another location within the app, * or an absolute URL * @param int $status HTTP status code (eg: 301) - * @return void|\Cake\Network\Response + * @return \Cake\Network\Response|null * @link http://book.cakephp.org/3.0/en/controllers.html#Controller::redirect */ public function redirect($url, $status = 302) diff --git a/src/Database/Query.php b/src/Database/Query.php index 7328e9a2501..cb72f9e4ea3 100644 --- a/src/Database/Query.php +++ b/src/Database/Query.php @@ -1580,7 +1580,7 @@ public function decorateResults($callback, $overwrite = false) * * @param callable $callback the function to be executed for each ExpressionInterface * found inside this query. - * @return void|$this + * @return $this|null */ public function traverseExpressions(callable $callback) { @@ -1589,7 +1589,7 @@ public function traverseExpressions(callable $callback) foreach ($expression as $e) { $visitor($e); } - return; + return null; } if ($expression instanceof ExpressionInterface) { diff --git a/src/I18n/I18n.php b/src/I18n/I18n.php index 33af89de9f4..2d0378a2a6b 100644 --- a/src/I18n/I18n.php +++ b/src/I18n/I18n.php @@ -120,7 +120,7 @@ public static function translators() * @param string|null $locale The locale for the translator. * @param callable|null $loader A callback function or callable class responsible for * constructing a translations package instance. - * @return \Aura\Intl\Translator|void The configured translator. + * @return \Aura\Intl\Translator|null The configured translator. */ public static function translator($name = 'default', $locale = null, callable $loader = null) { @@ -131,7 +131,7 @@ public static function translator($name = 'default', $locale = null, callable $l $packages = static::translators()->getPackages(); $packages->set($name, $locale, $loader); - return; + return null; } $translators = static::translators(); @@ -206,7 +206,7 @@ public static function config($name, callable $loader) * locale as stored in the `intl.default_locale` PHP setting. * * @param string|null $locale The name of the locale to set as default. - * @return string|void The name of the default locale. + * @return string|null The name of the default locale. */ public static function locale($locale = null) { @@ -217,7 +217,7 @@ public static function locale($locale = null) if (isset(static::$_collection)) { static::translators()->setLocale($locale); } - return; + return null; } $current = Locale::getDefault(); diff --git a/src/I18n/functions.php b/src/I18n/functions.php index bb62d3527ed..a5157b5a7e8 100644 --- a/src/I18n/functions.php +++ b/src/I18n/functions.php @@ -69,13 +69,13 @@ function __n($singular, $plural, $count, $args = null) * @param string $domain Domain. * @param string $msg String to translate. * @param mixed $args Array with arguments or multiple arguments in function. - * @return void|string Translated string. + * @return string|null Translated string. * @link http://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#__d */ function __d($domain, $msg, $args = null) { if (!$msg) { - return; + return null; } $arguments = func_num_args() === 3 ? (array)$args : array_slice(func_get_args(), 2); return I18n::translator($domain)->translate($msg, $arguments); @@ -94,13 +94,13 @@ function __d($domain, $msg, $args = null) * @param string $plural Plural. * @param int $count Count. * @param mixed $args Array with arguments or multiple arguments in function. - * @return void|string Plural form of translated string. + * @return string|null Plural form of translated string. * @link http://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#__dn */ function __dn($domain, $singular, $plural, $count, $args = null) { if (!$singular) { - return; + return null; } $arguments = func_num_args() === 5 ? (array)$args : array_slice(func_get_args(), 4); @@ -121,13 +121,13 @@ function __dn($domain, $singular, $plural, $count, $args = null) * @param string $context Context of the text. * @param string $singular Text to translate. * @param mixed $args Array with arguments or multiple arguments in function. - * @return void|string Translated string. + * @return string|null Translated string. * @link http://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#__ */ function __x($context, $singular, $args = null) { if (!$singular) { - return; + return null; } $arguments = func_num_args() === 3 ? (array)$args : array_slice(func_get_args(), 2); @@ -148,13 +148,13 @@ function __x($context, $singular, $args = null) * @param string $plural Plural text. * @param int $count Count. * @param mixed $args Array with arguments or multiple arguments in function. - * @return void|string Plural form of translated string. + * @return string|null Plural form of translated string. * @link http://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#__xn */ function __xn($context, $singular, $plural, $count, $args = null) { if (!$singular) { - return; + return null; } $arguments = func_num_args() === 5 ? (array)$args : array_slice(func_get_args(), 2); @@ -176,13 +176,13 @@ function __xn($context, $singular, $plural, $count, $args = null) * @param string $context Context of the text. * @param string $msg String to translate. * @param mixed $args Array with arguments or multiple arguments in function. - * @return void|string Translated string. + * @return string|null Translated string. * @link http://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#__dx */ function __dx($domain, $context, $msg, $args = null) { if (!$msg) { - return; + return null; } $arguments = func_num_args() === 4 ? (array)$args : array_slice(func_get_args(), 2); @@ -207,13 +207,13 @@ function __dx($domain, $context, $msg, $args = null) * @param string $plural Plural text. * @param int $count Count. * @param mixed $args Array with arguments or multiple arguments in function. - * @return void|string Plural form of translated string. + * @return string|null Plural form of translated string. * @link http://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#__dxn */ function __dxn($domain, $context, $singular, $plural, $count, $args = null) { if (!$singular) { - return; + return null; } $arguments = func_num_args() === 6 ? (array)$args : array_slice(func_get_args(), 2); diff --git a/src/Routing/Dispatcher.php b/src/Routing/Dispatcher.php index ca8217e7842..a2fc2a5e5ed 100644 --- a/src/Routing/Dispatcher.php +++ b/src/Routing/Dispatcher.php @@ -54,7 +54,7 @@ class Dispatcher * * @param \Cake\Network\Request $request Request object to dispatch. * @param \Cake\Network\Response $response Response object to put the results of the dispatch into. - * @return string|void if `$request['return']` is set then it returns response body, null otherwise + * @return string|null if `$request['return']` is set then it returns response body, null otherwise * @throws \Cake\Routing\Exception\MissingControllerException When the controller is missing. */ public function dispatch(Request $request, Response $response) @@ -67,7 +67,7 @@ public function dispatch(Request $request, Response $response) return $beforeEvent->result->body(); } $beforeEvent->result->send(); - return; + return null; } $controller = false; diff --git a/src/Routing/Route/Route.php b/src/Routing/Route/Route.php index d76ed614eca..9d91795fd3e 100644 --- a/src/Routing/Route/Route.php +++ b/src/Routing/Route/Route.php @@ -116,7 +116,7 @@ public function __construct($template, $defaults = [], array $options = []) * Get/Set the supported extensions for this route. * * @param null|string|array $extensions The extensions to set. Use null to get. - * @return array|void The extensions or null. + * @return array|null The extensions or null. */ public function extensions($extensions = null) { diff --git a/src/Routing/RouteBuilder.php b/src/Routing/RouteBuilder.php index d4af7d42126..8f33be58d4f 100644 --- a/src/Routing/RouteBuilder.php +++ b/src/Routing/RouteBuilder.php @@ -132,7 +132,7 @@ public function __construct(RouteCollection $collection, $path, array $params = * Get or set default route class. * * @param string|null $routeClass Class name. - * @return string|void + * @return string|null */ public function routeClass($routeClass = null) { @@ -149,7 +149,7 @@ public function routeClass($routeClass = null) * extensions applied. However, setting extensions does not modify existing routes. * * @param null|string|array $extensions Either the extensions to use or null. - * @return array|void + * @return array|null */ public function extensions($extensions = null) { diff --git a/src/Routing/Router.php b/src/Routing/Router.php index 74cf8bf6388..f2fe3fd9dad 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -161,7 +161,7 @@ class Router * Get or set default route class. * * @param string|null $routeClass Class name. - * @return string|void + * @return string|null */ public static function defaultRouteClass($routeClass = null) { diff --git a/src/Shell/CompletionShell.php b/src/Shell/CompletionShell.php index 9e33fe8b088..2ec0ae554b3 100644 --- a/src/Shell/CompletionShell.php +++ b/src/Shell/CompletionShell.php @@ -51,7 +51,7 @@ public function main() /** * list commands * - * @return void|int|bool Returns the number of bytes returned from writing to stdout. + * @return int|bool|null Returns the number of bytes returned from writing to stdout. */ public function commands() { @@ -62,7 +62,7 @@ public function commands() /** * list options for the named command * - * @return void|int|bool Returns the number of bytes returned from writing to stdout. + * @return int|bool|null Returns the number of bytes returned from writing to stdout. */ public function options() { @@ -78,7 +78,7 @@ public function options() /** * list subcommands for the named command * - * @return void|int|bool Returns the number of bytes returned from writing to stdout. + * @return int|bool|null Returns the number of bytes returned from writing to stdout. */ public function subcommands() { @@ -93,7 +93,7 @@ public function subcommands() /** * Guess autocomplete from the whole argument string * - * @return void|int|bool Returns the number of bytes returned from writing to stdout. + * @return int|bool|null Returns the number of bytes returned from writing to stdout. */ public function fuzzy() { @@ -151,7 +151,7 @@ public function getOptionParser() * Emit results as a string, space delimited * * @param array $options The options to output - * @return void|int|bool Returns the number of bytes returned from writing to stdout. + * @return int|bool|null Returns the number of bytes returned from writing to stdout. */ protected function _output($options = []) { diff --git a/src/Shell/I18nShell.php b/src/Shell/I18nShell.php index c192d3f7097..ba26cdf2b38 100644 --- a/src/Shell/I18nShell.php +++ b/src/Shell/I18nShell.php @@ -74,7 +74,7 @@ public function main() * Inits PO file from POT file. * * @param string|null $language Language code to use. - * @return void|int + * @return int|null */ public function init($language = null) { diff --git a/src/TestSuite/Fixture/TestFixture.php b/src/TestSuite/Fixture/TestFixture.php index 9fd599af833..4d127f3e1bc 100644 --- a/src/TestSuite/Fixture/TestFixture.php +++ b/src/TestSuite/Fixture/TestFixture.php @@ -204,13 +204,13 @@ protected function _schemaFromImport() * Get/Set the Cake\Database\Schema\Table instance used by this fixture. * * @param \Cake\Database\Schema\Table $schema The table to set. - * @return void|\Cake\Database\Schema\Table + * @return \Cake\Database\Schema\Table|null */ public function schema(Table $schema = null) { if ($schema) { $this->_schema = $schema; - return; + return null; } return $this->_schema; } diff --git a/src/Utility/Hash.php b/src/Utility/Hash.php index 8eccb6531f4..b770c174860 100644 --- a/src/Utility/Hash.php +++ b/src/Utility/Hash.php @@ -510,7 +510,7 @@ public static function combine(array $data, $keyPath, $valuePath = null, $groupP * @param array $data Source array from which to extract the data * @param array $paths An array containing one or more Hash::extract()-style key paths * @param string $format Format string into which values will be inserted, see sprintf() - * @return void|array An array of strings extracted from `$path` and formatted with `$format` + * @return array|null An array of strings extracted from `$path` and formatted with `$format` * @link http://book.cakephp.org/3.0/en/core-libraries/hash.html#Hash::format * @see sprintf() * @see Hash::extract() @@ -521,7 +521,7 @@ public static function format(array $data, array $paths, $format) $count = count($paths); if (!$count) { - return; + return null; } for ($i = 0; $i < $count; $i++) { @@ -549,7 +549,7 @@ public static function format(array $data, array $paths, $format) * * @param array $data The data to search through. * @param array $needle The values to file in $data - * @return bool true if $data contains $needle, false otherwise + * @return bool true If $data contains $needle, false otherwise * @link http://book.cakephp.org/3.0/en/core-libraries/hash.html#Hash::contains */ public static function contains(array $data, array $needle) diff --git a/src/View/Helper.php b/src/View/Helper.php index 7626e0d0a5b..4cd9358ae12 100644 --- a/src/View/Helper.php +++ b/src/View/Helper.php @@ -142,7 +142,7 @@ public function __call($method, $params) * Lazy loads helpers. * * @param string $name Name of the property being accessed. - * @return \Cake\View\Helper|void Helper instance if helper with provided name exists + * @return \Cake\View\Helper|null Helper instance if helper with provided name exists */ public function __get($name) { diff --git a/src/View/Helper/FlashHelper.php b/src/View/Helper/FlashHelper.php index 529d3f1f773..daf003fc7f9 100644 --- a/src/View/Helper/FlashHelper.php +++ b/src/View/Helper/FlashHelper.php @@ -64,7 +64,7 @@ class FlashHelper extends Helper * @param string $key The [Flash.]key you are rendering in the view. * @param array $options Additional options to use for the creation of this flash message. * Supports the 'params', and 'element' keys that are used in the helper. - * @return string|void Rendered flash message or null if flash key does not exist + * @return string|null Rendered flash message or null if flash key does not exist * in session. * @throws \UnexpectedValueException If value for flash settings key is not an array. */ diff --git a/src/View/Helper/FormHelper.php b/src/View/Helper/FormHelper.php index 227ea02b60e..441f260c05a 100644 --- a/src/View/Helper/FormHelper.php +++ b/src/View/Helper/FormHelper.php @@ -546,12 +546,12 @@ public function end(array $secureAttributes = []) * generating the hash, else $this->fields is being used. * @param array $secureAttributes will be passed as HTML attributes into the hidden * input elements generated for the Security Component. - * @return void|string A hidden input field with a security hash + * @return string|null A hidden input field with a security hash */ public function secure(array $fields = [], array $secureAttributes = []) { if (empty($this->request['_Token'])) { - return; + return null; } $locked = []; $unlockedFields = $this->_unlockedFields; diff --git a/src/View/View.php b/src/View/View.php index afc118cd9d6..c54a5134cac 100644 --- a/src/View/View.php +++ b/src/View/View.php @@ -354,7 +354,7 @@ public function initialize() * Get/set path for templates files. * * @param string $path Path for template files. If null returns current path. - * @return string|void + * @return string|null */ public function templatePath($path = null) { @@ -369,7 +369,7 @@ public function templatePath($path = null) * Get/set path for layout files. * * @param string $path Path for layout files. If null returns current path. - * @return string|void + * @return string|null */ public function layoutPath($path = null) { @@ -386,7 +386,7 @@ public function layoutPath($path = null) * automatically applied to rendered templates. * * @param bool $autoLayout Boolean to turn on/off. If null returns current value. - * @return bool|void + * @return bool|null */ public function autoLayout($autoLayout = null) { @@ -401,7 +401,7 @@ public function autoLayout($autoLayout = null) * The view theme to use. * * @param string $theme Theme name. If null returns current theme. - * @return string|void + * @return string|null */ public function theme($theme = null) { @@ -417,7 +417,7 @@ public function theme($theme = null) * filename in /app/Template/ without the .ctp extension. * * @param string $name Template file name to set. If null returns current name. - * @return string|void + * @return string|null */ public function template($name = null) { @@ -434,7 +434,7 @@ public function template($name = null) * without the .ctp extension. * * @param string $name Layout file name to set. If null returns current name. - * @return string|void + * @return string|null */ public function layout($name = null) { @@ -556,7 +556,7 @@ public function elementExists($name) * * @param string|null $view Name of view file to use * @param string|null $layout Layout to use. - * @return string|void Rendered content or null if content already rendered and returned earlier. + * @return string|null Rendered content or null if content already rendered and returned earlier. * @throws \Cake\Core\Exception\Exception If there is an error in the view. * @triggers View.beforeRender $this, [$viewFileName] * @triggers View.afterRender $this, [$viewFileName] @@ -564,7 +564,7 @@ public function elementExists($name) public function render($view = null, $layout = null) { if ($this->hasRendered) { - return; + return null; } if ($layout !== null) {