Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require PHP 7.4 and Symfony 5.4 #1528

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ jobs:
strategy:
matrix:
php-version:
- "7.2"
- "8.0"
- "8.1"
- "7.4"
- "8.2"

steps:
- name: Checkout code
Expand All @@ -29,7 +28,7 @@ jobs:

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: Run performance benchmarks
run: |
vendor/bin/phpbench run tests/Benchmark/Performance --report=aggregate
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.2"
- "7.4"

steps:
- name: "Checkout"
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": "^7.2 || ^8.0",
"php": "^7.4 || ^8.0",
"doctrine/annotations": "^1.14 || ^2.0",
"doctrine/instantiator": "^1.3.1 || ^2.0",
"doctrine/lexer": "^2.0 || ^3.0",
Expand All @@ -39,16 +39,16 @@
"ocramius/proxy-manager": "^1.0 || ^2.0",
"phpbench/phpbench": "^1.0",
"phpstan/phpstan": "^1.0.2",
"phpunit/phpunit": "^8.5.21 || ^9.0 || ^10.0",
"phpunit/phpunit": "^9.0 || ^10.0",
"psr/container": "^1.0 || ^2.0",
"symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/expression-language": "^3.2 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/filesystem": "^4.2 || ^5.0 || ^6.0 || ^7.0",
"symfony/form": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/translation": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/uid": "^5.1 || ^6.0 || ^7.0",
"symfony/validator": "^3.1.9 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/expression-language": "^5.4 || ^6.0 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0",
"symfony/form": "^5.4 || ^6.0 || ^7.0",
"symfony/translation": "^5.4 || ^6.0 || ^7.0",
"symfony/uid": "^5.4 || ^6.0 || ^7.0",
"symfony/validator": "^5.4 || ^6.0 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
"twig/twig": "^1.34 || ^2.4 || ^3.0"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<arg name="colors"/>
<arg value="nps"/>

<config name="php_version" value="70200"/>
<config name="php_version" value="70400"/>

