mirror of
https://github.com/php/php-src.git
synced 2026-04-27 18:23:26 +02:00
Merge commit 'refs/pull/1066/head' of git://github.com/php/php-src
* git://github.com/php/php-src: Add zend assert deleted by accident Let's keep it simple Improve internal function return types checking for parent
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
Return type of parent is not allowed in function
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function test(): parent {}
|
||||
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot declare a return type of parent outside of a class scope in %s on line 3
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
Return type of parent is not allowed in closure
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$c = function(): parent {};
|
||||
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot declare a return type of parent outside of a class scope in %s on line 3
|
||||
+2
-2
@@ -2007,8 +2007,8 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
|
||||
if (info->type_hint) {
|
||||
if (info->class_name) {
|
||||
ZEND_ASSERT(info->type_hint == IS_OBJECT);
|
||||
if (!strcasecmp(info->class_name, "self") && !scope) {
|
||||
zend_error(E_CORE_ERROR, "Cannot declare a return type of self outside of a class scope");
|
||||
if (!scope && (!strcasecmp(info->class_name, "self") || !strcasecmp(info->class_name, "parent"))) {
|
||||
zend_error(E_CORE_ERROR, "Cannot declare a return type of %s outside of a class scope", info->class_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user