zephir-lang / zephir

Zephir is a compiled high-level language aimed to ease the creation of C-extensions for PHP
https://zephir-lang.com
MIT License
3.3k stars 466 forks source link

'void' return type hint is ignored #1908

Closed JellyBrick closed 5 years ago

JellyBrick commented 5 years ago

Log

Fatal error: Declaration of Pocketmine\Utils\BinaryStream::setOffset(int $offset) must be compatible with pocketmine\network\mcpe\protocol\Packet::setOffset(int $offset): void in /develop/pocketmine/src/network/mcpe/protocol/DataPacket.php on line 38

Code

interface Packet{
        public function setOffset(int $offset) : void
        //...
}

Packet.php

abstract class DataPacket extends BinaryStream implements Packet{
     //....
}

DataPacket.php

    public function setOffset(int offset) -> void
    {
        let this->offset = offset;
    }

binarystream.zep

However, the generated code has no type hints. (Stubs included)

    /**
     * @param int $offset
     */
    public function setOffset(int $offset) {}

binarystream.zep stub

Jurigag commented 5 years ago

I'm guessing stubs generations wasn't made when 7.1 was released, that's why we ignore void. I guess someone would need to update it and add check for php 7.1

JellyBrick commented 5 years ago

@Jurigag #1910