Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 cfa55f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Datasource/QueryTrait.php
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/ORM/Behavior/CounterCacheBehavior.php
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/ORM/Query.php
Expand Up @@ -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
{
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit cfa55f2

Please sign in to comment.