Skip to content

Commit

Permalink
Fix DocBlockTypeResolver crash on PHP 7.3 and less
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Feb 22, 2021
1 parent c5100ac commit 3676d37
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/Fixtures/ObjectWithPhpDocProperty.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace JMS\Serializer\Tests\Fixtures;

// phpcs:disable
final class ObjectWithPhpDocProperty
{
/**
*/
private $emptyBlock;

}
25 changes: 25 additions & 0 deletions tests/Metadata/Driver/DocBlockTypeResolverTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace JMS\Serializer\Tests\Metadata\Driver;

use JMS\Serializer\Metadata\Driver\DocBlockTypeResolver;
use JMS\Serializer\Tests\Fixtures\ObjectWithPhpDocProperty;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;

final class DocBlockTypeResolverTest extends TestCase
{
public function testGetPropertyDocblockTypeHintDoesNotCrash(): void
{
// It crashed on PHP 7.3 and less because of array_merge(...[])

$resolver = new DocBlockTypeResolver();
self::assertNull(
$resolver->getPropertyDocblockTypeHint(
new ReflectionProperty(ObjectWithPhpDocProperty::class, 'emptyBlock')
)
);
}
}

0 comments on commit 3676d37

Please sign in to comment.