Skip to content

Commit d38f6fe

Browse files
committed
Update to support symfony/serializer 8.x, remove proxy references.
1 parent 4f494fa commit d38f6fe

File tree

2 files changed

+51
-53
lines changed

2 files changed

+51
-53
lines changed

composer.json

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
{
2-
"name": "azuracast/doctrine-entity-normalizer",
3-
"description": "An implementation of the Symfony Serializer with custom support for Doctrine 3 ORM entities.",
4-
"type": "library",
5-
"license": "Apache-2.0",
6-
"authors": [
7-
{
8-
"name": "Buster Neece",
9-
"email": "[email protected]",
10-
"homepage": "https://busterneece.com/"
11-
}
2+
"name": "azuracast/doctrine-entity-normalizer",
3+
"description": "An implementation of the Symfony Serializer with custom support for Doctrine 3 ORM entities.",
4+
"type": "library",
5+
"license": "Apache-2.0",
6+
"authors": [
7+
{
8+
"name": "Buster Neece",
9+
"email": "[email protected]",
10+
"homepage": "https://busterneece.com/"
11+
}
12+
],
13+
"scripts": {
14+
"test": [
15+
"@composer install --prefer-dist --no-progress",
16+
"@phplint",
17+
"@phpstan"
1218
],
13-
"scripts": {
14-
"test": [
15-
"@composer install --prefer-dist --no-progress",
16-
"@phplint",
17-
"@phpstan"
18-
],
19-
"phplint": "parallel-lint . --exclude vendor",
20-
"phpstan": "phpstan analyze"
21-
},
22-
"autoload": {
23-
"psr-4": {
24-
"Azura\\Normalizer\\": "src"
25-
}
26-
},
27-
"require": {
28-
"php": ">=8.4",
29-
"doctrine/collections": ">1",
30-
"doctrine/inflector": "^2",
31-
"doctrine/orm": "^3",
32-
"doctrine/persistence": "^2|^3",
33-
"symfony/property-info": "^7",
34-
"symfony/serializer": "^7"
35-
},
36-
"require-dev": {
37-
"php-parallel-lint/php-console-highlighter": "^1",
38-
"php-parallel-lint/php-parallel-lint": "^1.3",
39-
"phpstan/phpstan": "^2",
40-
"roave/security-advisories": "dev-master"
41-
},
42-
"config": {
43-
"preferred-install": "dist",
44-
"discard-changes": true,
45-
"sort-packages": true
19+
"phplint": "parallel-lint . --exclude vendor",
20+
"phpstan": "phpstan analyze"
21+
},
22+
"autoload": {
23+
"psr-4": {
24+
"Azura\\Normalizer\\": "src"
4625
}
26+
},
27+
"require": {
28+
"php": ">=8.4",
29+
"doctrine/collections": ">1",
30+
"doctrine/inflector": "^2",
31+
"doctrine/orm": "^3",
32+
"doctrine/persistence": "^2|^3",
33+
"symfony/property-info": "^7",
34+
"symfony/serializer": "^8"
35+
},
36+
"require-dev": {
37+
"php-parallel-lint/php-console-highlighter": "^1",
38+
"php-parallel-lint/php-parallel-lint": "^1.3",
39+
"phpstan/phpstan": "^2",
40+
"roave/security-advisories": "dev-master"
41+
},
42+
"config": {
43+
"preferred-install": "dist",
44+
"discard-changes": true,
45+
"sort-packages": true
46+
}
4747
}

src/DoctrineEntityNormalizer.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Azura\Normalizer\TypeExtractor\EntityTypeExtractor;
99
use Doctrine\Common\Collections\Collection;
1010
use Doctrine\ORM\EntityManagerInterface;
11-
use Doctrine\ORM\Proxy\DefaultProxyClassNameResolver;
1211
use InvalidArgumentException;
1312
use ReflectionClass;
1413
use ReflectionException;
@@ -20,10 +19,10 @@
2019

2120
final class DoctrineEntityNormalizer extends AbstractObjectNormalizer
2221
{
23-
public const CLASS_METADATA = 'class_metadata';
24-
public const ASSOCIATION_MAPPINGS = 'association_mappings';
22+
public const string CLASS_METADATA = 'class_metadata';
23+
public const string ASSOCIATION_MAPPINGS = 'association_mappings';
2524

26-
public const NORMALIZE_TO_IDENTIFIERS = 'form_mode';
25+
public const string NORMALIZE_TO_IDENTIFIERS = 'form_mode';
2726

2827
private EntityTypeExtractor $typeExtractor;
2928

@@ -150,7 +149,7 @@ public function supportsDenormalization(mixed $data, string $type, ?string $form
150149
* @return string[]|AttributeMetadataInterface[]|bool
151150
*/
152151
protected function getAllowedAttributes(
153-
$classOrObject,
152+
string|object $classOrObject,
154153
array $context,
155154
bool $attributesAsString = false
156155
): array|bool {
@@ -186,7 +185,6 @@ protected function extractAttributes(object $object, ?string $format = null, arr
186185
* @param string|null $format
187186
* @param array $context
188187
* @return bool
189-
* @throws ReflectionException
190188
*/
191189
protected function isAllowedAttribute(
192190
object|string $classOrObject,
@@ -290,7 +288,7 @@ private function supportsDeepNormalization(ReflectionClass $reflClass, string $a
290288
/** @var DeepNormalize $deepNormalize */
291289
$deepNormalize = current($deepNormalizeAttrs)->newInstance();
292290
return $deepNormalize->getDeepNormalize();
293-
} catch (\ReflectionException) {
291+
} catch (ReflectionException) {
294292
return false;
295293
}
296294
}
@@ -308,7 +306,7 @@ private function getProperty(
308306
string $key
309307
): mixed {
310308
if (null !== $accessor = $this->typeExtractor->getAccessorMethod($reflClass, $key)) {
311-
[$method, $prefix] = $accessor;
309+
[$method,] = $accessor;
312310
return $method->invoke($entity);
313311
}
314312

@@ -389,7 +387,7 @@ private function setProperty(
389387
): void {
390388
// Prefer setter if it exists.
391389
if (null !== $mutator = $this->typeExtractor->getMutatorMethod($reflClass, $key)) {
392-
[$method, $prefix] = $mutator;
390+
[$method,] = $mutator;
393391
$method->invoke($entity, $value);
394392
return;
395393
}
@@ -406,7 +404,7 @@ private function setProperty(
406404
private function isEntity(mixed $class): bool
407405
{
408406
if (is_object($class)) {
409-
$class = DefaultProxyClassNameResolver::getClass($class);
407+
$class = $class::class;
410408
}
411409

412410
if (!is_string($class) || !class_exists($class)) {

0 commit comments

Comments
 (0)