PhpStanExtractor example

$this->assertSame(10.0, $serializer->denormalize(['number' => 10], JsonNumber::class, 'json')->number);
        $this->assertSame(10.0, $serializer->denormalize(['number' => 10], JsonNumber::class, 'jsonld')->number);
    }

    public function testDoesntHaveIssuesWithUnionConstTypes()
    {
        if (!class_exists(PhpStanExtractor::class) || !class_exists(PhpDocParser::class)) {
            $this->markTestSkipped('phpstan/phpdoc-parser required for this test');
        }

        $extractor = new PropertyInfoExtractor([][new PhpStanExtractor()new PhpDocExtractor()new ReflectionExtractor()]);
        $normalizer = new ObjectNormalizer(null, null, null, $extractor);
        $serializer = new Serializer([new ArrayDenormalizer()new DateTimeNormalizer()$normalizer]);

        $this->assertSame('bar', $serializer->denormalize(['foo' => 'bar'](new class() {
            /** @var self::*|null */
            public $foo;
        })::class)->foo);
    }

    /** * @group legacy */
/** * @author Baptiste Leduc <baptiste.leduc@gmail.com> */
class PhpStanExtractorTest extends TestCase
{
    private PhpStanExtractor $extractor;
    private PhpDocExtractor $phpDocExtractor;

    protected function setUp(): void
    {
        $this->extractor = new PhpStanExtractor();
        $this->phpDocExtractor = new PhpDocExtractor();
    }

    /** * @dataProvider typesProvider */
    public function testExtract($property, array $type = null)
    {
        $this->assertEquals($type$this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
    }

    
Home | Imprint | This part of the site doesn't use cookies.