diff --git a/src/AbstractVisitor.php b/src/AbstractVisitor.php index 6e86ea81d..10e50fd28 100644 --- a/src/AbstractVisitor.php +++ b/src/AbstractVisitor.php @@ -39,9 +39,9 @@ protected function getElementType(array $typeArray): ?array if (isset($typeArray['params'][1]) && \is_array($typeArray['params'][1])) { return $typeArray['params'][1]; - } else { - return $typeArray['params'][0]; } + + return $typeArray['params'][0]; } /** diff --git a/src/Accessor/DefaultAccessorStrategy.php b/src/Accessor/DefaultAccessorStrategy.php index a3c25a326..5f54fc4ef 100644 --- a/src/Accessor/DefaultAccessorStrategy.php +++ b/src/Accessor/DefaultAccessorStrategy.php @@ -96,7 +96,7 @@ public function getValue(object $object, PropertyMetadata $metadata, Serializati return $accessor($object, $metadata->name); } catch (\Error $e) { // handle uninitialized properties in PHP >= 7.4 - if (preg_match('/^Typed property ([\w\\\\@]+)::\$(\w+) must not be accessed before initialization$/', $e->getMessage(), $matches)) { + if (preg_match('/^Typed property ([\w\\\\@]+)::\$(\w+) must not be accessed before initialization$/', $e->getMessage())) { throw new UninitializedPropertyException(sprintf('Uninitialized property "%s::$%s".', $metadata->class, $metadata->name), 0, $e); } diff --git a/src/Annotation/ReadOnly.php b/src/Annotation/ReadOnly.php index 23bff2630..b5344e10e 100644 --- a/src/Annotation/ReadOnly.php +++ b/src/Annotation/ReadOnly.php @@ -2,4 +2,6 @@ declare(strict_types=1); -class_alias('JMS\Serializer\Annotation\DeprecatedReadOnly', 'JMS\Serializer\Annotation\ReadOnly'); +use JMS\Serializer\Annotation\DeprecatedReadOnly; + +class_alias(DeprecatedReadOnly::class, 'JMS\Serializer\Annotation\ReadOnly'); diff --git a/src/Construction/DoctrineObjectConstructor.php b/src/Construction/DoctrineObjectConstructor.php index 6c7602d43..bf995d32d 100644 --- a/src/Construction/DoctrineObjectConstructor.php +++ b/src/Construction/DoctrineObjectConstructor.php @@ -108,7 +108,9 @@ public function construct(DeserializationVisitorInterface $visitor, ClassMetadat if (is_array($data) && !array_key_exists($propertyMetadata->serializedName, $data)) { return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context); - } elseif (is_object($data) && !property_exists($data, $propertyMetadata->serializedName)) { + } + + if (is_object($data) && !property_exists($data, $propertyMetadata->serializedName)) { return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context); } diff --git a/src/DeserializationContext.php b/src/DeserializationContext.php index 5c16a24db..a0a7c8c6e 100644 --- a/src/DeserializationContext.php +++ b/src/DeserializationContext.php @@ -30,7 +30,7 @@ public function getDepth(): int public function increaseDepth(): void { - $this->depth += 1; + ++$this->depth; } public function decreaseDepth(): void @@ -39,6 +39,6 @@ public function decreaseDepth(): void throw new LogicException('Depth cannot be smaller than zero.'); } - $this->depth -= 1; + --$this->depth; } } diff --git a/src/EventDispatcher/EventDispatcher.php b/src/EventDispatcher/EventDispatcher.php index f3d5363bf..cc63235e5 100644 --- a/src/EventDispatcher/EventDispatcher.php +++ b/src/EventDispatcher/EventDispatcher.php @@ -87,7 +87,7 @@ public function hasListeners(string $eventName, string $class, string $format): $this->classListeners[$eventName][$class][$format] = $this->initializeListeners($eventName, $class, $format); } - return !!$this->classListeners[$eventName][$class][$format]; + return (bool) $this->classListeners[$eventName][$class][$format]; } public function dispatch(string $eventName, string $class, string $format, Event $event): void diff --git a/src/Exclusion/GroupsExclusionStrategy.php b/src/Exclusion/GroupsExclusionStrategy.php index c3f0a7d99..04c306875 100644 --- a/src/Exclusion/GroupsExclusionStrategy.php +++ b/src/Exclusion/GroupsExclusionStrategy.php @@ -59,19 +59,19 @@ public function shouldSkipProperty(PropertyMetadata $property, Context $navigato } return $this->shouldSkipUsingGroups($property, $groups); - } else { - if (!$property->groups) { - return !isset($this->groups[self::DEFAULT_GROUP]); - } + } - foreach ($property->groups as $group) { - if (is_scalar($group) && isset($this->groups[$group])) { - return false; - } - } + if (!$property->groups) { + return !isset($this->groups[self::DEFAULT_GROUP]); + } - return true; + foreach ($property->groups as $group) { + if (is_scalar($group) && isset($this->groups[$group])) { + return false; + } } + + return true; } private function shouldSkipUsingGroups(PropertyMetadata $property, array $groups): bool diff --git a/src/GraphNavigator/DeserializationGraphNavigator.php b/src/GraphNavigator/DeserializationGraphNavigator.php index 495df3f1f..bdd9ac99e 100644 --- a/src/GraphNavigator/DeserializationGraphNavigator.php +++ b/src/GraphNavigator/DeserializationGraphNavigator.php @@ -158,7 +158,7 @@ public function accept($data, ?array $type = null) // could also simply be an artifical type. if (null !== $handler = $this->handlerRegistry->getHandler(GraphNavigatorInterface::DIRECTION_DESERIALIZATION, $type['name'], $this->format)) { try { - $rs = \call_user_func($handler, $this->visitor, $data, $type, $this->context); + $rs = $handler($this->visitor, $data, $type, $this->context); $this->context->decreaseDepth(); return $rs; diff --git a/src/GraphNavigator/SerializationGraphNavigator.php b/src/GraphNavigator/SerializationGraphNavigator.php index 1de6e3bb7..d0626c64b 100644 --- a/src/GraphNavigator/SerializationGraphNavigator.php +++ b/src/GraphNavigator/SerializationGraphNavigator.php @@ -206,7 +206,7 @@ public function accept($data, ?array $type = null) // could also simply be an artifical type. if (null !== $handler = $this->handlerRegistry->getHandler(GraphNavigatorInterface::DIRECTION_SERIALIZATION, $type['name'], $this->format)) { try { - $rs = \call_user_func($handler, $this->visitor, $data, $type, $this->context); + $rs = $handler($this->visitor, $data, $type, $this->context); $this->context->stopVisiting($data); return $rs; diff --git a/src/Handler/DateHandler.php b/src/Handler/DateHandler.php index da187b28a..abb517f19 100644 --- a/src/Handler/DateHandler.php +++ b/src/Handler/DateHandler.php @@ -262,7 +262,6 @@ private function parseDateTime($data, array $type, bool $immutable = false): \Da private function parseDateInterval(string $data): \DateInterval { - $dateInterval = null; try { $f = 0.0; if (preg_match('~\.\d+~', $data, $match)) { diff --git a/src/Handler/EnumHandler.php b/src/Handler/EnumHandler.php index 1adbc051a..89acaf8cd 100644 --- a/src/Handler/EnumHandler.php +++ b/src/Handler/EnumHandler.php @@ -52,9 +52,9 @@ public function serializeEnum( $valueType = isset($type['params'][2]) ? ['name' => $type['params'][2]] : null; return $context->getNavigator()->accept($enum->value, $valueType); - } else { - return $context->getNavigator()->accept($enum->name); } + + return $context->getNavigator()->accept($enum->name); } /** @@ -81,12 +81,12 @@ public function deserializeEnum(DeserializationVisitorInterface $visitor, $data, } return $enumType::from($caseValue); - } else { - if (!$ref->hasCase($caseValue)) { - throw new InvalidMetadataException(sprintf('The type "%s" does not have the case "%s"', $ref->getName(), $caseValue)); - } + } - return $ref->getCase($caseValue)->getValue(); + if (!$ref->hasCase($caseValue)) { + throw new InvalidMetadataException(sprintf('The type "%s" does not have the case "%s"', $ref->getName(), $caseValue)); } + + return $ref->getCase($caseValue)->getValue(); } } diff --git a/src/Handler/FormErrorHandler.php b/src/Handler/FormErrorHandler.php index 48a8d8a0a..1255b2586 100644 --- a/src/Handler/FormErrorHandler.php +++ b/src/Handler/FormErrorHandler.php @@ -131,9 +131,9 @@ private function getErrorMessage(FormError $error): ?string if (null !== $error->getMessagePluralization()) { if ($this->translator instanceof TranslatorContract) { return $this->translator->trans($error->getMessageTemplate(), ['%count%' => $error->getMessagePluralization()] + $error->getMessageParameters(), $this->translationDomain); - } else { - return $this->translator->transChoice($error->getMessageTemplate(), $error->getMessagePluralization(), $error->getMessageParameters(), $this->translationDomain); } + + return $this->translator->transChoice($error->getMessageTemplate(), $error->getMessagePluralization(), $error->getMessageParameters(), $this->translationDomain); } return $this->translator->trans($error->getMessageTemplate(), $error->getMessageParameters(), $this->translationDomain); diff --git a/src/Handler/HandlerRegistry.php b/src/Handler/HandlerRegistry.php index 1b8ae94ae..a2b811c6d 100644 --- a/src/Handler/HandlerRegistry.php +++ b/src/Handler/HandlerRegistry.php @@ -70,11 +70,7 @@ public function registerHandler(int $direction, string $typeName, string $format */ public function getHandler(int $direction, string $typeName, string $format) { - if (!isset($this->handlers[$direction][$typeName][$format])) { - return null; - } - - return $this->handlers[$direction][$typeName][$format]; + return $this->handlers[$direction][$typeName][$format] ?? null; } /** diff --git a/src/JsonSerializationVisitor.php b/src/JsonSerializationVisitor.php index 4a57da4e1..b7db8bbbf 100644 --- a/src/JsonSerializationVisitor.php +++ b/src/JsonSerializationVisitor.php @@ -89,7 +89,7 @@ public function visitDouble(float $data, array $type) */ public function visitArray(array $data, array $type) { - \array_push($this->dataStack, $data); + $this->dataStack[] = $data; $rs = isset($type['params'][1]) ? new \ArrayObject() : []; @@ -117,7 +117,7 @@ public function visitArray(array $data, array $type) public function startVisitingObject(ClassMetadata $metadata, object $data, array $type): void { - \array_push($this->dataStack, $this->data); + $this->dataStack[] = $this->data; $this->data = true === $metadata->isMap ? new \ArrayObject() : []; } diff --git a/src/Metadata/ClassMetadata.php b/src/Metadata/ClassMetadata.php index 805ec294b..00db25525 100644 --- a/src/Metadata/ClassMetadata.php +++ b/src/Metadata/ClassMetadata.php @@ -242,7 +242,9 @@ public function merge(MergeableInterface $object): void $this->discriminatorBaseClass, $this->discriminatorBaseClass )); - } elseif (!$this->discriminatorFieldName && $object->discriminatorFieldName) { + } + + if (!$this->discriminatorFieldName && $object->discriminatorFieldName) { $this->discriminatorFieldName = $object->discriminatorFieldName; $this->discriminatorMap = $object->discriminatorMap; } diff --git a/src/Metadata/Driver/AbstractDoctrineTypeDriver.php b/src/Metadata/Driver/AbstractDoctrineTypeDriver.php index 70320f78e..4cd20dc76 100644 --- a/src/Metadata/Driver/AbstractDoctrineTypeDriver.php +++ b/src/Metadata/Driver/AbstractDoctrineTypeDriver.php @@ -150,10 +150,6 @@ protected function tryLoadingDoctrineMetadata(string $className): ?DoctrineClass protected function normalizeFieldType(string $type): ?string { - if (!isset($this->fieldMapping[$type])) { - return null; - } - - return $this->fieldMapping[$type]; + return $this->fieldMapping[$type] ?? null; } } diff --git a/src/Metadata/Driver/AnnotationOrAttributeDriver.php b/src/Metadata/Driver/AnnotationOrAttributeDriver.php index a3d14f035..247587e0f 100644 --- a/src/Metadata/Driver/AnnotationOrAttributeDriver.php +++ b/src/Metadata/Driver/AnnotationOrAttributeDriver.php @@ -153,13 +153,19 @@ public function loadMetadataForClass(\ReflectionClass $class): ?BaseClassMetadat if ($annot instanceof PreSerialize) { $classMetadata->addPreSerializeMethod(new MethodMetadata($name, $method->name)); continue 2; - } elseif ($annot instanceof PostDeserialize) { + } + + if ($annot instanceof PostDeserialize) { $classMetadata->addPostDeserializeMethod(new MethodMetadata($name, $method->name)); continue 2; - } elseif ($annot instanceof PostSerialize) { + } + + if ($annot instanceof PostSerialize) { $classMetadata->addPostSerializeMethod(new MethodMetadata($name, $method->name)); continue 2; - } elseif ($annot instanceof VirtualProperty) { + } + + if ($annot instanceof VirtualProperty) { $virtualPropertyMetadata = new VirtualPropertyMetadata($name, $method->name); $propertiesMetadata[] = $virtualPropertyMetadata; $propertiesAnnotations[] = $methodAnnotations; diff --git a/src/Metadata/Driver/DefaultValuePropertyDriver.php b/src/Metadata/Driver/DefaultValuePropertyDriver.php index c50503545..89ba14c5f 100644 --- a/src/Metadata/Driver/DefaultValuePropertyDriver.php +++ b/src/Metadata/Driver/DefaultValuePropertyDriver.php @@ -37,7 +37,7 @@ public function loadMetadataForClass(ReflectionClass $class): ?ClassMetadata \assert($classMetadata instanceof SerializerClassMetadata); - foreach ($classMetadata->propertyMetadata as $key => $propertyMetadata) { + foreach ($classMetadata->propertyMetadata as $propertyMetadata) { \assert($propertyMetadata instanceof PropertyMetadata); if (null !== $propertyMetadata->hasDefault) { continue; diff --git a/src/Metadata/Driver/DocBlockDriver.php b/src/Metadata/Driver/DocBlockDriver.php index f7b1f97e3..14f689eb0 100644 --- a/src/Metadata/Driver/DocBlockDriver.php +++ b/src/Metadata/Driver/DocBlockDriver.php @@ -57,7 +57,7 @@ public function loadMetadataForClass(ReflectionClass $class): ?ClassMetadata // We base our scan on the internal driver's property list so that we // respect any internal allow/blocklist like in the AnnotationDriver - foreach ($classMetadata->propertyMetadata as $key => $propertyMetadata) { + foreach ($classMetadata->propertyMetadata as $propertyMetadata) { // If the inner driver provides a type, don't guess anymore. if ($propertyMetadata->type) { continue; diff --git a/src/Metadata/Driver/DocBlockDriver/DocBlockTypeResolver.php b/src/Metadata/Driver/DocBlockDriver/DocBlockTypeResolver.php index f3ff04645..639ceb231 100644 --- a/src/Metadata/Driver/DocBlockDriver/DocBlockTypeResolver.php +++ b/src/Metadata/Driver/DocBlockDriver/DocBlockTypeResolver.php @@ -305,8 +305,8 @@ private function hasGlobalNamespacePrefix(string $typeHint): bool private function gatherGroupUseStatements(string $classContents): array { $foundUseStatements = []; - preg_match_all(self::GROUP_USE_STATEMENTS_REGEX, $classContents, $foundGroupUseStatements); - for ($useStatementIndex = 0; $useStatementIndex < count($foundGroupUseStatements[0]); $useStatementIndex++) { + $found = preg_match_all(self::GROUP_USE_STATEMENTS_REGEX, $classContents, $foundGroupUseStatements); + for ($useStatementIndex = 0; $useStatementIndex < $found; $useStatementIndex++) { foreach (explode(',', $foundGroupUseStatements[2][$useStatementIndex]) as $singleUseStatement) { $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]) . trim($singleUseStatement); } @@ -318,8 +318,8 @@ private function gatherGroupUseStatements(string $classContents): array private function gatherSingleUseStatements(string $classContents): array { $foundUseStatements = []; - preg_match_all(self::SINGLE_USE_STATEMENTS_REGEX, $classContents, $foundSingleUseStatements); - for ($useStatementIndex = 0; $useStatementIndex < count($foundSingleUseStatements[0]); $useStatementIndex++) { + $found = preg_match_all(self::SINGLE_USE_STATEMENTS_REGEX, $classContents, $foundSingleUseStatements); + for ($useStatementIndex = 0; $useStatementIndex < $found; $useStatementIndex++) { $foundUseStatements[] = trim($foundSingleUseStatements[1][$useStatementIndex]); } diff --git a/src/Metadata/Driver/XmlDriver.php b/src/Metadata/Driver/XmlDriver.php index dd5436709..dfbc80751 100644 --- a/src/Metadata/Driver/XmlDriver.php +++ b/src/Metadata/Driver/XmlDriver.php @@ -211,7 +211,7 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $path): } if (null !== $excludeIf = $pElem->attributes()->{'expose-if'}) { - $pMetadata->excludeIf = $this->parseExpression('!(' . (string) $excludeIf . ')'); + $pMetadata->excludeIf = $this->parseExpression('!(' . $excludeIf . ')'); $isExpose = true; } @@ -348,8 +348,8 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $path): } if ( - (ExclusionPolicy::NONE === (string) $exclusionPolicy && !$isExclude) - || (ExclusionPolicy::ALL === (string) $exclusionPolicy && $isExpose) + (ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) + || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) ) { $metadata->addPropertyMetadata($pMetadata); } diff --git a/src/Metadata/PropertyMetadata.php b/src/Metadata/PropertyMetadata.php index ff41c949f..143038a1e 100644 --- a/src/Metadata/PropertyMetadata.php +++ b/src/Metadata/PropertyMetadata.php @@ -211,10 +211,7 @@ public static function isCollectionList(?array $type = null): bool public static function isCollectionMap(?array $type = null): bool { - return is_array($type) - && 'array' === $type['name'] - && isset($type['params'][0]) - && isset($type['params'][1]); + return isset($type['params'][0], $type['params'][1]) && is_array($type) && 'array' === $type['name']; } protected function serializeToArray(): array diff --git a/src/Serializer.php b/src/Serializer.php index af0540596..56c091fd1 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -106,7 +106,9 @@ private function findInitialType(?string $type, SerializationContext $context): { if (null !== $type) { return $type; - } elseif ($context->hasAttribute('initial_type')) { + } + + if ($context->hasAttribute('initial_type')) { return $context->getAttribute('initial_type'); } diff --git a/src/Type/Lexer.php b/src/Type/Lexer.php index 80dd048db..17fe70aa4 100644 --- a/src/Type/Lexer.php +++ b/src/Type/Lexer.php @@ -72,12 +72,12 @@ protected function getType(&$value) // Recognize quoted strings case "'" === $value[0]: - $value = str_replace("''", "'", substr($value, 1, strlen($value) - 2)); + $value = str_replace("''", "'", substr($value, 1, -1)); return self::T_STRING; case '"' === $value[0]: - $value = str_replace('""', '"', substr($value, 1, strlen($value) - 2)); + $value = str_replace('""', '"', substr($value, 1, -1)); return self::T_STRING; diff --git a/src/Type/Parser.php b/src/Type/Parser.php index ab7d361a7..bdd7e174a 100644 --- a/src/Type/Parser.php +++ b/src/Type/Parser.php @@ -44,9 +44,11 @@ private function visit() } if (Lexer::T_FLOAT === $this->lexer->token->type) { - return floatval($this->lexer->token->value); - } elseif (Lexer::T_INTEGER === $this->lexer->token->type) { - return intval($this->lexer->token->value); + return (float) $this->lexer->token->value; + } + + if (Lexer::T_INTEGER === $this->lexer->token->type) { + return (int) $this->lexer->token->value; } elseif (Lexer::T_NULL === $this->lexer->token->type) { return null; } elseif (Lexer::T_STRING === $this->lexer->token->type) { @@ -54,7 +56,9 @@ private function visit() } elseif (Lexer::T_IDENTIFIER === $this->lexer->token->type) { if ($this->lexer->isNextToken(Lexer::T_TYPE_START)) { return $this->visitCompoundType(); - } elseif ($this->lexer->isNextToken(Lexer::T_ARRAY_START)) { + } + + if ($this->lexer->isNextToken(Lexer::T_ARRAY_START)) { return $this->visitArrayType(); } diff --git a/src/Visitor/Factory/XmlSerializationVisitorFactory.php b/src/Visitor/Factory/XmlSerializationVisitorFactory.php index 10541a457..d72afddcc 100644 --- a/src/Visitor/Factory/XmlSerializationVisitorFactory.php +++ b/src/Visitor/Factory/XmlSerializationVisitorFactory.php @@ -72,7 +72,7 @@ public function setDefaultEncoding(string $encoding): self public function setFormatOutput(bool $formatOutput): self { - $this->formatOutput = (bool) $formatOutput; + $this->formatOutput = $formatOutput; return $this; } diff --git a/src/XmlDeserializationVisitor.php b/src/XmlDeserializationVisitor.php index a2ba33016..8be776452 100644 --- a/src/XmlDeserializationVisitor.php +++ b/src/XmlDeserializationVisitor.php @@ -146,11 +146,13 @@ public function visitBoolean($data, array $type): bool if ('true' === $data || '1' === $data) { return true; - } elseif ('false' === $data || '0' === $data) { + } + + if ('false' === $data || '0' === $data) { return false; - } else { - throw new RuntimeException(sprintf('Could not convert data to boolean. Expected "true", "false", "1" or "0", but got %s.', json_encode($data))); } + + throw new RuntimeException(sprintf('Could not convert data to boolean. Expected "true", "false", "1" or "0", but got %s.', json_encode($data))); } /** diff --git a/src/XmlSerializationVisitor.php b/src/XmlSerializationVisitor.php index ffa1e1419..e0b4fa937 100644 --- a/src/XmlSerializationVisitor.php +++ b/src/XmlSerializationVisitor.php @@ -146,7 +146,7 @@ public function visitString(string $data, array $type) { $doCData = null !== $this->currentMetadata ? $this->currentMetadata->xmlElementCData : true; - return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string) $data); + return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode($data); } /** @@ -318,9 +318,7 @@ public function visitProperty(PropertyMetadata $metadata, $v): void } if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) { - $namespace = null !== $metadata->xmlNamespace - ? $metadata->xmlNamespace - : $this->getClassDefaultNamespace($this->objectMetadataStack->top()); + $namespace = $metadata->xmlNamespace ?? $this->getClassDefaultNamespace($this->objectMetadataStack->top()); $element = $this->createElement($metadata->serializedName, $namespace); $this->currentNode->appendChild($element); diff --git a/tests/Fixtures/AccessorSetter.php b/tests/Fixtures/AccessorSetter.php index c1bedf23b..d9ab91607 100644 --- a/tests/Fixtures/AccessorSetter.php +++ b/tests/Fixtures/AccessorSetter.php @@ -60,62 +60,3 @@ public function setCollectionDifferent($collection) $this->collection = array_combine($collection, $collection); } } - -class AccessorSetterElement -{ - /** - * @Serializer\Type("string") - * @Serializer\Accessor(setter="setAttributeDifferent") - * @Serializer\XmlAttribute - * - * @var string - */ - #[Serializer\Type(name: 'string')] - #[Serializer\Accessor(setter: 'setAttributeDifferent')] - #[Serializer\XmlAttribute] - protected $attribute; - - /** - * @Serializer\Type("string") - * @Serializer\Accessor(setter="setElementDifferent") - * @Serializer\XmlValue - * - * @var string - */ - #[Serializer\Type(name: 'string')] - #[Serializer\Accessor(setter: 'setElementDifferent')] - #[Serializer\XmlValue] - protected $element; - - /** - * @return string - */ - public function getAttribute() - { - return $this->attribute; - } - - /** - * @param string $attribute - */ - public function setAttributeDifferent($attribute) - { - $this->attribute = $attribute . '-different'; - } - - /** - * @param string $element - */ - public function setElementDifferent($element) - { - $this->element = $element . '-different'; - } - - /** - * @return string - */ - public function getElement() - { - return $this->element; - } -} diff --git a/tests/Fixtures/AccessorSetterElement.php b/tests/Fixtures/AccessorSetterElement.php new file mode 100644 index 000000000..54570364d --- /dev/null +++ b/tests/Fixtures/AccessorSetterElement.php @@ -0,0 +1,64 @@ +attribute; + } + + /** + * @param string $attribute + */ + public function setAttributeDifferent($attribute) + { + $this->attribute = $attribute . '-different'; + } + + /** + * @param string $element + */ + public function setElementDifferent($element) + { + $this->element = $element . '-different'; + } + + /** + * @return string + */ + public function getElement() + { + return $this->element; + } +} diff --git a/tests/Fixtures/IndexedCommentsBlogPost.php b/tests/Fixtures/IndexedCommentsBlogPost.php index d8526e97d..451d975ac 100644 --- a/tests/Fixtures/IndexedCommentsBlogPost.php +++ b/tests/Fixtures/IndexedCommentsBlogPost.php @@ -45,20 +45,3 @@ public function getCommentsIndexedByAuthor() return $indexedComments; } } - -class IndexedCommentsList -{ - /** @XmlList(inline=true, entry="comment") */ - #[XmlList(entry: 'comment', inline: true)] - private $comments = []; - - /** @XmlAttribute */ - #[XmlAttribute] - private $count = 0; - - public function addComment(Comment $comment) - { - $this->comments[] = $comment; - $this->count += 1; - } -} diff --git a/tests/Fixtures/IndexedCommentsList.php b/tests/Fixtures/IndexedCommentsList.php new file mode 100644 index 000000000..dbebf2800 --- /dev/null +++ b/tests/Fixtures/IndexedCommentsList.php @@ -0,0 +1,23 @@ +comments[] = $comment; + $this->count += 1; + } +}