Remove any unreferenced non aggregate root entity

@param object $object
@param string $propertyName
@param array $propertyMetaData
@return void
437730
protected function removeDeletedReference($object, $propertyName, $propertyMetaData)
    {
        $previousValue = $this->persistenceSession->getCleanStateOfProperty($object, $propertyName);
        if ($previousValue !== null && is_array($previousValue) && isset($previousValue['value']['identifier'])
            && $this->reflectionService->getClassSchema($propertyMetaData['type'])->getModelType() === ClassSchema::MODELTYPE_ENTITY
            && $this->reflectionService->getClassSchema($propertyMetaData['type'])->isAggregateRoot() === false) {
            $object = $this->persistenceSession->getObjectByIdentifier($previousValue['value']['identifier']);
            if (!$this->visitedDuringPersistence->contains($object)) {
                $this->removeEntity($object);
            }
        }
    }
1025609
public void unregisterPropertyExclusion( Class target, String propertyName ) {
      if( target != null && propertyName != null ) {
         Set set = (Set) exclusionMap.get( target );
         if( set == null ) {
            set = new HashSet();
            exclusionMap.put( target, set );
         }
         set.remove( propertyName );
      }
   }
821289
protected function getPrivate($object, string $propertyName)
    {
        $objectArray = (array) $object;
        foreach ($objectArray as $name => $value) {
            if (substr($name, - \strlen($propertyName) - 1) === "\x00" . $propertyName) {
                return $value;
            }
        }

        return null;
    }
837781
protected function getPropertyValueFromObject(ClassMetadata $meta, $propertyName, $object)
    {
        $refl = $meta->getReflectionClass();
        $prop = $refl->getProperty($propertyName);
        $prop->setAccessible(true);
        $value = $prop->getValue($object);
        return $value;
    }
661886
public function removeObject(DataObject $object)
    {
        $item = ChangeSetItem::get()->filter([
            'ObjectID' => $object->ID,
            'ObjectClass' => $object->baseClass(),
            'ChangeSetID' => $this->ID
        ])->first();

        if ($item) {
            // TODO: Handle case of implicit added item being removed.

            $item->delete();
        }

        $this->sync();
    }
825537
public static function delete($object)
    {
        if (null === $object) {
            throw new \LogicException("No object");
        }

        $setterDelete = [
            $object,
            "setDeleted"
        ];

        if (false === is_callable($setterDelete)) {
            throw new \LogicException(sprintf("%s is not softdeletable", get_class($object)));
        }

        $object->setDeleted(true);

        $oReflectionClass = new \ReflectionClass($object);
        foreach ($oReflectionClass->getProperties() as $property) {
            $property->setAccessible(true);
            $propertyValue = $property->getValue($object);

            if ($propertyValue instanceof Collection || true === is_array($propertyValue)) {
                foreach ($propertyValue as $propertyValueRelation) {
                    $setterDelete = [
                        $propertyValueRelation,
                        "setDeleted"
                    ];

                    if (true === is_callable($setterDelete)) {
                        $propertyValueRelation->setDeleted(true);
                    }
                }
            }
        }
    }
525761
private function removeMappingsFromTraits(ClassMetadata $metadata): void
    {
        $traits = $this->getTraits($metadata->name);

        foreach ($traits as $trait) {
            $trait = new \ReflectionClass($trait);

            /**
             * @var \ReflectionProperty $property
             */
            foreach ($trait->getProperties() as $property) {
                $name = $property->getName();

                if (isset($metadata->fieldMappings[$name])) {
                    $mapping = $metadata->fieldMappings[$name];

                    unset(
                        $metadata->fieldMappings[$name],
                        $metadata->fieldNames[$mapping['columnName']],
                        $metadata->columnNames[$name]
                    );
                }
            }
        }
    }
