_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q25800
Stage.geoNear
train
public function geoNear($x, $y = null) : Stage\GeoNear {
php
{ "resource": "" }
q25801
HydratorFactory.generateHydratorClasses
train
public function generateHydratorClasses(array $classes, ?string $toDir = null) : void { $hydratorDir = $toDir ?: $this->hydratorDir; $hydratorDir = rtrim($hydratorDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; foreach ($classes as $class) { $hydratorClassName = str_replace('\\'...
php
{ "resource": "" }
q25802
CollectionHelper.isAtomic
train
public static function isAtomic(string $strategy) : bool { return $strategy
php
{ "resource": "" }
q25803
CollectionHelper.isHash
train
public static function isHash(string $strategy) : bool { return $strategy
php
{ "resource": "" }
q25804
CollectionHelper.isList
train
public static function isList(?string $strategy) : bool { return $strategy
php
{ "resource": "" }
q25805
CollStats.showLatencyStats
train
public function showLatencyStats(bool $histograms = false) : self { $this->latencyStats
php
{ "resource": "" }
q25806
DocumentPersister.wrapCursor
train
private function wrapCursor(Cursor $baseCursor) : Iterator { return new CachingIterator(new
php
{ "resource": "" }
q25807
DocumentPersister.createDocument
train
private function createDocument(array $result, ?object $document = null, array $hints = []) : ?object { if ($document !== null) { $hints[Query::HINT_REFRESH] = true; $id
php
{ "resource": "" }
q25808
DocumentPersister.prepareProjection
train
public function prepareProjection(array $fields) : array { $preparedFields = []; foreach ($fields as $key => $value) {
php
{ "resource": "" }
q25809
DocumentPersister.prepareSort
train
public function prepareSort(array $fields) : array { $sortFields = []; foreach ($fields as $key => $value) { if (is_array($value)) { $sortFields[$this->prepareFieldName($key)] = $value; } else {
php
{ "resource": "" }
q25810
DocumentPersister.hasDBRefFields
train
private function hasDBRefFields($value) : bool { if (! is_array($value) && ! is_object($value)) { return false; } if (is_object($value)) { $value = get_object_vars($value); } foreach ($value
php
{ "resource": "" }
q25811
DocumentPersister.hasQueryOperators
train
private function hasQueryOperators($value) : bool { if (! is_array($value) && ! is_object($value)) { return false; } if (is_object($value)) { $value = get_object_vars($value); } foreach ($value
php
{ "resource": "" }
q25812
DocumentPersister.getClassDiscriminatorValues
train
private function getClassDiscriminatorValues(ClassMetadata $metadata) : array { $discriminatorValues = []; if ($metadata->discriminatorValue !== null) { $discriminatorValues[] = $metadata->discriminatorValue; } foreach ($metadata->subClasses as $className) { ...
php
{ "resource": "" }
q25813
DocumentPersister.getQueryForDocument
train
private function getQueryForDocument(object $document) : array { $id = $this->uow->getDocumentIdentifier($document); $id = $this->class->getDatabaseIdentifierValue($id);
php
{ "resource": "" }
q25814
PersistenceBuilder.prepareAssociatedDocumentValue
train
public function prepareAssociatedDocumentValue(array $mapping, $document, $includeNestedCollections = false) { if (isset($mapping['embedded'])) { return $this->prepareEmbeddedDocumentValue($mapping, $document, $includeNestedCollections); } if (isset($mapping['reference'])) { ...
php
{ "resource": "" }
q25815
ClassMetadataFactory.validateIdentifier
train
protected function validateIdentifier(ClassMetadata $class) : void { if (! $class->identifier && ! $class->isMappedSuperclass && ! $class->isEmbeddedDocument &&
php
{ "resource": "" }
q25816
ClassMetadataFactory.setInheritedShardKey
train
private function setInheritedShardKey(ClassMetadata $subClass, ClassMetadata $parentClass) : void { if (! $parentClass->isSharded()) { return; } $subClass->setShardKey(
php
{ "resource": "" }
q25817
CollectionPersister.update
train
public function update(object $parent, array $collections, array $options) : void { $setStrategyColls = []; $addPushStrategyColls = []; foreach ($collections as $coll) { $mapping = $coll->getMapping(); if ($mapping['isInverseSide']) { continue; /...
php
{ "resource": "" }
q25818
CollectionPersister.setCollections
train
private function setCollections(object $parent, array $collections, array $options) : void { $pathCollMap = []; $paths = []; foreach ($collections as $coll) { [$propertyPath ] = $this->getPathAndParent($coll); $pathCollMap[$propertyPath] = $coll; ...
php
{ "resource": "" }
q25819
CollectionPersister.deleteElements
train
private function deleteElements(object $parent, array $collections, array $options) : void { $pathCollMap = []; $paths = []; $deleteDiffMap = []; foreach ($collections as $coll) { $coll->initialize(); if (! $this->uow->isCollectionScheduledForUpdate...
php
{ "resource": "" }
q25820
CollectionPersister.insertElements
train
private function insertElements(object $parent, array $collections, array $options) : void { $pushAllPathCollMap = []; $addToSetPathCollMap = []; $pushAllPaths = []; $addToSetPaths = []; $diffsMap = []; foreach ($collections as $coll) { ...
php
{ "resource": "" }
q25821
CollectionPersister.pushAllCollections
train
private function pushAllCollections(object $parent, array $collsPaths, array $pathCollsMap, array $diffsMap, array $options) : void { $pushAllPaths = $this->excludeSubPaths($collsPaths); /** @var PersistentCollectionInterface[] $pushAllColls */ $pushAllColls = array_intersect_key($pathColl...
php
{ "resource": "" }
q25822
CollectionPersister.addToSetCollections
train
private function addToSetCollections(object $parent, array $collsPaths, array $pathCollsMap, array $diffsMap, array $options) : void { $addToSetPaths = $this->excludeSubPaths($collsPaths); /** @var PersistentCollectionInterface[] $addToSetColls */ $addToSetColls = array_intersect_key($pathCo...
php
{ "resource": "" }
q25823
CollectionPersister.getValuePrepareCallback
train
private function getValuePrepareCallback(PersistentCollectionInterface $coll) : Closure { $mapping = $coll->getMapping(); if (isset($mapping['embedded'])) { return function ($v) use ($mapping) { return $this->pb->prepareEmbeddedDocumentValue($mapping, $v);
php
{ "resource": "" }
q25824
CollectionPersister.excludeSubPaths
train
private function excludeSubPaths(array $paths) : array { if (empty($paths)) { return $paths; } sort($paths); $uniquePaths = [$paths[0]]; for ($i = 1, $count = count($paths); $i < $count; ++$i) { $lastUniquePath = end($uniquePaths); assert($...
php
{ "resource": "" }
q25825
GeoNear.near
train
public function near($x, $y = null) : self { if ($x instanceof Point) { $x = $x->jsonSerialize(); } $this->near = is_array($x) ? $x : [$x, $y];
php
{ "resource": "" }
q25826
FilterCollection.getFilter
train
public function getFilter(string $name) : BsonFilter { if (! $this->isEnabled($name)) { throw new InvalidArgumentException("Filter '" . $name .
php
{ "resource": "" }
q25827
GraphLookup.connectToField
train
public function connectToField(string $connectToField) : self {
php
{ "resource": "" }
q25828
Operator.concat
train
public function concat($expression1, $expression2, ...$expressions) :
php
{ "resource": "" }
q25829
Operator.concatArrays
train
public function concatArrays($array1, $array2, ...$arrays) : self {
php
{ "resource": "" }
q25830
Operator.dateToString
train
public function dateToString($format, $expression) : self {
php
{ "resource": "" }
q25831
Operator.divide
train
public function divide($expression1, $expression2) : self {
php
{ "resource": "" }
q25832
Operator.eq
train
public function eq($expression1, $expression2) : self {
php
{ "resource": "" }
q25833
Operator.in
train
public function in($expression, $arrayExpression) : self {
php
{ "resource": "" }
q25834
Operator.ifNull
train
public function ifNull($expression, $replacementExpression) : self {
php
{ "resource": "" }
q25835
Operator.let
train
public function let($vars, $in) : self { $this->expr->let($vars,
php
{ "resource": "" }
q25836
Operator.log
train
public function log($number, $base) : self { $this->expr->log($number,
php
{ "resource": "" }
q25837
Operator.mod
train
public function mod($expression1, $expression2) : self {
php
{ "resource": "" }
q25838
Operator.multiply
train
public function multiply($expression1, $expression2, ...$expressions) :
php
{ "resource": "" }
q25839
Operator.pow
train
public function pow($number, $exponent) : self {
php
{ "resource": "" }
q25840
Operator.setDifference
train
public function setDifference($expression1, $expression2) : self {
php
{ "resource": "" }
q25841
Operator.setEquals
train
public function setEquals($expression1, $expression2, ...$expressions) :
php
{ "resource": "" }
q25842
Operator.setIntersection
train
public function setIntersection($expression1, $expression2, ...$expressions) :
php
{ "resource": "" }
q25843
Operator.setIsSubset
train
public function setIsSubset($expression1, $expression2) : self {
php
{ "resource": "" }
q25844
Operator.setUnion
train
public function setUnion($expression1, $expression2, ...$expressions) :
php
{ "resource": "" }
q25845
Operator.split
train
public function split($string, $delimiter) : self {
php
{ "resource": "" }
q25846
Operator.subtract
train
public function subtract($expression1, $expression2) : self {
php
{ "resource": "" }
q25847
Facet.pipeline
train
public function pipeline($builder) : self { if (! $this->field) { throw new LogicException(__METHOD__ . ' requires you set a current field using field().'); } if ($builder instanceof Stage) { $builder = $builder->builder; } if
php
{ "resource": "" }
q25848
DateType.getDateTime
train
public static function getDateTime($value) : DateTimeInterface { $datetime = false; $exception = null; if ($value instanceof DateTimeInterface) { return $value; } elseif ($value instanceof UTCDateTime) { $datetime = $value->toDateTime(); $datetim...
php
{ "resource": "" }
q25849
PersistentCollectionTrait.doRemove
train
private function doRemove($offset, $arrayAccess) { $this->initialize(); if ($arrayAccess) { $this->coll->offsetUnset($offset); $removed = true; } else { $removed = $this->coll->remove($offset);
php
{ "resource": "" }
q25850
PersistentCollectionTrait.doSet
train
private function doSet($offset, $value, $arrayAccess) { $arrayAccess ? $this->coll->offsetSet($offset, $value) : $this->coll->set($offset, $value); // Handle orphanRemoval
php
{ "resource": "" }
q25851
Query.debug
train
public function debug(?string $name = null) { return
php
{ "resource": "" }
q25852
Query.makeIterator
train
private function makeIterator(Traversable $cursor) : Iterator { if ($this->hydrate) { $cursor = new HydratingIterator($cursor, $this->dm->getUnitOfWork(), $this->class, $this->unitOfWorkHints); } $cursor = new CachingIterator($cursor); if (! empty($this->primers)) { ...
php
{ "resource": "" }
q25853
DocumentRepository.find
train
public function find($id, int $lockMode = LockMode::NONE, ?int $lockVersion = null) : ?object { if ($id === null) { return null; } /* TODO: What if the ID object has a field with the same name as the * class' mapped identifier field name? */ if (is_arra...
php
{ "resource": "" }
q25854
UnitOfWork.getPersistenceBuilder
train
public function getPersistenceBuilder() : PersistenceBuilder { if (! $this->persistenceBuilder) {
php
{ "resource": "" }
q25855
UnitOfWork.getCollectionPersister
train
public function getCollectionPersister() : CollectionPersister { if (! isset($this->collectionPersister)) { $pb
php
{ "resource": "" }
q25856
UnitOfWork.setDocumentPersister
train
public function setDocumentPersister(string $documentName, Persisters\DocumentPersister $persister)
php
{ "resource": "" }
q25857
UnitOfWork.getClassesForCommitAction
train
private function getClassesForCommitAction(array $documents, bool $includeEmbedded = false) : array { if (empty($documents)) { return []; } $divided = []; $embeds = []; foreach ($documents as $oid => $d) { $className = get_class($d); if (i...
php
{ "resource": "" }
q25858
UnitOfWork.computeScheduleInsertsChangeSets
train
private function computeScheduleInsertsChangeSets() : void { foreach ($this->documentInsertions as $document) { $class = $this->dm->getClassMetadata(get_class($document)); if ($class->isEmbeddedDocument) {
php
{ "resource": "" }
q25859
UnitOfWork.computeScheduleUpsertsChangeSets
train
private function computeScheduleUpsertsChangeSets() : void { foreach ($this->documentUpserts as $document) { $class = $this->dm->getClassMetadata(get_class($document)); if ($class->isEmbeddedDocument) {
php
{ "resource": "" }
q25860
UnitOfWork.setDocumentChangeSet
train
public function setDocumentChangeSet(object $document, array $changeset) :
php
{ "resource": "" }
q25861
UnitOfWork.scheduleForInsert
train
public function scheduleForInsert(ClassMetadata $class, object $document) : void { $oid = spl_object_hash($document); if (isset($this->documentUpdates[$oid])) { throw new InvalidArgumentException('Dirty document can not be scheduled for insertion.'); } if (isset($this->d...
php
{ "resource": "" }
q25862
UnitOfWork.scheduleForUpsert
train
public function scheduleForUpsert(ClassMetadata $class, object $document) : void { $oid = spl_object_hash($document); if ($class->isEmbeddedDocument) { throw new InvalidArgumentException('Embedded document can not be scheduled for upsert.'); } if (isset($this->documentUp...
php
{ "resource": "" }
q25863
UnitOfWork.isScheduledForSynchronization
train
public function isScheduledForSynchronization(object $document) : bool { $class = $this->dm->getClassMetadata(get_class($document)); return
php
{ "resource": "" }
q25864
UnitOfWork.scheduleForDelete
train
public function scheduleForDelete(object $document) : void { $oid = spl_object_hash($document); if (isset($this->documentInsertions[$oid])) { if ($this->isInIdentityMap($document)) { $this->removeFromIdentityMap($document); } unset($this->document...
php
{ "resource": "" }
q25865
UnitOfWork.isDocumentScheduled
train
public function isDocumentScheduled(object $document) : bool { $oid = spl_object_hash($document); return isset($this->documentInsertions[$oid]) || isset($this->documentUpserts[$oid]) ||
php
{ "resource": "" }
q25866
UnitOfWork.addToIdentityMap
train
public function addToIdentityMap(object $document) : bool { $class = $this->dm->getClassMetadata(get_class($document)); $id = $this->getIdForIdentityMap($document); if (isset($this->identityMap[$class->name][$id])) {
php
{ "resource": "" }
q25867
UnitOfWork.tryGetById
train
public function tryGetById($id, ClassMetadata $class) { if (! $class->identifier) { throw new InvalidArgumentException(sprintf('Class "%s" does not have an identifier', $class->name)); }
php
{ "resource": "" }
q25868
UnitOfWork.containsId
train
public function containsId($id, string $rootClassName) : bool {
php
{ "resource": "" }
q25869
UnitOfWork.persist
train
public function persist(object $document) : void { $class = $this->dm->getClassMetadata(get_class($document)); if ($class->isMappedSuperclass ||
php
{ "resource": "" }
q25870
UnitOfWork.unscheduleOrphanRemoval
train
public function unscheduleOrphanRemoval(object $document) : void
php
{ "resource": "" }
q25871
UnitOfWork.scheduleCollectionDeletion
train
public function scheduleCollectionDeletion(PersistentCollectionInterface $coll) : void { $oid = spl_object_hash($coll); unset($this->collectionUpdates[$oid]); if (isset($this->collectionDeletions[$oid])) {
php
{ "resource": "" }
q25872
UnitOfWork.unscheduleCollectionDeletion
train
public function unscheduleCollectionDeletion(PersistentCollectionInterface $coll) : void { if ($coll->getOwner() === null) { return; } $oid = spl_object_hash($coll); if (! isset($this->collectionDeletions[$oid])) { return; }
php
{ "resource": "" }
q25873
UnitOfWork.scheduleCollectionUpdate
train
public function scheduleCollectionUpdate(PersistentCollectionInterface $coll) : void { $mapping = $coll->getMapping(); if (CollectionHelper::usesSet($mapping['strategy'])) { /* There is no need to $unset collection if it will be $set later
php
{ "resource": "" }
q25874
UnitOfWork.unscheduleCollectionUpdate
train
public function unscheduleCollectionUpdate(PersistentCollectionInterface $coll) : void { if ($coll->getOwner() === null) { return; } $oid = spl_object_hash($coll); if (! isset($this->collectionUpdates[$oid])) { return; }
php
{ "resource": "" }
q25875
UnitOfWork.setOriginalDocumentProperty
train
public function setOriginalDocumentProperty(string $oid, string $property, $value)
php
{ "resource": "" }
q25876
Lookup.foreignField
train
public function foreignField(string $foreignField) : self { $this->foreignField
php
{ "resource": "" }
q25877
ClassMetadata.getReferencePrefix
train
private static function getReferencePrefix(string $storeAs) : string { if (! in_array($storeAs, [self::REFERENCE_STORE_AS_REF, self::REFERENCE_STORE_AS_DB_REF, self::REFERENCE_STORE_AS_DB_REF_WITH_DB])) { throw new LogicException('Can only
php
{ "resource": "" }
q25878
ClassMetadata.getReferenceFieldName
train
public static function getReferenceFieldName(string $storeAs, string $pathPrefix = '') : string { if ($storeAs === self::REFERENCE_STORE_AS_ID)
php
{ "resource": "" }
q25879
ClassMetadata.setDefaultDiscriminatorValue
train
public function setDefaultDiscriminatorValue(?string $defaultDiscriminatorValue) : void { if ($this->isFile) { throw MappingException::discriminatorNotAllowedForGridFS($this->name); } if ($defaultDiscriminatorValue === null) { $this->defaultDiscriminatorValue = null;...
php
{ "resource": "" }
q25880
ClassMetadata.addIndex
train
public function addIndex(array $keys, array $options = []) : void { $this->indexes[] = [ 'keys' => array_map(static function ($value) { if ($value === 1 || $value === -1) { return $value; }
php
{ "resource": "" }
q25881
ClassMetadata.setReadPreference
train
public function setReadPreference(?string $readPreference, array $tags) : void { $this->readPreference
php
{ "resource": "" }
q25882
ClassMetadata.setCollection
train
public function setCollection($name) : void { if (is_array($name)) { if (! isset($name['name'])) { throw new InvalidArgumentException('A name key is required when passing an array to setCollection()'); } $this->collectionCapped = $name['capped'] ?? false; ...
php
{ "resource": "" }
q25883
ClassMetadata.applyStorageStrategy
train
private function applyStorageStrategy(array &$mapping) : void { if (! isset($mapping['type']) || isset($mapping['id'])) { return; } switch (true) { case $mapping['type'] === 'int': case $mapping['type'] === 'float': $defaultStrategy = se...
php
{ "resource": "" }
q25884
ClassMetadata.getPHPIdentifierValue
train
public function getPHPIdentifierValue($id) { $idType = $this->fieldMappings[$this->identifier]['type'];
php
{ "resource": "" }
q25885
ClassMetadata.getDatabaseIdentifierValue
train
public function getDatabaseIdentifierValue($id) { $idType = $this->fieldMappings[$this->identifier]['type']; return
php
{ "resource": "" }
q25886
ClassMetadata.getFieldMappingByDbFieldName
train
public function getFieldMappingByDbFieldName(string $dbFieldName) : array { foreach ($this->fieldMappings as $mapping) { if ($mapping['name'] === $dbFieldName) { return $mapping;
php
{ "resource": "" }
q25887
ClassMetadata.isNullable
train
public function isNullable(string $fieldName) : bool { $mapping = $this->getFieldMapping($fieldName); return
php
{ "resource": "" }
q25888
ClassMetadata.getAssociationCollectionClass
train
public function getAssociationCollectionClass(string $assocName) : string { if (! isset($this->associationMappings[$assocName])) { throw new InvalidArgumentException("Association name expected, '" . $assocName . "' is not an association."); } if (! array_key_exists('collectionCl...
php
{ "resource": "" }
q25889
BucketAutoOutput.buckets
train
public function buckets(int $buckets) : Stage\BucketAuto { assert($this->bucket instanceof Stage\BucketAuto);
php
{ "resource": "" }
q25890
BucketAutoOutput.granularity
train
public function granularity(string $granularity) : Stage\BucketAuto { assert($this->bucket instanceof Stage\BucketAuto);
php
{ "resource": "" }
q25891
BucketOutput.boundaries
train
public function boundaries(...$boundaries) { assert($this->bucket instanceof Stage\Bucket);
php
{ "resource": "" }
q25892
SchemaManager.isEquivalentIndexKeys
train
private function isEquivalentIndexKeys(IndexInfo $mongoIndex, array $documentIndex) : bool { $mongoIndexKeys = $mongoIndex['key']; $documentIndexKeys = $documentIndex['keys']; /* If we are dealing with text indexes, we need to unset internal fields * from the MongoDB index and f...
php
{ "resource": "" }
q25893
SchemaManager.indexOptionsAreMissing
train
private function indexOptionsAreMissing(array $mongoIndexOptions, array $documentIndexOptions) : bool { foreach (self::ALLOWED_MISSING_INDEX_OPTIONS as $option) {
php
{ "resource": "" }
q25894
SchemaManager.isEquivalentTextIndexWeights
train
private function isEquivalentTextIndexWeights(IndexInfo $mongoIndex, array $documentIndex) : bool { $mongoIndexWeights = $mongoIndex['weights']; $documentIndexWeights = $documentIndex['options']['weights'] ?? []; // If not specified, assign a default weight for text fields foreac...
php
{ "resource": "" }
q25895
DocumentManager.getDocumentCollection
train
public function getDocumentCollection(string $className) : Collection { $className = $this->classNameResolver->getRealClass($className); /** @var ClassMetadata $metadata */ $metadata = $this->metadataFactory->getMetadataFor($className); assert($metadata instanceof ClassMetadata); ...
php
{ "resource": "" }
q25896
DocumentManager.getDocumentBucket
train
public function getDocumentBucket(string $className) : Bucket { $className = $this->classNameResolver->getRealClass($className); /** @var ClassMetadata $metadata */ $metadata = $this->metadataFactory->getMetadataFor($className); if (! $metadata->isFile) { throw MongoDBEx...
php
{ "resource": "" }
q25897
DocumentManager.find
train
public function find($documentName, $identifier, $lockMode = LockMode::NONE, $lockVersion = null) : ?object { $repository = $this->getRepository($documentName); if ($repository instanceof DocumentRepository) {
php
{ "resource": "" }
q25898
DocumentManager.createReference
train
public function createReference(object $document, array $referenceMapping) { $class = $this->getClassMetadata(get_class($document)); $id = $this->unitOfWork->getDocumentIdentifier($document); if ($id === null) { throw new RuntimeException( sprintf('Cannot crea...
php
{ "resource": "" }
q25899
DocumentManager.getDiscriminatorData
train
private function getDiscriminatorData(array $referenceMapping, ClassMetadata $class) : array { $discriminatorField = null; $discriminatorValue = null; $discriminatorMap = null; if (isset($referenceMapping['discriminatorField'])) { $discriminatorField = $referenceMappin...
php
{ "resource": "" }