<file>src/</file>
<file>tests/</file>
Expand Down
4 changes: 2 additions & 2 deletions src/Annotation/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct($values = [], $name = null)
{
if ((null !== $name) && !is_string($name) && !(is_object($name) && method_exists($name, '__toString'))) {
throw new \RuntimeException(
'Type must be either string, null or object implements __toString() method.'
'Type must be either string, null or object implements __toString() method.',
);
}

Expand All @@ -34,7 +34,7 @@ public function __construct($values = [], $name = null)
if (is_object($values)) {
if (false === method_exists($values, '__toString')) {
throw new \RuntimeException(
'Type must be either string or object implements __toString() method.'
'Type must be either string or object implements __toString() method.',
);
}

Expand Down
4 changes: 1 addition & 3 deletions src/Builder/DefaultDriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ public function createDriver(array $metadataDirs, Reader $annotationReader): Dri
$driver = new EnumPropertiesDriver($driver);
}

if (PHP_VERSION_ID >= 70400) {
$driver = new TypedPropertiesDriver($driver, $this->typeParser);
}
$driver = new TypedPropertiesDriver($driver, $this->typeParser);

if (PHP_VERSION_ID >= 80000) {
$driver = new DefaultValuePropertyDriver($driver);
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/NonCastableTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public function __construct(string $expectedType, $value)
sprintf(
'Cannot convert value of type "%s" to %s',
gettype($value),
$expectedType
)
$expectedType,
),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/NonVisitableTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function fromDataAndType($data, array $type, ?RuntimeException $pr
return new self(
sprintf('Type %s cannot be visited as %s', get_debug_type($data), $type['name']),
0,
$previous
$previous,
);
}
}
2 changes: 1 addition & 1 deletion src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function noMetadataForProperty(string $class, string $prop): self
return new RuntimeException(sprintf(
'You must define a type for %s::$%s.',
$class,
$prop
$prop,
));
}
}
2 changes: 1 addition & 1 deletion src/GraphNavigator/DeserializationGraphNavigator.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private function resolveMetadata($data, ClassMetadata $metadata): ?ClassMetadata
'The type value "%s" does not exist in the discriminator map of class "%s". Available types: %s',
$typeValue,
$metadata->name,
implode(', ', array_keys($metadata->discriminatorMap))
implode(', ', array_keys($metadata->discriminatorMap)),
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Handler/DateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private function parseDateTime($data, array $type, bool $immutable = false): \Da
throw new RuntimeException(sprintf(
'Invalid datetime "%s", expected one of the format %s.',
$data,
'"' . implode('", "', $formatTried) . '"'
'"' . implode('", "', $formatTried) . '"',
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Handler/FormErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(?object $translator = null, string $translationDomai
self::class,
TranslatorInterface::class,
TranslatorContract::class,
get_class($translator)
get_class($translator),
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/JsonDeserializationVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function visitDiscriminatorMapProperty($data, ClassMetadata $metadata): s
throw new LogicException(sprintf(
'The discriminator field name "%s" for base-class "%s" was not found in input data.',
$metadata->discriminatorFieldName,
$metadata->name
$metadata->name,
));
}

Expand Down
8 changes: 4 additions & 4 deletions src/Metadata/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function merge(MergeableInterface $object): void
'The discriminator of class "%s" would overwrite the discriminator of the parent class "%s". Please define all possible sub-classes in the discriminator of %s.',
$object->name,
$this->discriminatorBaseClass,
$this->discriminatorBaseClass
$this->discriminatorBaseClass,
));
} elseif (!$this->discriminatorFieldName && $object->discriminatorFieldName) {
$this->discriminatorFieldName = $object->discriminatorFieldName;
Expand Down Expand Up @@ -359,7 +359,7 @@ private function handleDiscriminatorProperty(): void
throw new InvalidMetadataException(sprintf(
'The sub-class "%s" is not listed in the discriminator of the base class "%s".',
$this->name,
$this->discriminatorBaseClass
$this->discriminatorBaseClass,
));
}

Expand All @@ -373,15 +373,15 @@ private function handleDiscriminatorProperty(): void
'The discriminator field name "%s" of the base-class "%s" conflicts with a regular property of the sub-class "%s".',
$this->discriminatorFieldName,
$this->discriminatorBaseClass,
$this->name
$this->name,
));
}

$discriminatorProperty = new StaticPropertyMetadata(
$this->name,
$this->discriminatorFieldName,
$typeValue,
$this->discriminatorGroups
$this->discriminatorGroups,
);
$discriminatorProperty->serializedName = $this->discriminatorFieldName;
$discriminatorProperty->xmlAttribute = $this->xmlDiscriminatorAttribute;
Expand Down
10 changes: 5 additions & 5 deletions src/Metadata/Driver/AnnotationOrAttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
$virtualPropertyMetadata = new ExpressionPropertyMetadata(
$name,
$annot->name,
$this->parseExpression($annot->exp)
$this->parseExpression($annot->exp),
);
$propertiesMetadata[] = $virtualPropertyMetadata;
$propertiesAnnotations[] = $annot->options;
Expand Down Expand Up @@ -248,7 +248,7 @@
throw new InvalidMetadataException(sprintf(
'Invalid group name "%s" on "%s", did you mean to create multiple groups?',
implode(', ', $propertyMetadata->groups),
$propertyMetadata->class . '->' . $propertyMetadata->name
$propertyMetadata->class . '->' . $propertyMetadata->name,
));
}
}
Expand Down Expand Up @@ -290,7 +290,7 @@
}
}

if (!$configured) {

Check failure on line 293 in src/Metadata/Driver/AnnotationOrAttributeDriver.php

View workflow job for this annotation

GitHub Actions / Coding Standards (7.4)

Empty IF statement detected
// return null;
// uncomment the above line afetr a couple of months
}
Expand All @@ -310,7 +310,7 @@
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
$class->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF)
$class->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}

