Parse a single property.

@param PropertyInterface $property The property to parse.
@param array             $propInfo The property information.

@return void

@SuppressWarnings(PHPMD.CyclomaticComplexity)
354856
protected function parseSingleProperty(PropertyInterface $property, array $propInfo)
    {
        foreach ($propInfo as $key => $value) {
            switch ($key) {
                case 'label':
                    $this->parseSinglePropertyLabel($property, $value);
                    break;

                case 'description':
                    if (!$property->getDescription()) {
                        $property->setDescription($value);
                    }
                    break;

                case 'default':
                    if (!$property->getDefaultValue()) {
                        $property->setDefaultValue($value);
                    }
                    break;

                case 'exclude':
                    $property->setExcluded((bool) $value);
                    break;

                case 'search':
                    $property->setSearchable((bool) $value);
                    break;

                case 'filter':
                    $property->setFilterable((bool) $value);
                    break;

                case 'inputType':
                    $property->setWidgetType($value);
                    break;

                case 'options':
                    $property->setOptions($value);
                    break;

                case 'explanation':
                    $property->setExplanation($value);
                    break;

                case 'eval':
                    $property->setExtra(
                        \array_merge(
                            (array) $property->getExtra(),
                            (array) $value
                        )
                    );
                    break;

                case 'reference':
                    $property->setExtra(
                        \array_merge(
                            (array) $property->getExtra(),
                            ['reference' => &$propInfo['reference']]
                        )
                    );
                    break;

                case 'sql':
                    $this->determineEmptyValueFromSql($property, $value);
                    break;

                default:
            }
        }

        $this->parseWidgetPageTree($property, $propInfo);
    }
1171168
protected function setProp(string $property, $value)
    {
        if (\property_exists($this, $property)) {
            $this->{$property} = $value;
        }
    }
47973
public function setProperty(&$object, $propertyName, $propertyValue)
    {
        $property = $this->getPropertyInstance($object, $propertyName);
        $property->setAccessible(true);
        $property->setValue($object, $propertyValue);
    }
618700
public static function setPropertyValue($object, $property, $value): void
    {
        $ref = new \ReflectionClass($object);
        $prop = static::getPrivateProperty($ref, $property);
        $prop->setAccessible(true);
        $prop->setValue($object, $value);
        $prop->setAccessible(false);
    }
1055039
private function handleNotFound(?PropertyMetadata $parentPropertyMetadata, string $resourceClass, string $property): PropertyMetadata
    {
        if ($parentPropertyMetadata) {
            return $parentPropertyMetadata;
        }

        throw new PropertyNotFoundException(sprintf('Property "%s" of the resource class "%s" not found.', $property, $resourceClass));
    }
1313258
protected function addChild(PropertyInterface $property)
    {
        if ($property instanceof SectionPropertyInterface) {
            foreach ($property->getChildProperties() as $childProperty) {
                $this->addPropertyTags($childProperty);
            }
        } else {
            $this->addPropertyTags($property);
        }

        $this->properties[$property->getName()] = $property;
    }
556415
public function add(PropertyInterface $property)
    {
        $iri = $property->toIri();

        // Create the property values list if necessary
        if (!$this->offsetExists($iri)) {
            $this->offsetSet($iri, [$property]);
            return;
        }

        $propertyStore =& $this->offsetGet($iri);
        $propertyStore[] = $property;
    }
772026
public function addToObserved(Property $property)
    {
        $this->validatePropertyPaths((string) $this->className, $this->idDefinition, [$property]);
        $this->observedProperties[] = $property;
        $this->observedProperties = array_unique($this->observedProperties);
    }
1125710
private function getSnippets(PropertyInterface $property)
    {
        /** @var PageBridge $page */
        $page = $property->getStructure();
        $webspaceKey = $page->getWebspaceKey();
        $locale = $page->getLanguageCode();
        $shadowLocale = null;
        if ($page->getIsShadow()) {
            $shadowLocale = $page->getShadowBaseLanguage();
        }

        $refs = $property->getValue();
        $ids = $this->getUuids($refs);

        $snippetType = $this->getParameterValue($property->getParams(), 'snippetType');
        $default = $this->getParameterValue($property->getParams(), 'default', false);

        $snippetArea = $default;
        if (true === $snippetArea || 'true' === $snippetArea) {
            $snippetArea = $snippetType;
        }

        if (empty($ids) && $snippetArea && $this->defaultEnabled) {
            $ids = $this->loadSnippetAreaIds($webspaceKey, $snippetArea, $locale);
        }

        return $this->snippetResolver->resolve($ids, $webspaceKey, $locale, $shadowLocale);
    }
478843
protected function selectValue(PropertyInterface $property, array $data)
    {
        $errors = [];
        $key = $property->getName();
        $value = array_key_exists($key, $data) ? $data[$key] : null;

        if ($value === null && $property->isRequired()) {
            if (!array_key_exists($key, $data)) {
                $errors[] = Error::MISSING_KEY;
            }
            $errors[] = Error::MISSING_VALUE;
        }

        return empty($errors) ? Ok::unit($value) : Error::unit($errors);
    }
