Skip to content

Commit

Permalink
More defaults and doc block corrections.
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Nov 21, 2014
1 parent 0efad4f commit 0e90d71
Show file tree
Hide file tree
Showing 26 changed files with 71 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/Auth/BaseAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function __construct(ComponentRegistry $registry, array $config = []) {
* helps mitigate timing attacks that are attempting to find valid usernames.
*
* @param string $username The username/identifier.
* @param string $password The password, if not provide password checking is skipped
* @param string|null $password The password, if not provide password checking is skipped
* and result of find is returned.
* @return bool|array Either false on failure, or an array of user data.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/ControllerAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(ComponentRegistry $registry, array $config = array()
* Get/set the controller this authorize object will be working with. Also
* checks that isAuthorized is implemented.
*
* @param Controller $controller null to get, a controller to set.
* @param Controller|null $controller null to get, a controller to set.
* @return \Cake\Controller\Controller
* @throws \Cake\Core\Exception\Exception If controller does not have method `isAuthorized()`.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public static function engine($config) {
* Permanently remove all expired and deleted data
*
* @param string $config [optional] The config name you wish to have garbage collected. Defaults to 'default'
* @param int $expires [optional] An expires timestamp. Defaults to NULL
* @param int|null $expires [optional] An expires timestamp. Defaults to NULL
* @return void
*/
public static function gc($config = 'default', $expires = null) {
Expand Down Expand Up @@ -411,7 +411,7 @@ public static function clearGroup($group, $config = 'default') {
*
* $config will equal to `['posts' => ['daily', 'weekly']]`
*
* @param string $group group name or null to retrieve all group mappings
* @param string|null $group group name or null to retrieve all group mappings
* @return array map of group and all configuration that has the same group
* @throws \InvalidArgumentException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/CacheEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function init(array $config = []) {
*
* Permanently remove all expired and deleted data
*
* @param int $expires [optional] An expires timestamp, invalidating all data before.
* @param int|null $expires [optional] An expires timestamp, invalidating all data before.
* @return void
*/
public function gc($expires = null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Engine/FileEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function init(array $config = []) {
/**
* Garbage collection. Permanently remove all expired and deleted data
*
* @param int $expires [optional] An expires timestamp, invalidating all data before.
* @param int|null $expires [optional] An expires timestamp, invalidating all data before.
* @return bool True if garbage collection was successful, false on failure
*/
public function gc($expires = null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Collection/CollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function each(callable $c);
* });
* }}}
*
* @param callable $c the method that will receive each of the elements and
* @param callable|null $c the method that will receive each of the elements and
* returns true whether or not they should be in the resulting collection.
* If left null, a callback that filters out falsey values will be used.
* @return \Cake\Collection\CollectionInterface
Expand Down Expand Up @@ -569,7 +569,7 @@ public function append($items);
* or a function returning the indexing key out of the provided element
* @param callable|string $valuePath the column name path to use as the array value
* or a function returning the value out of the provided element
* @param callable|string $groupPath the column name path to use as the parent
* @param callable|string|null $groupPath the column name path to use as the parent
* grouping key or a function returning the key out of the provided element
* @return \Cake\Collection\CollectionInterface
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Console/ConsoleInputOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ConsoleInputOption {
* @param array $choices Valid choices for this option.
* @throws \Cake\Console\Exception\ConsoleException
*/
public function __construct($name, $short = null, $help = '', $boolean = false, $default = '', $choices = []) {
public function __construct($name, $short = '', $help = '', $boolean = false, $default = '', $choices = []) {
if (is_array($name) && isset($name['name'])) {
foreach ($name as $key => $value) {
$this->{'_' . $key} = $value;
Expand Down Expand Up @@ -145,7 +145,7 @@ public function help($width = 0) {
* @return string
*/
public function usage() {
$name = empty($this->_short) ? '--' . $this->_name : '-' . $this->_short;
$name = strlen($this->_short) < 1 ? '--' . $this->_name : '-' . $this->_short;
$default = '';
if (!empty($this->_default) && $this->_default !== true) {
$default = ' ' . $this->_default;
Expand Down Expand Up @@ -204,7 +204,7 @@ public function xml(\SimpleXmlElement $parent) {
$option = $parent->addChild('option');
$option->addAttribute('name', '--' . $this->_name);
$short = '';
if (strlen($this->_short)) {
if (strlen($this->_short) > 0) {
$short = $this->_short;
}
$option->addAttribute('short', '-' . $short);
Expand Down
6 changes: 3 additions & 3 deletions src/Console/ConsoleInputSubcommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class ConsoleInputSubcommand {
* Make a new Subcommand
*
* @param string|array $name The long name of the subcommand, or an array with all the properties.
* @param string $help The help text for this option
* @param ConsoleOptionParser|array $parser A parser for this subcommand. Either a ConsoleOptionParser, or an array that can be
* used with ConsoleOptionParser::buildFromArray()
* @param string $help The help text for this option.
* @param \Cake\Console\ConsoleOptionParser|array|null $parser A parser for this subcommand. Either a ConsoleOptionParser, or an
* array that can be used with ConsoleOptionParser::buildFromArray().
*/
public function __construct($name, $help = '', $parser = null) {
if (is_array($name) && isset($name['name'])) {
Expand Down
16 changes: 8 additions & 8 deletions src/Console/ConsoleIo.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class ConsoleIo {
/**
* Constructor
*
* @param \Cake\Console\ConsoleOutput $out A ConsoleOutput object for stdout.
* @param \Cake\Console\ConsoleOutput $err A ConsoleOutput object for stderr.
* @param \Cake\Console\ConsoleInput $in A ConsoleInput object for stdin.
* @param \Cake\Console\ConsoleOutput|null $out A ConsoleOutput object for stdout.
* @param \Cake\Console\ConsoleOutput|null $err A ConsoleOutput object for stderr.
* @param \Cake\Console\ConsoleInput|null $in A ConsoleInput object for stdin.
*/
public function __construct(ConsoleOutput $out = null, ConsoleOutput $err = null, ConsoleInput $in = null) {
$this->_out = $out ? $out : new ConsoleOutput('php://stdout');
Expand Down Expand Up @@ -228,7 +228,7 @@ public function hr($newlines = 0, $width = 79) {
* Prompts the user for input, and returns it.
*
* @param string $prompt Prompt text.
* @param string $default Default input value.
* @param string|null $default Default input value.
* @return mixed Either the default value, or the user-provided input.
*/
public function ask($prompt, $default = null) {
Expand All @@ -250,7 +250,7 @@ public function outputAs($mode) {
* Add a new output style or get defined styles.
*
* @param string $style The style to get or create.
* @param array $definition The array definition of the style to change or create a style
* @param array|bool|null $definition The array definition of the style to change or create a style
* or false to remove a style.
* @return mixed If you are getting styles, the style or null will be returned. If you are creating/modifying
* styles true will be returned.
Expand All @@ -265,7 +265,7 @@ public function styles($style = null, $definition = null) {
*
* @param string $prompt Prompt text.
* @param string|array $options Array or string of options.
* @param string $default Default input value.
* @param string|null $default Default input value.
* @return mixed Either the default value, or the user-provided input.
*/
public function askChoice($prompt, $options, $default = null) {
Expand Down Expand Up @@ -296,8 +296,8 @@ public function askChoice($prompt, $options, $default = null) {
* Prompts the user for input, and returns it.
*
* @param string $prompt Prompt text.
* @param string|array $options Array or string of options.
* @param string $default Default input value.
* @param string|null $options String of options. Pass null to omit.
* @param string|null $default Default input value. Pass null to omit.
* @return string Either the default value, or the user-provided input.
*/
protected function _getInput($prompt, $options, $default) {
Expand Down
13 changes: 7 additions & 6 deletions src/Console/ConsoleOptionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class ConsoleOptionParser {
/**
* Construct an OptionParser so you can define its behavior
*
* @param string $command The command name this parser is for. The command name is used for generating help.
* @param string $command|null The command name this parser is for. The command name is used for generating help.
* @param bool $defaultOptions Whether you want the verbose and quiet options set. Setting
* this to false will prevent the addition of `--verbose` & `--quiet` options.
*/
Expand Down Expand Up @@ -156,7 +156,7 @@ public function __construct($command = null, $defaultOptions = true) {
/**
* Static factory method for creating new OptionParsers so you can chain methods off of them.
*
* @param string $command The command name this parser is for. The command name is used for generating help.
* @param string|null $command The command name this parser is for. The command name is used for generating help.
* @param bool $defaultOptions Whether you want the verbose and quiet options set.
* @return ConsoleOptionParser
*/
Expand Down Expand Up @@ -209,7 +209,7 @@ public static function buildFromArray($spec) {
/**
* Get or set the command name for shell/task.
*
* @param string $text The text to set, or null if you want to read
* @param string|null $text The text to set, or null if you want to read
* @return string|$this If reading, the value of the command. If setting $this will be returned.
*/
public function command($text = null) {
Expand All @@ -223,8 +223,8 @@ public function command($text = null) {
/**
* Get or set the description text for shell/task.
*
* @param string|array $text The text to set, or null if you want to read. If an array the
* text will be imploded with "\n"
* @param string|array|null $text The text to set, or null if you want to read. If an array the
* text will be imploded with "\n".
* @return string|$this If reading, the value of the description. If setting $this will be returned.
*/
public function description($text = null) {
Expand All @@ -242,7 +242,8 @@ public function description($text = null) {
* Get or set an epilog to the parser. The epilog is added to the end of
* the options and arguments listing when help is generated.
*
* @param string|array $text Text when setting or null when reading. If an array the text will be imploded with "\n"
* @param string|array|null $text Text when setting or null when reading. If an array the text will
* be imploded with "\n".
* @return string|$this If reading, the value of the epilog. If setting $this will be returned.
*/
public function epilog($text = null) {
Expand Down
6 changes: 3 additions & 3 deletions src/Console/ConsoleOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ protected function _write($message) {
*
* `$this->output->styles('annoy', false);`
*
* @param string $style The style to get or create.
* @param array $definition The array definition of the style to change or create a style
* @param string|null $style The style to get or create.
* @param array|bool|null $definition The array definition of the style to change or create a style
* or false to remove a style.
* @return mixed If you are getting styles, the style or null will be returned. If you are creating/modifying
* styles true will be returned.
Expand All @@ -282,7 +282,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 $type The output type to use. Should be one of the class constants.
* @param int|null $type The output type to use. Should be one of the class constants.
* @return mixed Either null or the value if getting.
*/
public function outputAs($type = null) {
Expand Down
10 changes: 5 additions & 5 deletions src/Console/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ public function param($name) {
* Prompts the user for input, and returns it.
*
* @param string $prompt Prompt text.
* @param string|array $options Array or string of options.
* @param string $default Default input value.
* @param string|array|null $options Array or string of options.
* @param string|null $default Default input value.
* @return mixed Either the default value, or the user-provided input.
* @link http://book.cakephp.org/3.0/en/console-and-shells.html#Shell::in
*/
Expand Down Expand Up @@ -492,7 +492,7 @@ public function wrapText($text, $options = []) {
* present in most shells. Using Shell::QUIET for a message means it will always display.
* While using Shell::VERBOSE means it will only display when verbose output is toggled.
*
* @param string|array $message A string or an array of strings to output
* @param string|array|null $message A string or an array of strings to output
* @param int $newlines Number of newlines to append
* @param int $level The message's output level, see above.
* @return int|bool Returns the number of bytes returned from writing to stdout.
Expand All @@ -506,7 +506,7 @@ public function out($message = null, $newlines = 1, $level = Shell::NORMAL) {
* Outputs a single or multiple error messages to stderr. If no parameters
* are passed outputs just a newline.
*
* @param string|array $message A string or an array of strings to output
* @param string|array|null $message A string or an array of strings to output
* @param int $newlines Number of newlines to append
* @return void
*/
Expand Down Expand Up @@ -542,7 +542,7 @@ public function hr($newlines = 0, $width = 63) {
* and exits the application with status code 1
*
* @param string $title Title of the error
* @param string $message An optional error message
* @param string|null $message An optional error message
* @return void
* @link http://book.cakephp.org/3.0/en/console-and-shells.html#styling-output
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/AuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ protected function _setDefaults() {
* Each adapter will be checked in sequence, if any of them return true, then the user will
* be authorized for the request.
*
* @param array $user The user to check the authorization of. If empty the user in the session will be used.
* @param \Cake\Network\Request $request The request to authenticate for. If empty, the current request will be used.
* @param array|null $user The user to check the authorization of. If empty the user in the session will be used.
* @param \Cake\Network\Request|null $request The request to authenticate for. If empty, the current request will be used.
* @return bool True if $user is authorized, otherwise false
*/
public function isAuthorized($user = null, Request $request = null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/CookieComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function write($key, $value = null) {
* This method will also allow you to read cookies that have been written in this
* request, but not yet sent to the client.
*
* @param string $key Key of the value to be obtained.
* @param string|null $key Key of the value to be obtained.
* @return string or null, value for specified key
*/
public function read($key = null) {
Expand Down Expand Up @@ -265,7 +265,7 @@ protected function _load($key) {
/**
* Returns true if given key is set in the cookie.
*
* @param string $key Key to check for
* @param string|null $key Key to check for
* @return bool True if the key exists
*/
public function check($key = null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/RequestHandlerComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ public function addInputType($type, $handler) {
/**
* Getter/setter for viewClassMap
*
* @param array|string $type The type string or array with format `array('type' => 'viewClass')` to map one or more
* @param array $viewClass The viewClass to be used for the type without `View` appended
* @param array|string|null $type The type string or array with format `array('type' => 'viewClass')` to map one or more
* @param array|null $viewClass The viewClass to be used for the type without `View` appended
* @return array|string Returns viewClass when only string $type is set, else array with viewClassMap
*/
public function viewClassMap($type = null, $viewClass = null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Component/SessionComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function check($name) {
* @return void
* @deprecated 3.0 Use FlashComponent::set() instead.
*/
public function setFlash($message, $element = null, array $params = array(), $key = 'flash') {
public function setFlash($message, $element = '', array $params = array(), $key = 'flash') {
$this->_session->write('Flash.' . $key, [
'message' => $message,
'key' => $key,
Expand Down
12 changes: 6 additions & 6 deletions src/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ class Controller implements EventListenerInterface {
* Sets a number of properties based on conventions if they are empty. To override the
* conventions CakePHP uses you can define properties in your class declaration.
*
* @param \Cake\Network\Request $request Request object for this controller. Can be null for testing,
* @param \Cake\Network\Request|null $request Request object for this controller. Can be null for testing,
* but expect that features that use the request parameters will not work.
* @param \Cake\Network\Response $response Response object for this controller.
* @param string $name Override the name useful in testing when using mocks.
* @param \Cake\Event\EventManager $eventManager The event manager. Defaults to a new instance.
* @param \Cake\Network\Response|null $response Response object for this controller.
* @param string|null $name Override the name useful in testing when using mocks.
* @param \Cake\Event\EventManager|null $eventManager The event manager. Defaults to a new instance.
*/
public function __construct(Request $request = null, Response $response = null, $name = null, $eventManager = null) {
if ($this->name === null && $name === null) {
Expand Down Expand Up @@ -596,7 +596,7 @@ public function render($view = null, $layout = null) {
/**
* Returns the referring URL for this request.
*
* @param string $default Default URL to use if HTTP_REFERER cannot be read from headers
* @param string|null $default Default URL to use if HTTP_REFERER cannot be read from headers
* @param bool $local If true, restrict referring URLs to local server
* @return string Referring URL
*/
Expand All @@ -620,7 +620,7 @@ public function referer($default = null, $local = false) {
*
* This method will also make the PaginatorHelper available in the view.
*
* @param \Cake\ORM\Table|string|\Cake\ORM\Query $object Table to paginate
* @param \Cake\ORM\Table|string|\Cake\ORM\Query|null $object Table to paginate
* (e.g: Table instance, 'TableName' or a Query object)
* @return \Cake\ORM\ResultSet Query results
* @link http://book.cakephp.org/3.0/en/controllers.html#Controller::paginate
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/ErrorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class ErrorController extends Controller {
/**
* Constructor
*
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Network\Response $response Reponse instance.
* @param \Cake\Network\Request|null $request Request instance.
* @param \Cake\Network\Response|null $response Reponse instance.
*/
public function __construct($request = null, $response = null) {
parent::__construct($request, $response);
Expand Down
14 changes: 7 additions & 7 deletions src/Core/Exception/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@ public function getAttributes() {
*
* See also Cake\Network\Response::header()
*
* @param string|array $header An array of header strings or a single header string
* @param string|array|null $header An array of header strings or a single header string
* - an associative array of "header name" => "header value"
* - an array of string headers is also accepted
* @param string $value The header value.
* @return array
*/
public function responseHeader($header = null, $value = null) {
if ($header) {
if (is_array($header)) {
return $this->_responseHeaders = $header;
}
$this->_responseHeaders = array($header => $value);
if ($header === null) {
return $this->_responseHeaders;
}
return $this->_responseHeaders;
if (is_array($header)) {
return $this->_responseHeaders = $header;
}
$this->_responseHeaders = array($header => $value);
}

}
Loading

0 comments on commit 0e90d71

Please sign in to comment.