mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.0'
* PHP-8.0: Don't autoload classes during covariant type check against mixed
This commit is contained in:
commit
f71bfe4544
2 changed files with 27 additions and 0 deletions
20
Zend/tests/type_declarations/variance/mixed_return_type.phpt
Normal file
20
Zend/tests/type_declarations/variance/mixed_return_type.phpt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
--TEST--
|
||||||
|
Everything is trivially a subtype of mixed
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
spl_autoload_register(function($class) {
|
||||||
|
echo "Loading $class\n";
|
||||||
|
});
|
||||||
|
|
||||||
|
class A {
|
||||||
|
public function test(): mixed {}
|
||||||
|
}
|
||||||
|
class B extends A {
|
||||||
|
public function test(): X {}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
===DONE===
|
|
@ -436,6 +436,13 @@ static inheritance_status zend_perform_covariant_type_check(
|
||||||
{
|
{
|
||||||
ZEND_ASSERT(ZEND_TYPE_IS_SET(fe_type) && ZEND_TYPE_IS_SET(proto_type));
|
ZEND_ASSERT(ZEND_TYPE_IS_SET(fe_type) && ZEND_TYPE_IS_SET(proto_type));
|
||||||
|
|
||||||
|
/* Apart from void, everything is trivially covariant to the mixed type.
|
||||||
|
* Handle this case separately to ensure it never requires class loading. */
|
||||||
|
if (ZEND_TYPE_PURE_MASK(proto_type) == MAY_BE_ANY &&
|
||||||
|
!ZEND_TYPE_CONTAINS_CODE(fe_type, IS_VOID)) {
|
||||||
|
return INHERITANCE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/* Builtin types may be removed, but not added */
|
/* Builtin types may be removed, but not added */
|
||||||
uint32_t fe_type_mask = ZEND_TYPE_PURE_MASK(fe_type);
|
uint32_t fe_type_mask = ZEND_TYPE_PURE_MASK(fe_type);
|
||||||
uint32_t proto_type_mask = ZEND_TYPE_PURE_MASK(proto_type);
|
uint32_t proto_type_mask = ZEND_TYPE_PURE_MASK(proto_type);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue