klitsche/ffigen

View on GitHub
src/Adapter/PHPCParser/Compiler/FunctionDeclTranslator.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

declare(strict_types=1);

namespace Klitsche\FFIGen\Adapter\PHPCParser\Compiler;

use Klitsche\FFIGen\Types\Type;
use PHPCParser\Node\Decl\NamedDecl\ValueDecl\DeclaratorDecl\FunctionDecl;
use PHPCParser\NodeAbstract;

class FunctionDeclTranslator extends AbstractTranslator
{
    public function matches(NodeAbstract $node): bool
    {
        return $node instanceof FunctionDecl;
    }

    public function compile(NodeAbstract $node): Type
    {
        return $this->compiler->compile($node->type)->withDeclarationName($node->name);
    }
}