Navigation Menu

Skip to content

Commit

Permalink
Follow up on #11439 regarding entity phpdoc typehinting.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Nov 20, 2017
1 parent ec5f656 commit 9a308f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Datasource/RepositoryInterface.php
Expand Up @@ -217,7 +217,7 @@ public function patchEntity(EntityInterface $entity, array $data, array $options
* $article = $this->Articles->patchEntities($articles, $this->request->getData());
* ```
*
* @param array|\Traversable $entities the entities that will get the
* @param \Cake\Datasource\EntityInterface[]|\Traversable $entities the entities that will get the
* data merged in
* @param array $data list of arrays to be merged into the entities
* @param array $options A list of options for the objects hydration.
Expand Down
17 changes: 10 additions & 7 deletions src/ORM/Marshaller.php
Expand Up @@ -106,6 +106,7 @@ protected function _buildPropertyMap($data, $options)
}
if (isset($options['isMerge'])) {
$callback = function ($value, $entity) use ($assoc, $nested) {
/* @var \Cake\Datasource\EntityInterface $entity */
$options = $nested + ['associated' => [], 'association' => $assoc];

return $this->_mergeAssociation($entity->get($assoc->getProperty()), $assoc, $value, $options);
Expand Down Expand Up @@ -364,7 +365,7 @@ public function many(array $data, array $options = [])
* @param \Cake\ORM\Association\BelongsToMany $assoc The association to marshal.
* @param array $data The data to convert into entities.
* @param array $options List of options.
* @return array An array of built entities.
* @return \Cake\Datasource\EntityInterface[] An array of built entities.
* @throws \BadMethodCallException
* @throws \InvalidArgumentException
* @throws \RuntimeException
Expand Down Expand Up @@ -408,6 +409,7 @@ protected function _belongsToMany(BelongsToMany $assoc, array $data, $options =
if (!empty($conditions)) {
$query = $target->find();
$query->andWhere(function ($exp) use ($conditions) {
/* @var \Cake\Database\Expression\QueryExpression $exp */
return $exp->or_($conditions);
});

Expand Down Expand Up @@ -458,7 +460,7 @@ protected function _belongsToMany(BelongsToMany $assoc, array $data, $options =
*
* @param \Cake\ORM\Association $assoc The association class for the belongsToMany association.
* @param array $ids The list of ids to load.
* @return array An array of entities.
* @return \Cake\Datasource\EntityInterface[] An array of entities.
*/
protected function _loadAssociatedByIds($assoc, $ids)
{
Expand Down Expand Up @@ -489,7 +491,7 @@ protected function _loadAssociatedByIds($assoc, $ids)
*
* @param \Cake\ORM\Association $assoc The association class for the belongsToMany association.
* @param array $ids The list of ids to load.
* @return array An array of entities.
* @return \Cake\Datasource\EntityInterface[] An array of entities.
* @deprecated Use _loadAssociatedByIds()
*/
protected function _loadBelongsToMany($assoc, $ids)
Expand Down Expand Up @@ -633,11 +635,11 @@ public function merge(EntityInterface $entity, array $data, array $options = [])
* the accessible fields list in the entity will be used.
* - accessibleFields: A list of fields to allow or deny in entity accessible fields.
*
* @param array|\Traversable $entities the entities that will get the
* @param \Cake\Datasource\EntityInterface[]|\Traversable $entities the entities that will get the
* data merged in
* @param array $data list of arrays to be merged into the entities
* @param array $options List of options.
* @return array
* @return \Cake\Datasource\EntityInterface[]
* @see \Cake\ORM\Entity::$_accessible
*/
public function mergeMany($entities, array $data, array $options = [])
Expand Down Expand Up @@ -684,6 +686,7 @@ public function mergeMany($entities, array $data, array $options = [])
return count(array_filter($keys, 'strlen')) === count($primary);
})
->reduce(function ($query, $keys) use ($primary) {
/* @var \Cake\ORM\Query $query */
$fields = array_map([$this->_table, 'aliasField'], $primary);

return $query->orWhere($query->newExpr()->and_(array_combine($fields, $keys)));
Expand Down Expand Up @@ -748,7 +751,7 @@ protected function _mergeAssociation($original, $assoc, $value, $options)
* @param \Cake\ORM\Association $assoc The association to marshall
* @param array $value The data to hydrate
* @param array $options List of options.
* @return array
* @return \Cake\Datasource\EntityInterface[]
*/
protected function _mergeBelongsToMany($original, $assoc, $value, $options)
{
Expand Down Expand Up @@ -778,7 +781,7 @@ protected function _mergeBelongsToMany($original, $assoc, $value, $options)
* @param \Cake\ORM\Association\BelongsToMany $assoc The association to marshall
* @param array $value The data to hydrate
* @param array $options List of options.
* @return array An array of entities
* @return \Cake\Datasource\EntityInterface[] An array of entities
*/
protected function _mergeJoinData($original, $assoc, $value, $options)
{
Expand Down

0 comments on commit 9a308f2

Please sign in to comment.