Skip to content

Commit

Permalink
Fix phpstan reported doc block and casting issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Sep 28, 2018
1 parent 35fe0e5 commit 64ef1f0
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 16 deletions.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -42,7 +42,8 @@
},
"require-dev": {
"phpunit/phpunit": "^5.7.14|^6.0",
"cakephp/cakephp-codesniffer": "^3.0"
"cakephp/cakephp-codesniffer": "^3.0",
"phpstan/phpstan": "^0.10"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Component/FlashComponent.php
Expand Up @@ -86,7 +86,7 @@ public function __construct(ComponentRegistry $registry, array $config = [])
*/
public function set($message, array $options = [])
{
$options += $this->getConfig();
$options += (array)$this->getConfig();

if ($message instanceof Exception) {
if (!isset($options['params']['code'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Log/LoggingStatement.php
Expand Up @@ -78,7 +78,7 @@ public function execute($params = null)
*/
protected function _log($query, $params, $startTime)
{
$query->took = round((microtime(true) - $startTime) * 1000, 0);
$query->took = (int)round((microtime(true) - $startTime) * 1000, 0);
$query->params = $params ?: $this->_compiledParams;
$query->query = $this->queryString;
$this->getLogger()->log($query);
Expand Down
1 change: 1 addition & 0 deletions src/Database/SchemaCache.php
Expand Up @@ -93,6 +93,7 @@ public function clear($name = null)
*
* @param \Cake\Database\Connection $connection Connection object
* @return \Cake\Database\Schema\Collection|\Cake\Database\Schema\CachedCollection
* @throws \RuntimeException If given connection object is not compatible with schema caching
*/
public function getSchema(Connection $connection)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Datasource/QueryTrait.php
Expand Up @@ -61,7 +61,7 @@ trait QueryTrait
/**
* A query cacher instance if this query has caching enabled.
*
* @var \Cake\Datasource\QueryCacher
* @var \Cake\Datasource\QueryCacher|null
*/
protected $_cache;

Expand Down
4 changes: 3 additions & 1 deletion src/Datasource/RepositoryInterface.php
Expand Up @@ -18,8 +18,10 @@
* Describes the methods that any class representing a data storage should
* comply with.
*
* @method $this setAlias($alias)
* @method $this setAlias(string $alias)
* @method string getAlias()
* @method $this setRegistryAlias(string $alias)
* @method string getRegistryAlias()
*/
interface RepositoryInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Event/EventDispatcherTrait.php
Expand Up @@ -24,7 +24,7 @@ trait EventDispatcherTrait
* Instance of the Cake\Event\EventManager this object is using
* to dispatch inner events.
*
* @var \Cake\Event\EventManager
* @var \Cake\Event\EventManagerInterface|\Cake\Event\EventManager
*/
protected $_eventManager;

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Client.php
Expand Up @@ -179,7 +179,7 @@ public function __construct($config = [])
/**
* Get the cookies stored in the Client.
*
* @return \Cake\Http\Client\CookieCollection
* @return \Cake\Http\Cookie\CookieCollection
*/
public function cookies()
{
Expand Down
5 changes: 4 additions & 1 deletion src/Http/ControllerFactory.php
Expand Up @@ -43,7 +43,10 @@ public function create(ServerRequest $request, Response $response)
$this->missingController($request);
}

return $reflection->newInstance($request, $response);
/** @var \Cake\Controller\Controller $controller */
$controller = $reflection->newInstance($request, $response);

return $controller;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Server.php
Expand Up @@ -167,7 +167,7 @@ public function setRunner(Runner $runner)
/**
* Get the application's event manager or the global one.
*
* @return \Cake\Event\EventManagerInterface
* @return \Cake\Event\EventManager
*/
public function getEventManager()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Session.php
Expand Up @@ -228,7 +228,7 @@ public function __construct(array $config = [])
$this->engine($class, $config['handler']);
}

$this->_lifetime = ini_get('session.gc_maxlifetime');
$this->_lifetime = (int)ini_get('session.gc_maxlifetime');
$this->_isCLI = (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg');
session_register_shutdown();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Session/DatabaseSession.php
Expand Up @@ -62,7 +62,7 @@ public function __construct(array $config = [])
$this->_table = $tableLocator->get($config['model']);
}

$this->_timeout = ini_get('session.gc_maxlifetime');
$this->_timeout = (int)ini_get('session.gc_maxlifetime');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/I18n/DateFormatTrait.php
Expand Up @@ -156,7 +156,7 @@ public function nice($timezone = null, $locale = null)
* in which the date will be displayed. The timezone stored for this object will not
* be changed.
* @param string|null $locale The locale name in which the date should be displayed (e.g. pt-BR)
* @return string Formatted and translated date string
* @return string|int Formatted and translated date string
*/
public function i18nFormat($format = null, $timezone = null, $locale = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/ResultSet.php
Expand Up @@ -65,7 +65,7 @@ class ResultSet implements ResultSetInterface
/**
* Default table instance
*
* @var \Cake\ORM\Table
* @var \Cake\ORM\Table|\Cake\Datasource\RepositoryInterface
*/
protected $_defaultTable;

Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Table.php
Expand Up @@ -494,7 +494,7 @@ public function registryAlias($registryAlias = null)
/**
* Sets the connection instance.
*
* @param \Cake\Database\Connection|\Cake\Datasource\ConnectionInterface $connection The connection instance
* @param \Cake\Database\Connection $connection The connection instance
* @return $this
*/
public function setConnection(ConnectionInterface $connection)
Expand Down
2 changes: 1 addition & 1 deletion src/Shell/ServerShell.php
Expand Up @@ -82,7 +82,7 @@ public function startup()
$this->_host = $this->param('host');
}
if ($this->param('port')) {
$this->_port = $this->param('port');
$this->_port = (int)$this->param('port');
}
if ($this->param('document_root')) {
$this->_documentRoot = $this->param('document_root');
Expand Down
5 changes: 4 additions & 1 deletion src/TestSuite/MiddlewareDispatcher.php
Expand Up @@ -68,6 +68,7 @@ class MiddlewareDispatcher
* @param string|null $class The application class name. Defaults to App\Application.
* @param array|null $constructorArgs The constructor arguments for your application class.
* Defaults to `['./config']`
* @throws \LogicException If it cannot load class for use in integration testing.
*/
public function __construct($test, $class = null, $constructorArgs = null)
{
Expand All @@ -77,7 +78,9 @@ public function __construct($test, $class = null, $constructorArgs = null)

try {
$reflect = new ReflectionClass($this->_class);
$this->app = $reflect->newInstanceArgs($this->_constructorArgs);
/** @var \Cake\Core\HttpApplicationInterface $app */
$app = $reflect->newInstanceArgs($this->_constructorArgs);
$this->app = $app;
} catch (ReflectionException $e) {
throw new LogicException(sprintf('Cannot load "%s" for use in integration testing.', $this->_class));
}
Expand Down

0 comments on commit 64ef1f0

Please sign in to comment.