224124
protected function checkProperty(OutputInterface $output, CheckInterface $property)
    {
        $result = $property->check();

        if ($result === false) {
            $outputLevel = 'error';
            $sign = self::EMOJI_FAILURE;

            if ($property->isOptional() === true) {
                $outputLevel = 'comment';
                $sign = self::EMOJI_OPTIONAL;
            }

            $message = $property->getFailureMessage();

            // The default value from overallResult is true.
            // So it is enough to set it to false once.
            $this->overallResult = false;

        } elseif ($result === true) {
            $outputLevel = 'info';
            $sign = self::EMOJI_OK;
            $message = $property->getSuccessMessage();
        }

        $outputMessage = "  <info>%s</info>   <%s>%s</%s>";
        $outputMessage = sprintf($outputMessage, $sign, $outputLevel, $message, $outputLevel);
        $output->writeln($outputMessage);

        return $result;
    }
1208982
public function setProperty(PropertyInterface $property)
    {
        $this->property      = $property;
        $this->propertyType  = $property->type();
        $this->propertyIdent = $property->ident();

        $inputType = $property['input_type'];
        if ($inputType) {
            $this->inputType = $inputType;
        }

        $displayType = $property['display_type'];
        if ($displayType) {
            $this->displayType = $displayType;
        }

        return $this;
    }
655721
private function parseProperty(AbstractContent $content, $property)
    {
        $currentContent = $content;
        foreach (explode('->', $property) as $part) {
            if ('@' === substr($part, 0, 1)) {
                return $this->iconizeByParam($currentContent, substr($part, 1));
            } elseif ($currentContent->hasElement($part)) {
                $currentContent = $this->iconizedByElement($currentContent, $part);
            }
            
            if ($currentContent instanceof AbstractContent) {
                continue;
            } else {
                return $currentContent;
            }

            return null;
        }
    }
808532
private function parseAnnotations(PropertyContext $context, \ReflectionProperty $property, $original)
    {
        $annot = $this->propertyHandler->getPropertyAnnotation($property);

        if ($annot) {
            $context = $this->handleRepresentProperty($property, $annot, $context, $original);
        }

        return $context;
    }
704694
@Override
    public Object getPropertyValue(PropertyInfo propInfo) throws Exception {
        Object obj = registeredProperties == null ? null : registeredProperties.get(propInfo.getId());

        if (obj instanceof PropertyProxy) {
            Object value = ((PropertyProxy) obj).getValue();
            return value instanceof String ? propInfo.getPropertyType().getSerializer().deserialize((String) value) : value;
        } else {
            return obj == null ? null : propInfo.getPropertyValue(obj, obj == this);
        }
    }
456712
protected function convertPropertiesToQueryArray(PropertiesInterface $properties)
    {
        $propertiesArray = [];

        $propertyCounter = 0;
        $propertiesArray[Constants::CONTROL_PROP_ID] = [];
        $propertiesArray[Constants::CONTROL_PROP_VALUE] = [];
        foreach ($properties->getProperties() as $property) {
            $propertiesArray[Constants::CONTROL_PROP_ID][$propertyCounter] = $property->getId();

            $propertyValues = $property->getValues();

            if (count($propertyValues) === 1) {
                $propertiesArray[Constants::CONTROL_PROP_VALUE][$propertyCounter] =
                    $this->convertPropertyValueToSimpleType(
                        $property->getFirstValue()
                    );
            } elseif (count($propertyValues) > 1) {
                $propertyValueCounter = 0;
                $propertiesArray[Constants::CONTROL_PROP_VALUE][$propertyCounter] = [];
                foreach ($propertyValues as $propertyValue) {
                    $propertiesArray[Constants::CONTROL_PROP_VALUE][$propertyCounter][$propertyValueCounter] =
                        $this->convertPropertyValueToSimpleType(
                            $propertyValue
                        );
                    $propertyValueCounter ++;
                }
            }

            $propertyCounter ++;
        }

        return $propertiesArray;
    }
1206200
private function writeProperty(
        PropertyInterface $property,
        PropertyInterface $blockProperty,
        $value,
        $index,
        NodeInterface $node,
        $userId,
        $webspaceKey,
        $languageCode,
        $segmentKey,
        $isImport = false
    ) {
        // save sub property
        $contentType = $this->contentTypeManager->get($property->getContentTypeName());
        $blockPropertyWrapper = new BlockPropertyWrapper($property, $blockProperty, $index);
        $blockPropertyWrapper->setValue($value);

        if ($isImport && $contentType instanceof ContentTypeExportInterface) {
            return $contentType->importData(
                new SuluNode($node),
                $blockPropertyWrapper,
                $value,
                $userId,
                $webspaceKey,
                $languageCode,
                $segmentKey
            );
        }

        $contentType->write(
            new SuluNode($node),
            $blockPropertyWrapper,
            $userId,
            $webspaceKey,
            $languageCode,
            $segmentKey
        );
    }