Skip to content
Permalink
Browse files

Update phpstan to v0.10.

  • Loading branch information...
ADmad committed Jul 26, 2018
1 parent 08d9b9d commit cd9f495fb6a11cc5dba081d6ae74e5b3c7806984
@@ -72,7 +72,7 @@ script:
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.0 ]]; then vendor/bin/phpunit; fi

- if [[ $PHPCS = 1 ]]; then composer cs-check; fi
- if [[ $PHPSTAN = 1 ]]; then composer require --dev "phpstan/phpstan:0.9.*" && vendor/bin/phpstan analyse -c phpstan.neon -l 2 src; fi
- if [[ $PHPSTAN = 1 ]]; then composer require --dev "phpstan/phpstan:^0.10" && vendor/bin/phpstan analyse -c phpstan.neon -l 2 src; fi

after_success:
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi
@@ -11,7 +11,6 @@ parameters:
- '#Access to undefined constant PDO::SQLSRV_ATTR_ENCODING#'
- '#Access to undefined constant PDO::SQLSRV_ENCODING_BINARY#'
- '#Constant XC_TYPE_VAR not found#'
- '#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#'
- '#Result of method Cake\\Http\\Response::send\(\) \(void\) is used#'
@@ -23,10 +22,14 @@ parameters:
- '#Variable \$config in isset\(\) is never defined#'
- '#Call to static method id\(\) on an unknown class PHPUnit_Runner_Version#'
- '#Call to an undefined method DateTimeInterface::i18nFormat\(\)#'
- '#Call to an undefined method object::__toString\(\)#'
- '#Call to an undefined method object::toArray\(\)#'
- '#Call to an undefined method object::__debugInfo\(\)#'
- '#Cannot call method lastInsertId\(\) on null#'
- '#Call to an undefined method Cake\\Auth\\Storage\\StorageInterface::getConfig\(\)#'
- '#Call to an undefined method Cake\\Auth\\Storage\\StorageInterface::setConfig\(\)#'
- '#Variable \$_SESSION in isset\(\) always exists and is not nullable#'
- '#Call to an undefined method Traversable::getInnerIterator\(\)#'
- '#PHPDoc tag @throws with type PHPUnit\\Exception is not subtype of Throwable#'
- '#Call to an undefined method Cake\\Console\\ConsoleOutput\|PHPUnit_Framework_MockObject_MockObject::messages\(\)#'
- '#Binary operation "\+=" between \(array\&hasOffset\(.*\)\) and array results in an error#'
earlyTerminatingMethodCalls:
Cake\Shell\Shell:
- abort
@@ -67,6 +67,7 @@ public function __construct($items, callable $callback)
*/
public function unwrap()
{
/** @var \IteratorIterator $filter */
$filter = $this->getInnerIterator();
$iterator = $filter->getInnerIterator();
@@ -77,7 +77,7 @@ public function read()
public function dataAvailable($timeout = 0)
{
$readFds = [$this->_input];
$readyFds = stream_select($readFds, $writeFds, $errorFds, $timeout);
$readyFds = stream_select($readFds, null, null, $timeout);
return ($readyFds > 0);
}
@@ -881,7 +881,7 @@ public function constructAuthenticate()
*
* @param \Cake\Auth\Storage\StorageInterface|null $storage Sets provided
* object as storage or if null returns configured storage object.
* @return \Cake\Auth\Storage\StorageInterface|\Cake\Core\InstanceConfigTrait|null
* @return \Cake\Auth\Storage\StorageInterface|null
*/
public function storage(StorageInterface $storage = null)
{
@@ -337,7 +337,7 @@ protected function _delete($name)
$controller->response = $controller->response->withCookie($name, [
'value' => '',
'expire' => $expires->format('U') - 42000,
'expire' => (int)$expires->format('U') - 42000,
'path' => $config['path'],
'domain' => $config['domain'],
'secure' => $config['secure'],
@@ -104,7 +104,7 @@ protected function loadConfig()
*
* @param string $name The plugin name to locate a path for. Will return '' when a plugin cannot be found.
* @return string
* @throws Cake\Core\Exception\MissingPluginException when a plugin path cannot be resolved.
* @throws \Cake\Core\Exception\MissingPluginException when a plugin path cannot be resolved.
* @internal
*/
public function findPath($name)
@@ -1093,7 +1093,7 @@ protected function _nestedErrors($field)
/**
* Read the error(s) from one or many objects.
*
* @param array|\Cake\Datasource\EntityTrait $object The object to read errors from.
* @param array|\Cake\Datasource\EntityInterface $object The object to read errors from.
* @param string|null $path The field name for errors.
* @return array
*/
@@ -481,9 +481,11 @@ public function firstOrFail()
{
$entity = $this->first();
if (!$entity) {
/** @var \Cake\ORM\Table $table */
$table = $this->getRepository();
throw new RecordNotFoundException(sprintf(
'Record not found in table "%s"',
$this->getRepository()->getTable()
$table->getTable()
));
}
@@ -99,7 +99,10 @@ public function addPlugin($name, array $config = [])
$plugin = $name;
}
if (!$plugin instanceof PluginInterface) {
throw new InvalidArgumentException("The `{$name}` plugin does not implement Cake\Core\PluginInterface.");
throw new InvalidArgumentException(sprintf(
"The `%s` plugin does not implement Cake\Core\PluginInterface.",
get_class($plugin)
));
}
$this->plugins->add($plugin);
@@ -39,7 +39,10 @@ class CallbackStream extends BaseCallbackStream
public function getContents()
{
$callback = $this->detach();
$result = $callback ? $callback() : '';
$result = '';
if (is_callable($callback)) {
$result = $callback();
}
if (!is_string($result)) {
return '';
}
@@ -608,7 +608,7 @@ public function renew()
*/
protected function _timedOut()
{
$time = $this->read('Config.time');
$time = (int)$this->read('Config.time');
$result = false;
$checkTime = $time !== null && $this->_lifetime > 0;
@@ -180,15 +180,15 @@ public function timeAgoInWords(DateTimeInterface $time, array $options = [])
/**
* Calculate the data needed to format a relative difference string.
*
* @param \DateTime $futureTime The time from the future.
* @param \DateTime $pastTime The time from the past.
* @param int|string $futureTime The timestamp from the future.
* @param int|string $pastTime The timestamp from the past.
* @param bool $backwards Whether or not the difference was backwards.
* @param array $options An array of options.
* @return array An array of values.
*/
protected function _diffData($futureTime, $pastTime, $backwards, $options)
{
$diff = $futureTime - $pastTime;
$diff = (int)$futureTime - (int)$pastTime;
// If more than a week, then take into account the length of months
if ($diff >= 604800) {
@@ -1129,6 +1129,7 @@ public function find($type = null, array $options = [])
protected function _appendJunctionJoin($query, $conditions)
{
$name = $this->_junctionAssociationName();
/** @var array $joins */
$joins = $query->join();
$matching = [
$name => [
@@ -1386,6 +1387,7 @@ protected function _collectJointEntities($sourceEntity, $targetEntities)
$assocForeignKey = (array)$belongsTo->getForeignKey();
$sourceKey = $sourceEntity->extract((array)$source->getPrimaryKey());
$unions = [];
foreach ($missing as $key) {
$unions[] = $hasMany->find('all')
->where(array_combine($foreignKey, $sourceKey))
@@ -61,7 +61,7 @@ class TimestampBehavior extends Behavior
/**
* Current timestamp
*
* @var \DateTime
* @var \Cake\I18n\Time
*/
protected $_ts;
@@ -136,7 +136,7 @@ public function implementedEvents()
*
* @param \DateTime|null $ts Timestamp
* @param bool $refreshTimestamp If true timestamp is refreshed.
* @return \DateTime
* @return \Cake\I18n\Time
*/
public function timestamp(DateTime $ts = null, $refreshTimestamp = false)
{
@@ -248,6 +248,7 @@ protected function _validate($data, $options, $isNew)
} elseif (is_string($options['validate'])) {
$validator = $this->_table->getValidator($options['validate']);
} elseif (is_object($options['validate'])) {
/** @var \Cake\Validation\Validator $validator */
$validator = $options['validate'];
}
@@ -1084,10 +1084,11 @@ public function all()
public function triggerBeforeFind()
{
if (!$this->_beforeFindFired && $this->_type === 'select') {
$table = $this->getRepository();
$this->_beforeFindFired = true;
/* @var \Cake\Event\EventDispatcherInterface $table */
$table->dispatchEvent('Model.beforeFind', [
/** @var \Cake\Event\EventDispatcherInterface $repository */
$repository = $this->getRepository();
$repository->dispatchEvent('Model.beforeFind', [
$this,
new ArrayObject($this->_options),
!$this->isEagerLoaded()
@@ -1146,11 +1147,14 @@ protected function _transformQuery()
return;
}
/** @var \Cake\ORM\Table $repository */
$repository = $this->getRepository();
if (empty($this->_parts['from'])) {
$this->from([$this->_repository->getAlias() => $this->_repository->getTable()]);
$this->from([$repository->getAlias() => $repository->getTable()]);
}
$this->_addDefaultFields();
$this->getEagerLoader()->attachAssociations($this, $this->_repository, !$this->_hasFields);
$this->getEagerLoader()->attachAssociations($this, $repository, !$this->_hasFields);
$this->_addDefaultSelectTypes();
}
@@ -1165,13 +1169,16 @@ protected function _addDefaultFields()
$select = $this->clause('select');
$this->_hasFields = true;
/** @var \Cake\ORM\Table $repository */
$repository = $this->getRepository();
if (!count($select) || $this->_autoFields === true) {
$this->_hasFields = false;
$this->select($this->getRepository()->getSchema()->columns());
$this->select($repository->getSchema()->columns());
$select = $this->clause('select');
}
$aliased = $this->aliasFields($select, $this->getRepository()->getAlias());
$aliased = $this->aliasFields($select, $repository->getAlias());
$this->select($aliased, true);
}
@@ -1208,7 +1215,10 @@ protected function _addDefaultSelectTypes()
*/
public function find($finder, array $options = [])
{
return $this->getRepository()->callFinder($finder, $this, $options);
/** @var \Cake\ORM\Table $table */
$table = $this->getRepository();
return $table->callFinder($finder, $this, $options);
}
/**
@@ -1235,7 +1245,11 @@ protected function _dirty()
*/
public function update($table = null)
{
$table = $table ?: $this->getRepository()->getTable();
if (!$table) {
/** @var \Cake\ORM\Table $repository */
$repository = $this->getRepository();
$table = $repository->getTable();
}
return parent::update($table);
}
@@ -1251,8 +1265,9 @@ public function update($table = null)
*/
public function delete($table = null)
{
$repo = $this->getRepository();
$this->from([$repo->getAlias() => $repo->getTable()]);
/** @var \Cake\ORM\Table $repository */
$repository = $this->getRepository();
$this->from([$repository->getAlias() => $repository->getTable()]);
return parent::delete();
}
@@ -1272,7 +1287,9 @@ public function delete($table = null)
*/
public function insert(array $columns, array $types = [])
{
$table = $this->getRepository()->getTable();
/** @var \Cake\ORM\Table $repository */
$repository = $this->getRepository();
$table = $repository->getTable();
$this->into($table);
return parent::insert($columns, $types);
@@ -175,6 +175,7 @@ class ResultSet implements ResultSetInterface
*/
public function __construct($query, $statement)
{
/** @var \Cake\ORM\Table $repository */
$repository = $query->getRepository();
$this->_statement = $statement;
$this->_driver = $query->getConnection()->getDriver();
@@ -447,7 +448,7 @@ protected function _getTypes($table, $fields)
{
$types = [];
$schema = $table->getSchema();
$map = array_keys(Type::map() + ['string' => 1, 'text' => 1, 'boolean' => 1]);
$map = array_keys((array)Type::map() + ['string' => 1, 'text' => 1, 'boolean' => 1]);
$typeMap = array_combine(
$map,
array_map(['Cake\Database\Type', 'build'], $map)
@@ -1894,7 +1894,7 @@ public function save(EntityInterface $entity, $options = [])
$options = $options->toArray();
}
$options = new ArrayObject($options + [
$options = new ArrayObject((array)$options + [
'atomic' => true,
'associated' => true,
'checkRules' => true,
@@ -2272,7 +2272,7 @@ public function saveMany($entities, $options = [])
*/
public function delete(EntityInterface $entity, $options = [])
{
$options = new ArrayObject($options + [
$options = new ArrayObject((array)$options + [
'atomic' => true,
'checkRules' => true,
'_primary' => true,
@@ -124,7 +124,6 @@ protected function prepareRouteCollection()
* @param \Psr\Http\Message\ResponseInterface $response The response.
* @param callable $next The next middleware to call.
* @return \Psr\Http\Message\ResponseInterface A response.
* @throws \Cake\Routing\InvalidArgumentException
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next)
{
@@ -388,7 +388,7 @@ public function namePrefix($value = null)
*/
public function resources($name, $options = [], $callback = null)
{
if (is_callable($options) && $callback === null) {
if (is_callable($options)) {
$callback = $options;
$options = [];
}
@@ -982,7 +982,7 @@ public function plugin($name, $options = [], $callback = null)
*/
public function scope($path, $params, $callback = null)
{
if ($callback === null) {
if (is_callable($params)) {
$callback = $params;
$params = [];
}
@@ -1034,7 +1034,7 @@ public static function parseFileSize($size, $default = false)
$i = array_search(substr($size, -1), ['K', 'M', 'G', 'T', 'P']);
}
if ($i !== false) {
$size = substr($size, 0, $l);
$size = (float)substr($size, 0, $l);
return $size * pow(1024, $i + 1);
}
@@ -1108,7 +1108,7 @@ public static function luhn($check)
}
for ($position = ($length % 2); $position < $length; $position += 2) {
$number = $check[$position] * 2;
$number = (int)$check[$position] * 2;
$sum += ($number < 10) ? $number : $number - 9;
}
@@ -371,7 +371,7 @@ public function format($date, $format = null, $invalid = false, $timezone = null
*/
public function i18nFormat($date, $format = null, $invalid = false, $timezone = null)
{
if (!isset($date)) {
if ($date === null) {
return $invalid;
}
$timezone = $this->_getTimezone($timezone);
@@ -23,7 +23,7 @@ class AssociationTableMixinClassReflectionExtension implements PropertiesClassRe
* @param Broker $broker Class reflection broker
* @return void
*/
public function setBroker(Broker $broker)
public function setBroker(Broker $broker): void
{
$this->broker = $broker;
}

0 comments on commit cd9f495

Please sign in to comment.
You can’t perform that action at this time.