Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements #1819

Merged
merged 1 commit into from
Jul 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)) {

This comment was marked as resolved.

This comment was marked as resolved.

$discriminatorValues[] = null;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Query/Builder.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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