diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 5c58c343..051a14d2 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -174,7 +174,7 @@ class CompilerBase extends \PhpAot\Core\Translator protected int $floatPrecision = 17; protected bool $debug = false; protected bool $formatCode = true; - protected bool $printBacktraceOnError = false; + protected bool $printBacktraceOnError = true; protected bool $noLiteralStrings = false; protected bool $noConsole = false; // Windows: hide console window protected string $sanitize = ''; // Sanitizer type (address, undefined, etc.) @@ -1800,9 +1800,9 @@ class CompilerBase extends \PhpAot\Core\Translator } elseif (!$this->isInheritedFrom($objectClass, $returnClass)) { $this->fatalError($v, 'The return type is `' . $returnClass . '`, cannot return an instance of `' . $objectClass . '`'); } - // 把子类当做父类返回时,父类必须是抽象类 - if ($objectClass and $objectClass !== $returnClass and !$this->isAbstractClass($returnClass)) { - $this->fatalError($v, "When returning a subclass `$objectClass` instance as parent type, the parent class `$returnClass` must be abstract"); + // 把子类当做父类返回时,父类必须是抽象类或者接口 + if ($objectClass and $objectClass !== $returnClass and !$this->isAbstractClass($returnClass) and !$this->hasInterface($returnClass)) { + $this->fatalError($v, "When returning a subclass `$objectClass` instance as parent type, the parent class `$returnClass` must be abstract/interface"); } } diff --git a/src/gen_stub.php b/src/gen_stub.php index 4c437546..4eb70b78 100755 --- a/src/gen_stub.php +++ b/src/gen_stub.php @@ -218,7 +218,8 @@ class SimpleType { public /* readonly */ string $name; public /* readonly */ bool $isBuiltin; - public static function fromNode(Node $node): SimpleType { + public static function fromNode(Node $node): SimpleType|ArrayType + { if ($node instanceof Node\Name) { if ($node->toLowerString() === 'static') { // PHP internally considers "static" a builtin type. @@ -244,7 +245,7 @@ class SimpleType { throw new Exception("Unexpected node type"); } - public static function fromString(string $typeString): SimpleType + public static function fromString(string $typeString): SimpleType|ArrayType { switch (strtolower($typeString)) { case "void": diff --git a/tests/aot/ref-call-arg.phpt b/tests/aot/ref-call-arg.phpt index 8aa044b5..e1b7f65a 100644 --- a/tests/aot/ref-call-arg.phpt +++ b/tests/aot/ref-call-arg.phpt @@ -5,7 +5,8 @@ ref call arg function main() { $zip = new ZipArchive(); - if ($zip->open(__DIR__ . '/../../examples/test.zip') === TRUE) { + $path = realpath(__DIR__ . '/../../../data/test.zip'); + if ($zip->open($path) === TRUE) { for ($idx = 0; $s = $zip->statIndex($idx); $idx++) { $rs = $zip->getExternalAttributesIndex($idx, $opsys, $attr); var_dump($rs, $idx, $opsys, $attr); @@ -35,8 +36,12 @@ bool(true) int(2) int(3) int(2176057344) +bool(true) +int(3) +int(3) +int(2176057344) OK value foo bar baz -DONE +DONE \ No newline at end of file