Skip to content

Commit

Permalink
Merge pull request #1819 from carusogabriel/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
alcaeus committed Jul 27, 2018
2 parents 757bdb6 + e341d80 commit ecf0636
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php
Expand Up @@ -1311,7 +1311,7 @@ public function sqrt($expression)
*/
public function stdDevPop($expression1, ...$expressions)
{
$expression = (empty($expressions)) ? $expression1 : func_get_args();
$expression = empty($expressions) ? $expression1 : func_get_args();

return $this->operator('$stdDevPop', $expression);
}
Expand All @@ -1329,7 +1329,7 @@ public function stdDevPop($expression1, ...$expressions)
*/
public function stdDevSamp($expression1, ...$expressions)
{
$expression = (empty($expressions)) ? $expression1 : func_get_args();
$expression = empty($expressions) ? $expression1 : func_get_args();

return $this->operator('$stdDevSamp', $expression);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Configuration.php
Expand Up @@ -133,7 +133,7 @@ public function newDefaultAnnotationDriver(array $paths = []): AnnotationDriver
{
$reader = new AnnotationReader();

return new AnnotationDriver($reader, (array) $paths);
return new AnnotationDriver($reader, $paths);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
Expand Up @@ -1365,7 +1365,7 @@ private function getClassDiscriminatorValues(ClassMetadata $metadata)
}

// If a defaultDiscriminatorValue is set and it is among the discriminators being queries, add NULL to the list
if ($metadata->defaultDiscriminatorValue && array_search($metadata->defaultDiscriminatorValue, $discriminatorValues) !== false) {
if ($metadata->defaultDiscriminatorValue && in_array($metadata->defaultDiscriminatorValue, $discriminatorValues)) {
$discriminatorValues[] = null;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Query/Builder.php
Expand Up @@ -14,9 +14,9 @@
use MongoDB\Driver\ReadPreference;
use function array_filter;
use function array_key_exists;
use function array_search;
use function count;
use function func_get_args;
use function in_array;
use function is_array;
use function is_bool;
use function is_callable;
Expand Down Expand Up @@ -1833,7 +1833,7 @@ private function setDocumentName($documentName)
$discriminatorValues = $this->getDiscriminatorValues($documentNames);

// If a defaultDiscriminatorValue is set and it is among the discriminators being queries, add NULL to the list
if ($metadata->defaultDiscriminatorValue && array_search($metadata->defaultDiscriminatorValue, $discriminatorValues) !== false) {
if ($metadata->defaultDiscriminatorValue && in_array($metadata->defaultDiscriminatorValue, $discriminatorValues)) {
$discriminatorValues[] = null;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ODM/MongoDB/Query/Expr.php
Expand Up @@ -189,7 +189,7 @@ public function addToSet($valueOrExpression)
*/
public function all(array $values)
{
return $this->operator('$all', (array) $values);
return $this->operator('$all', $values);
}

/**
Expand Down Expand Up @@ -698,7 +698,7 @@ public function includesReferenceTo($document)
$this->requiresCurrentField();
$mapping = $this->getReferenceMapping();
$reference = $this->dm->createReference($document, $mapping);
$storeAs = array_key_exists('storeAs', $mapping) ? $mapping['storeAs'] : null;
$storeAs = $mapping['storeAs'] ?? null;
$keys = [];

switch ($storeAs) {
Expand Down Expand Up @@ -1096,7 +1096,7 @@ public function references($document)
$this->requiresCurrentField();
$mapping = $this->getReferenceMapping();
$reference = $this->dm->createReference($document, $mapping);
$storeAs = array_key_exists('storeAs', $mapping) ? $mapping['storeAs'] : null;
$storeAs = $mapping['storeAs'] ?? null;
$keys = [];

switch ($storeAs) {
Expand Down
Expand Up @@ -61,7 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'Created <comment>%s%s</comment> for <info>%s</info>',
$option,
(isset($class) ? ($option === self::INDEX ? '(es)' : '') : ($option === self::INDEX ? 'es' : 's')),
($class ?? 'all classes')
$class ?? 'all classes'
));
} catch (\Throwable $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
Expand Down
Expand Up @@ -53,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'Dropped <comment>%s%s</comment> for <info>%s</info>',
$option,
(isset($class) ? ($option === self::INDEX ? '(es)' : '') : ($option === self::INDEX ? 'es' : 's')),
($class ?? 'all classes')
$class ?? 'all classes'
));
} catch (\Throwable $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
Expand Down
5 changes: 2 additions & 3 deletions lib/Doctrine/ODM/MongoDB/Types/CustomIdType.php
Expand Up @@ -6,18 +6,17 @@

/**
* The Id type.
*
*/
class CustomIdType extends Type
{
public function convertToDatabaseValue($value)
{
return $value !== null ? $value : null;
return $value;
}

public function convertToPHPValue($value)
{
return $value !== null ? $value : null;
return $value;
}

public function closureToMongo()
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/UnitOfWork.php
Expand Up @@ -2064,7 +2064,7 @@ private function cascadeDetach($document, array &$visited)
continue;
}
$relatedDocuments = $class->reflFields[$mapping['fieldName']]->getValue($document);
if (($relatedDocuments instanceof Collection || is_array($relatedDocuments))) {
if ($relatedDocuments instanceof Collection || is_array($relatedDocuments)) {
if ($relatedDocuments instanceof PersistentCollectionInterface) {
// Unwrap so that foreach() does not initialize
$relatedDocuments = $relatedDocuments->unwrap();
Expand Down

0 comments on commit ecf0636

Please sign in to comment.