Skip to content

Commit

Permalink
Fix errors reported by phpstan.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Mar 18, 2018
1 parent b587cce commit 5f3a304
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 22 deletions.
4 changes: 3 additions & 1 deletion src/Console/CommandRunner.php
Expand Up @@ -257,7 +257,9 @@ public function eventManager(EventManager $events = null)
public function setEventManager(EventManager $events)
{
if ($this->app instanceof PluginApplicationInterface) {
return $this->app->setEventManager($events);
$this->app->setEventManager($events);

return $this;
}

throw new InvalidArgumentException('Cannot set the event manager, the application does not support events.');
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Plugin.php
Expand Up @@ -30,7 +30,7 @@ class Plugin
/**
* Holds a list of all loaded plugins and their configuration
*
* @var \Cake\Core\PluginCollection
* @var \Cake\Core\PluginCollection|null
*/
protected static $plugins;

Expand Down
4 changes: 3 additions & 1 deletion src/Core/PluginCollection.php
Expand Up @@ -48,7 +48,9 @@ class PluginCollection implements Iterator, Countable
protected $names = [];

/**
* @var null|string
* Iterator position.
*
* @var int
*/
protected $position = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/Database/Statement/StatementDecorator.php
Expand Up @@ -300,7 +300,7 @@ public function bind($params, $types)
*
* @param string|null $table table name or sequence to get last insert value from
* @param string|null $column the name of the column representing the primary key
* @return string
* @return string|int
*/
public function lastInsertId($table = null, $column = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Filesystem/Folder.php
Expand Up @@ -923,7 +923,7 @@ public function errors($reset = true)
* Get the real path (taking ".." and such into account)
*
* @param string $path Path to resolve
* @return string|bool The resolved path
* @return string|false The resolved path
*/
public function realpath($path)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Client.php
Expand Up @@ -122,7 +122,7 @@ class Client
* Cookies are indexed by the cookie's domain or
* request host name.
*
* @var \Cake\Http\Client\CookieCollection
* @var \Cake\Http\Cookie\CookieCollection
*/
protected $_cookies;

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Client/Response.php
Expand Up @@ -440,7 +440,7 @@ public function getCookieCollection()
* Get the value of a single cookie.
*
* @param string $name The name of the cookie value.
* @return string|null Either the cookie's value or null when the cookie is undefined.
* @return string|array|null Either the cookie's value or null when the cookie is undefined.
*/
public function getCookie($name)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Http/Server.php
Expand Up @@ -210,7 +210,9 @@ public function eventManager(EventManager $events = null)
public function setEventManager(EventManager $events)
{
if ($this->app instanceof PluginApplicationInterface) {
return $this->app->setEventManager($events);
$this->app->setEventManager($events);

return $this;
}

throw new InvalidArgumentException('Cannot set the event manager, the application does not support events.');
Expand Down
3 changes: 1 addition & 2 deletions src/Http/ServerRequest.php
Expand Up @@ -777,8 +777,7 @@ public function clearDetectorCache()
/**
* Worker for the public is() function
*
* @param string|array $type The type of request you want to check. If an array
* this method will return true if the request matches any type.
* @param string $type The type of request you want to check.
* @param array $args Array of custom detector arguments.
* @return bool Whether or not the request is the type you are checking.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Association.php
Expand Up @@ -502,7 +502,7 @@ public function getConditions()
* @deprecated 3.4.0 Use setConditions()/getConditions() instead.
* @param array|null $conditions list of conditions to be used
* @see \Cake\Database\Query::where() for examples on the format of the array
* @return array
* @return array|callable
*/
public function conditions($conditions = null)
{
Expand Down
25 changes: 20 additions & 5 deletions src/ORM/Table.php
Expand Up @@ -749,7 +749,9 @@ public function displayField($key = null)
'Use setDisplayField()/getDisplayField() instead.'
);
if ($key !== null) {
return $this->setDisplayField($key);
$this->setDisplayField($key);

return $key;
}

return $this->getDisplayField();
Expand Down Expand Up @@ -931,6 +933,7 @@ public function behaviors()
*/
public function getBehavior($name)
{
/** @var \Cake\ORM\Behavior $behavior */
$behavior = $this->_behaviors->get($name);
if ($behavior === null) {
throw new InvalidArgumentException(sprintf(
Expand Down Expand Up @@ -1126,7 +1129,10 @@ public function belongsTo($associated, array $options = [])
{
$options += ['sourceTable' => $this];

return $this->_associations->load(BelongsTo::class, $associated, $options);
/** @var \Cake\ORM\Association\BelongsTo $association */
$association = $this->_associations->load(BelongsTo::class, $associated, $options);

return $association;
}

/**
Expand Down Expand Up @@ -1169,7 +1175,10 @@ public function hasOne($associated, array $options = [])
{
$options += ['sourceTable' => $this];

return $this->_associations->load(HasOne::class, $associated, $options);
/** @var \Cake\ORM\Association\HasOne $association */
$association = $this->_associations->load(HasOne::class, $associated, $options);

return $association;
}

/**
Expand Down Expand Up @@ -1218,7 +1227,10 @@ public function hasMany($associated, array $options = [])
{
$options += ['sourceTable' => $this];

return $this->_associations->load(HasMany::class, $associated, $options);
/** @var \Cake\ORM\Association\HasMany $association */
$association = $this->_associations->load(HasMany::class, $associated, $options);

return $association;
}

/**
Expand Down Expand Up @@ -1269,7 +1281,10 @@ public function belongsToMany($associated, array $options = [])
{
$options += ['sourceTable' => $this];

return $this->_associations->load(BelongsToMany::class, $associated, $options);
/** @var \Cake\ORM\Association\BelongsToMany $association */
$association = $this->_associations->load(BelongsToMany::class, $associated, $options);

return $association;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/ValidationSet.php
Expand Up @@ -54,7 +54,7 @@ class ValidationSet implements ArrayAccess, IteratorAggregate, Countable
*
* @param bool|string|callable|null $validatePresent Deprecated since 3.6.0 ValidationSet::isPresenceRequired() is deprecated as a setter
* Use ValidationSet::requirePresence() instead.
* @return bool|string
* @return bool|string|callable
*/
public function isPresenceRequired($validatePresent = null)
{
Expand Down
1 change: 1 addition & 0 deletions src/View/Helper.php
Expand Up @@ -181,6 +181,7 @@ protected function _confirm($message, $okCode, $cancelCode = '', $options = [])
// We cannot change the key here in 3.x, but the behavior is inverted in this case
$escape = isset($options['escape']) && $options['escape'] === false;
if ($escape) {
/** @var string $confirm */
$confirm = h($confirm);
}

Expand Down
6 changes: 5 additions & 1 deletion src/View/Helper/UrlHelper.php
Expand Up @@ -55,6 +55,7 @@ public function build($url = null, $options = false)
/** @var string $url */
$url = Router::url($url, $options['fullBase']);
if ($options['escape']) {
/** @var string $url */
$url = h($url);
}

Expand Down Expand Up @@ -210,7 +211,10 @@ protected function _encodeUrl($url)
$parts = array_map('rawurlencode', $parts);
$encoded = implode('/', $parts);

return h(str_replace($path, $encoded, $url));
/** @var string $url */
$url = h(str_replace($path, $encoded, $url));

return $url;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/View/ViewBuilder.php
Expand Up @@ -254,7 +254,7 @@ public function setPlugin($name)
/**
* Gets the plugin name to use.
*
* @return string
* @return string|null|false
*/
public function getPlugin()
{
Expand All @@ -267,7 +267,7 @@ public function getPlugin()
* @deprecated 3.4.0 Use setPlugin()/getPlugin() instead.
* @param string|null|false $name Plugin name. If null returns current plugin.
* Use false to remove the current plugin name.
* @return string|$this
* @return string|false|null|$this
*/
public function plugin($name = null)
{
Expand Down Expand Up @@ -341,7 +341,7 @@ public function setTheme($theme)
/**
* Gets the view theme to use.
*
* @return string
* @return string|null|false
*/
public function getTheme()
{
Expand All @@ -354,7 +354,7 @@ public function getTheme()
* @deprecated 3.4.0 Use setTheme()/getTheme() instead.
* @param string|null|false $theme Theme name. If null returns current theme.
* Use false to remove the current theme.
* @return string|$this
* @return string|false|null|$this
*/
public function theme($theme = null)
{
Expand Down

0 comments on commit 5f3a304

Please sign in to comment.