Expand All @@ -333,7 +333,7 @@
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
$method->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF)
$method->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}

Expand All @@ -356,7 +356,7 @@
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
$property->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF)
$property->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Metadata/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected function getClassAnnotations(\ReflectionClass $class): array
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
$class->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF)
$class->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}

Expand All @@ -30,7 +30,7 @@ protected function getMethodAnnotations(\ReflectionMethod $method): array
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
$method->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF)
$method->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}

Expand All @@ -43,7 +43,7 @@ protected function getPropertyAnnotations(\ReflectionProperty $property): array
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
$property->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF)
$property->getAttributes(SerializerAttribute::class, \ReflectionAttribute::IS_INSTANCEOF),
);
}
}
7 changes: 5 additions & 2 deletions src/Metadata/Driver/AttributeDriver/AttributeReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ public function getPropertyAnnotation(ReflectionProperty $property, $annotationN
return $this->reader->getClassAnnotation($property, $annotationName) ?? $this->buildAnnotation($attributes);
}

private function buildAnnotation(array $attributes): ?object
/**
* @param list<\ReflectionAttribute<SerializerAttribute>> $attributes
*/
private function buildAnnotation(array $attributes): ?SerializerAttribute
{
if (!isset($attributes[0])) {
return null;
Expand All @@ -85,7 +88,7 @@ private function buildAnnotations(array $attributes): array
static function (\ReflectionAttribute $attribute): object {
return $attribute->newInstance();
},
$attributes
$attributes,
);
}
}
4 changes: 2 additions & 2 deletions src/Metadata/Driver/DocBlockDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public function loadMetadataForClass(ReflectionClass $class): ?ClassMetadata
try {
if ($propertyMetadata instanceof VirtualPropertyMetadata) {
$type = $this->docBlockTypeResolver->getMethodDocblockTypeHint(
new ReflectionMethod($propertyMetadata->class, $propertyMetadata->getter)
new ReflectionMethod($propertyMetadata->class, $propertyMetadata->getter),
);
} else {
$type = $this->docBlockTypeResolver->getPropertyDocblockTypeHint(
new ReflectionProperty($propertyMetadata->class, $propertyMetadata->name)
new ReflectionProperty($propertyMetadata->class, $propertyMetadata->name),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ private function getPhpstanType(\ReflectionClass $declaringClass, string $typeHi
',',
array_map(static function (string $type) use ($reflector, $self) {
return $self->resolveType(trim($type), $reflector);
}, $types)
}, $types),
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/Driver/DoctrineTypeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function setDiscriminator(DoctrineClassMetadata $doctrineMetadata, Cla
) {
$classMetadata->setDiscriminator(
$doctrineMetadata->discriminatorColumn['name'],
$doctrineMetadata->discriminatorMap
$doctrineMetadata->discriminatorMap,
);
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/Metadata/Driver/TypedPropertiesDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ public function loadMetadataForClass(ReflectionClass $class): ?ClassMetadata

\assert($classMetadata instanceof SerializerClassMetadata);

if (PHP_VERSION_ID <= 70400) {
return $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 $propertyMetadata) {
Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $path):
$virtualPropertyMetadata = new ExpressionPropertyMetadata(
$name,
(string) $method->attributes()->name,
$this->parseExpression((string) $method->attributes()->expression)
$this->parseExpression((string) $method->attributes()->expression),
);
} else {
if (!isset($method->attributes()->method)) {
Expand Down Expand Up @@ -326,7 +326,7 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $path):
$pMetadata->setAccessor(
(string) ($pElem->attributes()->{'access-type'} ?: $classAccessType),
$getter ? (string) $getter : null,
$setter ? (string) $setter : null
$setter ? (string) $setter : null,
);

if (null !== $inline = $pElem->attributes()->inline) {
Expand Down
Loading
Loading