1349089
protected function removeReverseProperty($property, NodeInterface $node)
    {
        unset($this->revProperties[$property][$node->getId()]);

        if (0 === count($this->revProperties[$property])) {
            unset($this->revProperties[$property]);
        }
    }
841618
@Override
    public void unset(String propName) {

        /*
         * Require a property name.
         */
        if (propName == null || propName.trim().isEmpty()) {
            return;
        }

        if (propName.equals(PROP_MEMBERS)) {
            unsetMembers();
        }
        if (propName.equals(PROP_DISPLAY_NAME)) {
            unsetDisplayName();
        }
        if (propName.equals(PROP_DESCRIPTION)) {
            unsetDescription();
        }
        if (propName.equals(PROP_BUSINESS_CATEGORY)) {
            unsetBusinessCategory();
        }
        if (propName.equals(PROP_SEE_ALSO)) {
            unsetSeeAlso();
        }

        if (extendedPropertiesDataType.containsKey(propName))
            unSetExtendedProperty(propName);

        super.unset(propName);
    }
283449
public void clear(final String propertyName) {
        Preconditions.checkNotNull(propertyName);
        if (properties.containsKey(propertyName)) {
            properties.put(propertyName, null);
        } else if (references.containsKey(propertyName)) {
            references.put(propertyName, null);
        }
    }
6917
public function removeAllProperties($propertyName, $value = null)
    {
        $updateable = Updatable::getInstance()
            ->table($this->getUserPropertiesDefinition()->table())
            ->where("{$this->getUserPropertiesDefinition()->getName()} = :name", ["name" => $propertyName]);

        if (!empty($value)) {
            $updateable->where("{$this->getUserPropertiesDefinition()->getValue()} = :value", ["value" => $value]);
        }

        $this->propertiesRepository->deleteByQuery($updateable);

        return true;
    }
728878
@Override
    public void removeProperty(Property property) {
        properties.remove(property);
        property.removePropertyChangeListener(this);
        buildModel();
    }
9811
public function getCleanStateOfProperty($object, $propertyName)
    {
        if ($this->isReconstitutedEntity($object) === false) {
            return null;
        }
        $identifier = $this->getIdentifierByObject($object);
        if (!isset($this->reconstitutedEntitiesData[$identifier]['properties'][$propertyName])) {
            return null;
        }
        return $this->reconstitutedEntitiesData[$identifier]['properties'][$propertyName];
    }
731895
public static function getPropertyAnnotation($object, $propertyName, $annotationClass)
    {
        return AnnotationManager::getPropertyAnnotations(BeanFactory::getObjectClass($object), $propertyName, $annotationClass)[0] ?? null;
    }
485711
protected function setDomainObjectInProperty($object, $propertyName, $domainObject, $lastObject, array $objectArrayPropertyPath)
    {
        if (is_object($object)) {
            ObjectAccess::setProperty($object, $propertyName, $domainObject);
        } elseif (is_array($object)) {
            $this->injectDomainObjectInLastObject($domainObject, $lastObject, $objectArrayPropertyPath);
        }
    }
1322024
public static function isPropertySettable($object, string $propertyName): bool
    {
        if (!is_object($object)) {
            throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1259828920);
        }

        $className = TypeHandling::getTypeForValue($object);
        if (($object instanceof \stdClass && array_key_exists($propertyName, get_object_vars($object))) || array_key_exists($propertyName, get_class_vars($className))) {
            return true;
        }
        return is_callable([$object, self::buildSetterMethodName($propertyName)]);
    }
1192640
public function removeMultipleProperties(array $propertyNames)
    {
        $this->parseStyleAttribute();

        foreach ($propertyNames as $propertyName) {
            if (!is_string($propertyName)) {
                throw new InvalidArgumentException(sprintf('Property name must be a string, %s given', (is_object($propertyName) ? get_class($propertyName) : gettype($propertyName))));
            }

            unset($this->properties[$propertyName]);
        }

        $this->updateStyleAttribute();

        return $this;
    }