Skip to content

Commit

Permalink
Correct return types.
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Nov 6, 2014
1 parent 1b7e36e commit 25414d8
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/Controller/Component/CookieComponent.php
Expand Up @@ -171,7 +171,7 @@ public function initialize(array $config) {
* @param null|string|array $option Either the option name to set, or an array of options to set,
* or null to read config options for a given key.
* @param string|null $value Either the value to set, or empty when $option is an array.
* @return void
* @return array|null
*/
public function configKey($keyname, $option = null, $value = null) {
if ($option === null) {
Expand All @@ -183,6 +183,7 @@ public function configKey($keyname, $option = null, $value = null) {
$option = [$option => $value];
}
$this->_keyConfig[$keyname] = $option;
return null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -625,7 +625,7 @@ public function responseType() {
* Maps a content type alias back to its mime-type(s)
*
* @param string|array $alias String alias to convert back into a content type. Or an array of aliases to map.
* @return string Null on an undefined alias. String value of the mapped alias type. If an
* @return string|null Null on an undefined alias. String value of the mapped alias type. If an
* alias maps to more than one content type, the first one will be returned.
*/
public function mapAlias($alias) {
Expand Down
2 changes: 1 addition & 1 deletion src/Core/functions.php
Expand Up @@ -167,7 +167,7 @@ function pj($var) {
* environment information.
*
* @param string $key Environment variable name.
* @return string Environment variable setting.
* @return string|null Environment variable setting.
* @link http://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#env
*/
function env($key) {
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Connection.php
Expand Up @@ -134,7 +134,7 @@ public function config() {
*/
public function configName() {
if (empty($this->_config['name'])) {
return null;
return '';
}
return $this->_config['name'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Schema/PostgresSchema.php
Expand Up @@ -151,7 +151,7 @@ public function convertColumnDescription(Table $table, $row) {
* We need to remove those.
*
* @param string $default The default value.
* @return string
* @return string|null
*/
protected function _defaultValue($default) {
if (is_numeric($default) || $default === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Type/BinaryType.php
Expand Up @@ -44,7 +44,7 @@ public function toDatabase($value, Driver $driver) {
*
* @param null|string|resource $value The value to convert.
* @param Driver $driver The driver instance to convert with.
* @return resource
* @return resource|null
* @throws \Cake\Core\Exception\Exception
*/
public function toPHP($value, Driver $driver) {
Expand Down
2 changes: 1 addition & 1 deletion src/Filesystem/Folder.php
Expand Up @@ -596,7 +596,7 @@ public function delete($path = null) {
$path = $this->pwd();
}
if (!$path) {
return null;
return false;
}
$path = Folder::slashTerm($path);
if (is_dir($path)) {
Expand Down
18 changes: 9 additions & 9 deletions src/Network/Response.php
Expand Up @@ -723,7 +723,7 @@ public function httpCodes($code = null) {
* e.g `type(array('jpg' => 'text/plain'));`
*
* @param string $contentType Content type key.
* @return mixed current content type or false if supplied an invalid content type
* @return mixed Current content type or false if supplied an invalid content type
*/
public function type($contentType = null) {
if ($contentType === null) {
Expand Down Expand Up @@ -751,7 +751,7 @@ public function type($contentType = null) {
* e.g `getMimeType('pdf'); // returns 'application/pdf'`
*
* @param string $alias the content type alias to map
* @return mixed string mapped mime type or false if $alias is not mapped
* @return mixed String mapped mime type or false if $alias is not mapped
*/
public function getMimeType($alias) {
if (isset($this->_mimeTypes[$alias])) {
Expand Down Expand Up @@ -837,7 +837,7 @@ public function cache($since, $time = '+1 day') {
* if set to false, the response will be set to private
* if no value is provided, it will return whether the response is sharable or not
* @param int $time time in seconds after which the response should no longer be considered fresh
* @return bool
* @return bool|null
*/
public function sharable($public = null, $time = null) {
if ($public === null) {
Expand Down Expand Up @@ -872,7 +872,7 @@ public function sharable($public = null, $time = null) {
* If called with no parameters, this function will return the current max-age value if any
*
* @param int $seconds if null, the method will return the current s-maxage value
* @return int
* @return int|null
*/
public function sharedMaxAge($seconds = null) {
if ($seconds !== null) {
Expand All @@ -892,7 +892,7 @@ public function sharedMaxAge($seconds = null) {
* If called with no parameters, this function will return the current max-age value if any
*
* @param int $seconds if null, the method will return the current max-age value
* @return int
* @return int|null
*/
public function maxAge($seconds = null) {
if ($seconds !== null) {
Expand Down Expand Up @@ -955,7 +955,7 @@ protected function _setCacheControl() {
* `$response->expires()` Will return the current expiration header value
*
* @param string|\DateTime $time Valid time string or \DateTime instance.
* @return string
* @return string|null
*/
public function expires($time = null) {
if ($time !== null) {
Expand All @@ -979,7 +979,7 @@ public function expires($time = null) {
* `$response->modified()` Will return the current Last-Modified header value
*
* @param string|\DateTime $time Valid time string or \DateTime instance.
* @return string
* @return string|null
*/
public function modified($time = null) {
if ($time !== null) {
Expand Down Expand Up @@ -1024,7 +1024,7 @@ public function notModified() {
*
* @param string|array $cacheVariances a single Vary string or an array
* containing the list for variances.
* @return array
* @return array|null
*/
public function vary($cacheVariances = null) {
if ($cacheVariances !== null) {
Expand Down Expand Up @@ -1056,7 +1056,7 @@ public function vary($cacheVariances = null) {
* @param string $hash the unique hash that identifies this response
* @param bool $weak whether the response is semantically the same as
* other with the same hash or not
* @return string
* @return string|null
*/
public function etag($hash = null, $weak = false) {
if ($hash !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Network/Session.php
Expand Up @@ -352,7 +352,7 @@ public function check($name = null) {
}

if (!isset($_SESSION)) {
return null;
return false;
}

return Hash::get($_SESSION, $name) !== null;
Expand Down
4 changes: 2 additions & 2 deletions src/Network/Socket.php
Expand Up @@ -188,7 +188,7 @@ protected function _connectionErrorHandler($code, $message) {
*/
public function context() {
if (!$this->connection) {
return;
return null;
}
return stream_context_get_options($this->connection);
}
Expand Down Expand Up @@ -232,7 +232,7 @@ public function addresses() {
/**
* Get the last error as a string.
*
* @return string Last error
* @return string|null Last error
*/
public function lastError() {
if (!empty($this->lastError)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/ResultSet.php
Expand Up @@ -255,7 +255,7 @@ public function unserialize($serialized) {
* end of the results simulating the behavior when the result set is backed
* by a statement.
*
* @return array|object
* @return array|object|null
*/
public function first() {
if (isset($this->_results[0])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Routing/Filter/AssetFilter.php
Expand Up @@ -48,7 +48,7 @@ public function beforeDispatch(Event $event) {

$url = urldecode($request->url);
if (strpos($url, '..') !== false || strpos($url, '.') === false) {
return;
return null;
}

$assetFile = $this->_getAssetFile($url);
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/Validator.php
Expand Up @@ -149,7 +149,7 @@ public function hasField($name) {
*
* @param string $name The name under which the provider should be set.
* @param null|object|string $object Provider object or class name.
* @return Validator|object|string
* @return Validator|object|string|null
*/
public function provider($name, $object = null) {
if ($object === null) {
Expand Down
4 changes: 2 additions & 2 deletions src/View/Helper/PaginatorHelper.php
Expand Up @@ -175,7 +175,7 @@ public function current($model = null) {
*
* @param string $model Optional model name. Uses the default if none is specified.
* @param array $options Options for pagination links. See #options for list of keys.
* @return string The name of the key by which the recordset is being sorted, or
* @return string|null The name of the key by which the recordset is being sorted, or
* null if the results are not currently sorted.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::sortKey
*/
Expand Down Expand Up @@ -491,7 +491,7 @@ protected function _hasPage($model, $page) {
/**
* Gets the default model of the paged sets
*
* @return string Model name or null if the pagination isn't initialized.
* @return string|null Model name or null if the pagination isn't initialized.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::defaultModel
*/
public function defaultModel() {
Expand Down

0 comments on commit 25414d8

Please sign in to comment.