Skip to content

Commit

Permalink
fix: allow building serializer if annotation reader class does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto committed Mar 6, 2024
1 parent 4aaf340 commit 6bed6cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
php_version:
- '8.1'
- '8.2'
- '8.3'

name: PHP ${{ matrix.php_version }}
steps:
Expand Down
7 changes: 4 additions & 3 deletions src/SerializerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,11 @@ public function build(): SerializerInterface
{
$metadataLoader = $this->metadataLoader;
if ($metadataLoader === null) {
$annotationReader = $this->annotationReader ?: new AnnotationReader();
if (class_exists(AnnotationReader::class)) {
$metadataLoader = new AnnotationLoader();
$metadataLoader->setReader($this->annotationReader ?? new AnnotationReader());
}

$metadataLoader = new AnnotationLoader();
$metadataLoader->setReader($annotationReader);
$metadataLoader = new AttributesLoader($metadataLoader);
}

Expand Down

0 comments on commit 6bed6cc

Please sign in to comment.