Skip to content

Commit

Permalink
Merge pull request #5911 from ReenExeContributor/scrutinizer-clear-code
Browse files Browse the repository at this point in the history
Scrutinizer clear code
  • Loading branch information
Ocramius authored Jul 5, 2016
2 parents ab4b761 + bcc7983 commit 27e9b49
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -1155,9 +1155,8 @@ private function getCommitOrder(array $entityChangeSet = null)
}

$joinColumns = reset($assoc['joinColumns']);
$isNullable = isset($joinColumns['nullable']) ? $joinColumns['nullable'] : false;

$calc->addDependency($targetClass->name, $class->name, $isNullable ? 0 : 1);
$calc->addDependency($targetClass->name, $class->name, (int)empty($joinColumns['nullable']));

// If the target class has mapped subclasses, these share the same dependency.
if ( ! $targetClass->subClasses) {
Expand Down Expand Up @@ -1344,9 +1343,7 @@ public function scheduleForDelete($entity)

$this->removeFromIdentityMap($entity);

if (isset($this->entityUpdates[$oid])) {
unset($this->entityUpdates[$oid]);
}
unset($this->entityUpdates[$oid]);

if ( ! isset($this->entityDeletions[$oid])) {
$this->entityDeletions[$oid] = $entity;
Expand Down Expand Up @@ -1568,11 +1565,9 @@ public function tryGetByIdHash($idHash, $rootClassName)
{
$stringIdHash = (string) $idHash;

if (isset($this->identityMap[$rootClassName][$stringIdHash])) {
return $this->identityMap[$rootClassName][$stringIdHash];
}

return false;
return isset($this->identityMap[$rootClassName][$stringIdHash])
? $this->identityMap[$rootClassName][$stringIdHash]
: false;
}

/**
Expand Down Expand Up @@ -1796,7 +1791,7 @@ public function merge($entity)
* @throws ORMInvalidArgumentException If the entity instance is NEW.
* @throws EntityNotFoundException
*/
private function doMerge($entity, array &$visited, $prevManagedCopy = null, $assoc = null)
private function doMerge($entity, array &$visited, $prevManagedCopy = null, array $assoc = [])
{
$oid = spl_object_hash($entity);

Expand Down Expand Up @@ -2445,9 +2440,7 @@ public function scheduleCollectionDeletion(PersistentCollection $coll)

// TODO: if $coll is already scheduled for recreation ... what to do?
// Just remove $coll from the scheduled recreations?
if (isset($this->collectionUpdates[$coid])) {
unset($this->collectionUpdates[$coid]);
}
unset($this->collectionUpdates[$coid]);

$this->collectionDeletions[$coid] = $coll;
}
Expand Down Expand Up @@ -2854,11 +2847,9 @@ public function getOriginalEntityData($entity)
{
$oid = spl_object_hash($entity);

if (isset($this->originalEntityData[$oid])) {
return $this->originalEntityData[$oid];
}

return array();
return isset($this->originalEntityData[$oid])
? $this->originalEntityData[$oid]
: [];
}

/**
Expand Down Expand Up @@ -2944,11 +2935,9 @@ public function tryGetById($id, $rootClassName)
{
$idHash = implode(' ', (array) $id);

if (isset($this->identityMap[$rootClassName][$idHash])) {
return $this->identityMap[$rootClassName][$idHash];
}

return false;
return isset($this->identityMap[$rootClassName][$idHash])
? $this->identityMap[$rootClassName][$idHash]
: false;
}

/**
Expand Down Expand Up @@ -2985,7 +2974,7 @@ public function hasPendingInsertions()
*/
public function size()
{
$countArray = array_map(function ($item) { return count($item); }, $this->identityMap);
$countArray = array_map('count', $this->identityMap);

return array_sum($countArray);
}
Expand Down

0 comments on commit 27e9b49

Please sign in to comment.