Skip to content

Explicit type declarations is not handled! #24

@Hubbitus

Description

@Hubbitus

Since PHP 7.4 type declarations were introduced.

But php-avro-schema-generator does not look in it.

Steps to reproduce:

// in ../DAO/DemoNotification.php
class DemoNotification {
    private string $content;

    public function __construct(string $content) {
        $this->content = $content;
    }

    public function getContent(): string {
        return $this->content;
    }
}

$data = new DemoNotification("Hello");
$registry = (new ClassRegistry())
    ->addClassDirectory(__DIR__ . '/../DAO')
    ->load();
$generator = new SchemaGenerator($registry, '');
$schemas = $generator->generate();
echo(current($schemas)); // Out: {"type":"record","name":"DemoNotification","namespace":"App.DAO","fields":[{"name":"content","type":""}]}

Actual behavior

Despite explicit type declaration:

private string $content;

Script outputs:

{"type":"record","name":"DemoNotification","namespace":"App.DAO","fields":[{"name":"content","type":""}]}

Expected behavior

{"type":"record","name":"DemoNotification","namespace":"App.DAO","fields":[{"name":"content","type":"string"}]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions