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 Nov 29, 2017
1 parent 13eeb6b commit e475be7
Show file tree
Hide file tree
Showing 33 changed files with 66 additions and 62 deletions.
3 changes: 1 addition & 2 deletions phpstan.neon
Expand Up @@ -15,14 +15,13 @@ parameters:
- '#Call to an undefined method Psr\\Http\\Message\\ResponseInterface::getCookies\(\)#'
- '#Access to an undefined property Psr\\Http\\Message\\UriInterface::\$webroot#'
- '#Access to an undefined property Psr\\Http\\Message\\UriInterface::\$base#'
- '#Call to an undefined method Cake\\Collection\\Iterator\\ZipIterator::getInnerIterator\(\)#'
- '#Call to an undefined method Cake\\ORM\\ResultSet::getInnerIterator\(\)#'
- '#Result of method Cake\\Http\\Response::send\(\) \(void\) is used#'
- '#Method Cake\\View\\Form\\ContextInterface::val\(\) invoked with 2 parameters, 1 required#'
- '#Access to an undefined property Exception::\$queryString#'
- '#Access to an undefined property PHPUnit\\Framework\\Test::\$fixtureManager#'
- '#Method Redis::#'
- '#Call to an undefined method Traversable::getArrayCopy().#'
- '#Variable $config in isset\(\) is never defined#'
earlyTerminatingMethodCalls:
Cake\Shell\Shell:
- abort
Expand Down
6 changes: 3 additions & 3 deletions src/Cache/Engine/ApcEngine.php
Expand Up @@ -14,7 +14,7 @@
*/
namespace Cake\Cache\Engine;

use APCUIterator;
use APCuIterator;
use Cake\Cache\CacheEngine;

