Skip to content

Commit 8b5f894

Browse files
committed
#17725 optimize getting proto_type full mask in zend_is_class_subtype_of_type
1 parent 9369f53 commit 8b5f894

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Zend/zend_inheritance.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,10 @@ static inheritance_status zend_is_class_subtype_of_type(
477477
zend_class_entry *fe_ce = NULL;
478478
bool have_unresolved = 0;
479479

480+
uint32_t proto_type_full_mask = ZEND_TYPE_FULL_MASK(proto_type);
481+
480482
/* If the parent has 'object' as a return type, any class satisfies the co-variant check */
481-
if (ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_OBJECT) {
483+
if (proto_type_full_mask & MAY_BE_OBJECT) {
482484
/* Currently, any class name would be allowed here. We still perform a class lookup
483485
* for forward-compatibility reasons, as we may have named types in the future that
484486
* are not classes (such as typedefs). */
@@ -492,7 +494,7 @@ static inheritance_status zend_is_class_subtype_of_type(
492494
}
493495

494496
/* If the parent has 'callable' as a return type, then Closure satisfies the co-variant check */
495-
if (ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_CALLABLE) {
497+
if (proto_type_full_mask & MAY_BE_CALLABLE) {
496498
if (!fe_ce) fe_ce = lookup_class(fe_scope, fe_class_name);
497499
if (!fe_ce) {
498500
have_unresolved = 1;
@@ -573,7 +575,7 @@ static inheritance_status zend_is_class_subtype_of_type(
573575

574576
// replacing static with self in final classes is okay
575577
if (!is_intersection && fe_scope->ce_flags & ZEND_ACC_FINAL &&
576-
ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_STATIC && instanceof_function(fe_scope, proto_scope)) {
578+
proto_type_full_mask & MAY_BE_STATIC && instanceof_function(fe_scope, proto_scope)) {
577579
if (!fe_ce) fe_ce = lookup_class(fe_scope, fe_class_name);
578580

579581
if (fe_ce && instanceof_function(fe_ce, fe_scope)) {

0 commit comments

Comments
 (0)