Skip to content

Commit

Permalink
build(code style): Update src to 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Czarnecki committed Jan 2, 2024
1 parent e8e2dd8 commit 767bd36
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 43 deletions.
4 changes: 1 addition & 3 deletions src/Accessor/DefaultAccessorStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ public function getValue(object $object, PropertyMetadata $metadata, Serializati

$accessor = $this->readAccessors[$metadata->class] ?? null;
if (null === $accessor) {
$accessor = \Closure::bind(static function ($o, $name) {
return $o->$name;
}, null, $metadata->class);
$accessor = \Closure::bind(static fn($o, $name) => $o->$name, null, $metadata->class);

Check failure on line 89 in src/Accessor/DefaultAccessorStrategy.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

There must be exactly 1 whitespace after "fn" keyword.
$this->readAccessors[$metadata->class] = $accessor;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/ReadOnly.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

declare(strict_types=1);

class_alias('JMS\Serializer\Annotation\DeprecatedReadOnly', 'JMS\Serializer\Annotation\ReadOnly');
class_alias(\JMS\Serializer\Annotation\DeprecatedReadOnly::class, 'JMS\Serializer\Annotation\ReadOnly');

Check failure on line 5 in src/Annotation/ReadOnly.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

Class \JMS\Serializer\Annotation\DeprecatedReadOnly should not be referenced via a fully qualified name, but via a use statement.
12 changes: 3 additions & 9 deletions src/Metadata/Driver/AnnotationOrAttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ protected function getClassAnnotations(\ReflectionClass $class): array

if (PHP_VERSION_ID >= 80000) {
$annotations = array_map(
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
static fn(\ReflectionAttribute $attribute): object => $attribute->newInstance(),
$class->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}
Expand All @@ -330,9 +328,7 @@ protected function getMethodAnnotations(\ReflectionMethod $method): array

if (PHP_VERSION_ID >= 80000) {
$annotations = array_map(
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
static fn(\ReflectionAttribute $attribute): object => $attribute->newInstance(),
$method->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}
Expand All @@ -353,9 +349,7 @@ protected function getPropertyAnnotations(\ReflectionProperty $property): array

if (PHP_VERSION_ID >= 80000) {
$annotations = array_map(
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
static fn(\ReflectionAttribute $attribute): object => $attribute->newInstance(),
$property->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}
Expand Down
12 changes: 3 additions & 9 deletions src/Metadata/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class AttributeDriver extends AnnotationOrAttributeDriver
protected function getClassAnnotations(\ReflectionClass $class): array
{
return array_map(
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
static fn(\ReflectionAttribute $attribute): object => $attribute->newInstance(),

Check failure on line 17 in src/Metadata/Driver/AttributeDriver.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

There must be exactly 1 whitespace after "fn" keyword.
$class->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}
Expand All @@ -27,9 +25,7 @@ static function (\ReflectionAttribute $attribute): object {
protected function getMethodAnnotations(\ReflectionMethod $method): array
{
return array_map(
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
static fn(\ReflectionAttribute $attribute): object => $attribute->newInstance(),

Check failure on line 28 in src/Metadata/Driver/AttributeDriver.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

There must be exactly 1 whitespace after "fn" keyword.
$method->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}
Expand All @@ -40,9 +36,7 @@ static function (\ReflectionAttribute $attribute): object {
protected function getPropertyAnnotations(\ReflectionProperty $property): array
{
return array_map(
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
static fn(\ReflectionAttribute $attribute): object => $attribute->newInstance(),

Check failure on line 39 in src/Metadata/Driver/AttributeDriver.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

There must be exactly 1 whitespace after "fn" keyword.
$property->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Metadata/Driver/AttributeDriver/AttributeReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ private function buildAnnotation(array $attributes): ?SerializerAttribute
private function buildAnnotations(array $attributes): array
{
return array_map(
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
static fn(\ReflectionAttribute $attribute): object => $attribute->newInstance(),

Check failure on line 88 in src/Metadata/Driver/AttributeDriver/AttributeReader.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

There must be exactly 1 whitespace after "fn" keyword.
$attributes,
);
}
Expand Down
16 changes: 4 additions & 12 deletions src/Metadata/Driver/DocBlockDriver/DocBlockTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,13 @@ private function getDocBlocTypeHint($reflector): ?string
// Generic array syntax: array<Product> | array<\Foo\Bar\Product> | array<int,Product>
if ($type instanceof GenericTypeNode) {
if ($this->isSimpleType($type->type, 'array')) {
$resolvedTypes = array_map(function (TypeNode $node) use ($reflector) {
return $this->resolveTypeFromTypeNode($node, $reflector);
}, $type->genericTypes);
$resolvedTypes = array_map(fn(TypeNode $node) => $this->resolveTypeFromTypeNode($node, $reflector), $type->genericTypes);

Check failure on line 118 in src/Metadata/Driver/DocBlockDriver/DocBlockTypeResolver.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

There must be exactly 1 whitespace after "fn" keyword.

return 'array<' . implode(',', $resolvedTypes) . '>';
}

if ($this->isSimpleType($type->type, 'list')) {
$resolvedTypes = array_map(function (TypeNode $node) use ($reflector) {
return $this->resolveTypeFromTypeNode($node, $reflector);
}, $type->genericTypes);
$resolvedTypes = array_map(fn(TypeNode $node) => $this->resolveTypeFromTypeNode($node, $reflector), $type->genericTypes);

Check failure on line 124 in src/Metadata/Driver/DocBlockDriver/DocBlockTypeResolver.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

There must be exactly 1 whitespace after "fn" keyword.

return 'array<int, ' . implode(',', $resolvedTypes) . '>';
}
Expand Down Expand Up @@ -194,9 +190,7 @@ private function flattenParamTagValueTypes(string $parameterName, array $varTagV
*/
private function filterNullFromTypes(array $types): array
{
return array_values(array_filter(array_map(function (TypeNode $node) {
return $this->isNullType($node) ? null : $node;
}, $types)));
return array_values(array_filter(array_map(fn(TypeNode $node) => $this->isNullType($node) ? null : $node, $types)));

Check failure on line 193 in src/Metadata/Driver/DocBlockDriver/DocBlockTypeResolver.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

There must be exactly 1 whitespace after "fn" keyword.
}

/**
Expand Down Expand Up @@ -427,9 +421,7 @@ private function getPhpstanType(\ReflectionClass $declaringClass, string $typeHi

return sprintf('array<%s>', implode(
',',
array_map(static function (string $type) use ($reflector, $self) {
return $self->resolveType(trim($type), $reflector);
}, $types),
array_map(static fn(string $type) => $self->resolveType(trim($type), $reflector), $types),
));
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/Ordering/AlphabeticalPropertyOrderingStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public function order(array $properties): array
{
uasort(
$properties,
static function (PropertyMetadata $a, PropertyMetadata $b): int {
return strcmp($a->name, $b->name);
},
static fn(PropertyMetadata $a, PropertyMetadata $b): int => strcmp($a->name, $b->name),

Check failure on line 18 in src/Ordering/AlphabeticalPropertyOrderingStrategy.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

There must be exactly 1 whitespace after "fn" keyword.
);

return $properties;
Expand Down
4 changes: 1 addition & 3 deletions src/XmlSerializationVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 767bd36

Please sign in to comment.