/**
Expand Down Expand Up @@ -144,8 +144,8 @@ public function clear($check)
if ($check) {
return true;
}
if (class_exists('APCUIterator', false)) {
$iterator = new APCUIterator(
if (class_exists('APCuIterator', false)) {
$iterator = new APCuIterator(
'/^' . preg_quote($this->_config['prefix'], '/') . '/',
APC_ITER_NONE
);
Expand Down
8 changes: 4 additions & 4 deletions src/Console/ConsoleInputArgument.php
Expand Up @@ -15,7 +15,7 @@
namespace Cake\Console;

use Cake\Console\Exception\ConsoleException;
use SimpleXmlElement;
use SimpleXMLElement;

/**
* An object to represent a single argument used in the command line.
Expand Down Expand Up @@ -178,10 +178,10 @@ public function validChoice($value)
/**
* Append this arguments XML representation to the passed in SimpleXml object.
*
* @param \SimpleXmlElement $parent The parent element.
* @return \SimpleXmlElement The parent with this argument appended.
* @param \SimpleXMLElement $parent The parent element.
* @return \SimpleXMLElement The parent with this argument appended.
*/
public function xml(SimpleXmlElement $parent)
public function xml(SimpleXMLElement $parent)
{
$option = $parent->addChild('argument');
$option->addAttribute('name', $this->_name);
Expand Down
8 changes: 4 additions & 4 deletions src/Console/ConsoleInputOption.php
Expand Up @@ -15,7 +15,7 @@
namespace Cake\Console;

use Cake\Console\Exception\ConsoleException;
use SimpleXmlElement;
use SimpleXMLElement;

/**
* An object to represent a single option used in the command line.
Expand Down Expand Up @@ -240,10 +240,10 @@ public function validChoice($value)
/**
* Append the option's xml into the parent.
*
* @param \SimpleXmlElement $parent The parent element.
* @return \SimpleXmlElement The parent with this option appended.
* @param \SimpleXMLElement $parent The parent element.
* @return \SimpleXMLElement The parent with this option appended.
*/
public function xml(SimpleXmlElement $parent)
public function xml(SimpleXMLElement $parent)
{
$option = $parent->addChild('option');
$option->addAttribute('name', '--' . $this->_name);
Expand Down
8 changes: 4 additions & 4 deletions src/Console/ConsoleInputSubcommand.php
Expand Up @@ -16,7 +16,7 @@
*/
namespace Cake\Console;

use SimpleXmlElement;
use SimpleXMLElement;

/**
* An object to represent a single subcommand used in the command line.
Expand Down Expand Up @@ -126,10 +126,10 @@ public function parser()
/**
* Append this subcommand to the Parent element
*
* @param \SimpleXmlElement $parent The parent element.
* @return \SimpleXmlElement The parent with this subcommand appended.
* @param \SimpleXMLElement $parent The parent element.
* @return \SimpleXMLElement The parent with this subcommand appended.
*/
public function xml(SimpleXmlElement $parent)
public function xml(SimpleXMLElement $parent)
{
$command = $parent->addChild('command');
$command->addAttribute('name', $this->_name);
Expand Down
6 changes: 3 additions & 3 deletions src/Console/HelpFormatter.php
Expand Up @@ -16,7 +16,7 @@

use Cake\Console\Exception\ConsoleException;
use Cake\Utility\Text;
use SimpleXmlElement;
use SimpleXMLElement;

/**
* HelpFormatter formats help for console shells. Can format to either
Expand Down Expand Up @@ -211,12 +211,12 @@ protected function _getMaxLength($collection)
* Get the help as an xml string.
*
* @param bool $string Return the SimpleXml object or a string. Defaults to true.
* @return string|\SimpleXmlElement See $string
* @return string|\SimpleXMLElement See $string
*/
public function xml($string = true)
{
$parser = $this->_parser;
$xml = new SimpleXmlElement('<shell></shell>');
$xml = new SimpleXMLElement('<shell></shell>');
$xml->addChild('command', $parser->getCommand());
$xml->addChild('description', $parser->getDescription());

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Controller.php
Expand Up @@ -123,15 +123,15 @@ class Controller implements EventListenerInterface, EventDispatcherInterface
* This object contains all the information about a request and several methods for reading
* additional information about the request.
*
* @var \Cake\Http\ServerRequest
* @var \Cake\Http\ServerRequest|null
* @link https://book.cakephp.org/3.0/en/controllers/request-response.html#request
*/
public $request;

/**
* An instance of a Response object that contains information about the impending response
*
* @var \Cake\Http\Response
* @var \Cake\Http\Response|null
* @link https://book.cakephp.org/3.0/en/controllers/request-response.html#response
*/
public $response;
Expand Down
1 change: 1 addition & 0 deletions src/Core/ObjectRegistry.php
Expand Up @@ -126,6 +126,7 @@ protected function _checkDuplicate($name, $config)
if (empty($config)) {
return;
}
/* @var \Cake\Core\InstanceConfigTrait $existing */
$existingConfig = $existing->getConfig();
unset($config['enabled'], $existingConfig['enabled']);

Expand Down
4 changes: 2 additions & 2 deletions src/Database/Connection.php
Expand Up @@ -827,7 +827,7 @@ public function logger($instance = null)
/**
* Sets a logger
*
* @param object $logger Logger object
* @param \Cake\Database\Log\QueryLogger $logger Logger object
* @return $this
*/
public function setLogger($logger)
Expand All @@ -840,7 +840,7 @@ public function setLogger($logger)
/**
* Gets the logger object
*
* @return object logger instance
* @return \Cake\Database\Log\QueryLogger logger instance
*/
public function getLogger()
{
Expand Down
8 changes: 4 additions & 4 deletions src/Database/Log/LoggingStatement.php
Expand Up @@ -110,8 +110,8 @@ public function bindValue($column, $value, $type = 'string')
* it returns the currently setup logger instance
*
* @deprecated 3.5.0 Use getLogger() and setLogger() instead.
* @param object|null $instance Logger object instance.
* @return object|null Logger instance
* @param \Cake\Database\Log\QueryLogger|null $instance Logger object instance.
* @return \Cake\Database\Log\QueryLogger|null Logger instance
*/
public function logger($instance = null)
{
Expand All @@ -125,7 +125,7 @@ public function logger($instance = null)
/**
* Sets a logger
*
* @param object $logger Logger object
* @param \Cake\Database\Log\QueryLogger $logger Logger object
* @return void
*/
public function setLogger($logger)
Expand All @@ -136,7 +136,7 @@ public function setLogger($logger)
/**
* Gets the logger object
*
* @return object logger instance
* @return \Cake\Database\Log\QueryLogger logger instance
*/
public function getLogger()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Event/EventManager.php
Expand Up @@ -63,7 +63,7 @@ class EventManager
/**
* Enables automatic adding of events to the event list object if it is present.
*
* @param bool
* @var bool
*/
protected $_trackEvents = false;

Expand Down
8 changes: 4 additions & 4 deletions src/Http/Cookie/Cookie.php
Expand Up @@ -16,7 +16,7 @@
use Cake\Chronos\Chronos;
use Cake\Utility\Hash;
use DateTimeImmutable;
use DateTimezone;
use DateTimeZone;
use InvalidArgumentException;

/**
Expand Down Expand Up @@ -146,7 +146,7 @@ public function __construct(
$this->validateBool($secure);
$this->secure = $secure;
if ($expiresAt) {
$expiresAt = $expiresAt->setTimezone(new DateTimezone('GMT'));
$expiresAt = $expiresAt->setTimezone(new DateTimeZone('GMT'));
}
$this->expiresAt = $expiresAt;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ public function isHttpOnly()
public function withExpiry($dateTime)
{
$new = clone $this;
$new->expiresAt = $dateTime->setTimezone(new DateTimezone('GMT'));
$new->expiresAt = $dateTime->setTimezone(new DateTimeZone('GMT'));

return $new;
}
Expand Down Expand Up @@ -439,7 +439,7 @@ public function getFormattedExpires()
*/
public function isExpired($time = null)
{
$time = $time ?: new DateTimeImmutable('now', new DateTimezone('UTC'));
$time = $time ?: new DateTimeImmutable('now', new DateTimeZone('UTC'));
if (!$this->expiresAt) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Middleware/CsrfProtectionMiddleware.php
Expand Up @@ -157,7 +157,7 @@ protected function _addTokenToRequest($token, ServerRequest $request)
* @param string $token The token to add.
* @param \Cake\Http\ServerRequest $request The request to validate against.
* @param \Cake\Http\Response $response The response.
* @return @param \Cake\Http\Response $response Modified response.
* @return \Cake\Http\Response $response Modified response.
*/
protected function _addTokenCookie($token, ServerRequest $request, Response $response)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Server.php
Expand Up @@ -109,7 +109,7 @@ public function emit(ResponseInterface $response, EmitterInterface $emitter = nu
/**
* Set the application.
*
* @param Cake\Core\HttpApplicationInterface $app The application to set.
* @param \Cake\Core\HttpApplicationInterface $app The application to set.
* @return $this
*/
public function setApp(HttpApplicationInterface $app)
Expand Down
2 changes: 1 addition & 1 deletion src/I18n/I18n.php
Expand Up @@ -168,7 +168,7 @@ public static function translator($name = 'default', $locale = null, callable $l
* ```
*
* @param string $name The domain of the translation messages.
* @param callable|null $loader A callback function or callable class responsible for
* @param callable $loader A callback function or callable class responsible for
* constructing a translations package instance.
* @param string|null $locale The locale for the translator.
* @return void
Expand Down
8 changes: 4 additions & 4 deletions src/I18n/RelativeTimeFormatter.php
Expand Up @@ -15,7 +15,7 @@
namespace Cake\I18n;

use Cake\Chronos\ChronosInterface;
use DatetimeInterface;
use DateTimeInterface;

/**
* Helper class for formatting relative dates & times.
Expand Down Expand Up @@ -91,7 +91,7 @@ public function diffForHumans(ChronosInterface $date, ChronosInterface $other =
* @return string Relative time string.
* @see \Cake\I18n\Time::timeAgoInWords()
*/
public function timeAgoInWords(DatetimeInterface $time, array $options = [])
public function timeAgoInWords(DateTimeInterface $time, array $options = [])
{
$options = $this->_options($options, FrozenTime::class);
if ($options['timezone'] && $time instanceof ChronosInterface) {
Expand Down Expand Up @@ -276,12 +276,12 @@ protected function _diffData($futureTime, $pastTime, $backwards, $options)
/**
* Format a into a relative date string.
*
* @param \DatetimeInterface $date The date to format.
* @param \DateTimeInterface $date The date to format.
* @param array $options Array of options.
* @return string Relative date string.
* @see \Cake\I18n\Date::timeAgoInWords()
*/
public function dateAgoInWords(DatetimeInterface $date, array $options = [])
public function dateAgoInWords(DateTimeInterface $date, array $options = [])
{
$options = $this->_options($options, FrozenDate::class);
if ($options['timezone'] && $date instanceof ChronosInterface) {
Expand Down
6 changes: 3 additions & 3 deletions src/Mailer/Email.php
Expand Up @@ -33,7 +33,7 @@
use PDO;
use RuntimeException;
use Serializable;
use SimpleXmlElement;
use SimpleXMLElement;

/**
* CakePHP Email class.
Expand Down Expand Up @@ -2694,7 +2694,7 @@ protected function _getContentTypeCharset()
* It has certain limitations for viewVars that are good to know:
*
* - ORM\Query executed and stored as resultset
* - SimpleXmlElements stored as associative array
* - SimpleXMLElements stored as associative array
* - Exceptions stored as strings
* - Resources, \Closure and \PDO are not supported.
*
Expand Down Expand Up @@ -2784,7 +2784,7 @@ public function serialize()
{
$array = $this->jsonSerialize();
array_walk_recursive($array, function (&$item, $key) {
if ($item instanceof SimpleXmlElement) {
if ($item instanceof SimpleXMLElement) {
$item = json_decode(json_encode((array)$item), true);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Association.php
Expand Up @@ -1431,7 +1431,7 @@ abstract public function isOwningSide(Table $side);
* the saving operation to the target table.
*
* @param \Cake\Datasource\EntityInterface $entity the data to be saved
* @param array|\ArrayObject $options The options for saving associated data.
* @param array $options The options for saving associated data.
* @return bool|\Cake\Datasource\EntityInterface false if $entity could not be saved, otherwise it returns
* the saved entity
* @see \Cake\ORM\Table::save()
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/EagerLoadable.php
Expand Up @@ -35,7 +35,7 @@ class EagerLoadable
/**
* A list of other associations to load from this level.
*
* @var \Cake\Orm\EagerLoadable[]
* @var \Cake\ORM\EagerLoadable[]
*/
protected $_associations = [];

Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Query.php
Expand Up @@ -424,7 +424,7 @@ public function clearContain()
* Used to recursively add contained association column types to
* the query.
*
* @param \Cake\ORM\Table|\Cake\Datasource\RepositoryInterface $table The table instance to pluck associations from.
* @param \Cake\ORM\Table $table The table instance to pluck associations from.
* @param \Cake\Database\TypeMap $typeMap The typemap to check for columns in.
* This typemap is indirectly mutated via Cake\ORM\Query::addDefaultTypes()
* @param array $associations The nested tree of associations to walk.
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/TableRegistry.php
Expand Up @@ -97,7 +97,7 @@ public static function getTableLocator()
/**
* Sets singleton instance of LocatorInterface implementation.
*
* @param \Cake\ORM\Locator\LocatorInterface|null $tableLocator Instance of a locator to use.
* @param \Cake\ORM\Locator\LocatorInterface $tableLocator Instance of a locator to use.
* @return void
*/
public static function setTableLocator(LocatorInterface $tableLocator)
Expand Down
2 changes: 1 addition & 1 deletion src/Routing/RouteCollection.php
Expand Up @@ -181,7 +181,7 @@ public function parse($url, $method = '')
/**
* Takes the ServerRequestInterface, iterates the routes until one is able to parse the route.
*
* @param \Psr\Http\Messages\ServerRequestInterface $request The request to parse route data from.
* @param \Psr\Http\Message\ServerRequestInterface $request The request to parse route data from.
* @return array An array of request parameters parsed from the URL.
* @throws \Cake\Routing\Exception\MissingRouteException When a URL has no matching route.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Shell/CommandListShell.php
Expand Up @@ -19,7 +19,7 @@
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Utility\Inflector;
use SimpleXmlElement;
use SimpleXMLElement;

/**
* Shows a list of commands available from the console.
Expand Down Expand Up @@ -128,7 +128,7 @@ protected function _asText($shellList)
protected function _asXml($shellList)
{
$plugins = Plugin::loaded();
$shells = new SimpleXmlElement('<shells></shells>');
$shells = new SimpleXMLElement('<shells></shells>');
foreach ($shellList as $plugin => $commands) {
foreach ($commands as $command) {
$callable = $command;
Expand Down

0 comments on commit e475be7

Please sign in to comment.