Skip to content
Permalink
Browse files

Fix callable checks. Add concrete for interface annotations as long a…

…s they are still used in parallel.
  • Loading branch information...
dereuromark committed Sep 25, 2017
1 parent 71fb923 commit cfa55f29a7eb39bd70e50c54b3807d7291c78382
Showing with 7 additions and 4 deletions.
  1. +1 −1 src/Datasource/QueryTrait.php
  2. +2 −2 src/ORM/Behavior/CounterCacheBehavior.php
  3. +4 −1 src/ORM/Query.php
@@ -28,7 +28,7 @@ trait QueryTrait
/**
* Instance of a table object this query is bound to
*
* @var \Cake\Datasource\RepositoryInterface
* @var \Cake\ORM\Table|\Cake\Datasource\RepositoryInterface
*/
protected $_repository;
@@ -227,7 +227,7 @@ protected function _processAssociation(Event $event, EntityInterface $entity, As
continue;
}
if (!is_string($config) && is_callable($config)) {
if (is_callable($config)) {
$count = $config($event, $entity, $this->_table, false);
} else {
$count = $this->_getCount($config, $countConditions);
@@ -236,7 +236,7 @@ protected function _processAssociation(Event $event, EntityInterface $entity, As
$assoc->getTarget()->updateAll([$field => $count], $updateConditions);
if (isset($updateOriginalConditions)) {
if (!is_string($config) && is_callable($config)) {
if (is_callable($config)) {
$count = $config($event, $entity, $this->_table, true);
} else {
$count = $this->_getCount($config, $countOriginalConditions);
@@ -65,6 +65,7 @@
* with the first rows of the query and each of the items, then the second rows and so on.
* @method \Cake\Collection\CollectionInterface chunk($size) Groups the results in arrays of $size rows each.
* @method bool isEmpty() Returns true if this query found no results.
* @mixin \Cake\Datasource\QueryTrait
*/
class Query extends DatabaseQuery implements JsonSerializable, QueryInterface
{
@@ -423,7 +424,7 @@ public function clearContain()
* Used to recursively add contained association column types to
* the query.
*
* @param \Cake\ORM\Table $table The table instance to pluck associations from.
* @param \Cake\Datasource\RepositoryInterface $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.
@@ -432,6 +433,7 @@ public function clearContain()
protected function _addAssociationsToTypeMap($table, $typeMap, $associations)
{
foreach ($associations as $name => $nested) {
/* @var \Cake\ORM\Table $table */
$association = $table->association($name);
if (!$association) {
continue;
@@ -998,6 +1000,7 @@ public function triggerBeforeFind()
if (!$this->_beforeFindFired && $this->_type === 'select') {
$table = $this->repository();
$this->_beforeFindFired = true;
/* @var \Cake\Event\EventDispatcherInterface $table */
$table->dispatchEvent('Model.beforeFind', [
$this,
new ArrayObject($this->_options),

0 comments on commit cfa55f2

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