Skip to content

Commit a5e4547

Browse files
Fixes from tests
1 parent a9c2500 commit a5e4547

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Zend/Optimizer/zend_optimizer.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "zend_call_graph.h"
3131
#include "zend_inference.h"
3232
#include "zend_dump.h"
33+
#include "zend_class_alias.h"
3334
#include "php.h"
3435

3536
#ifndef ZEND_OPTIMIZER_MAX_REGISTERED_PASSES
@@ -773,7 +774,8 @@ void zend_optimizer_shift_jump(zend_op_array *op_array, zend_op *opline, uint32_
773774

774775
static bool zend_optimizer_ignore_class(zval *ce_zv, zend_string *filename)
775776
{
776-
zend_class_entry *ce = Z_PTR_P(ce_zv);
777+
zend_class_entry *ce;
778+
Z_CE_FROM_ZVAL_P(ce, ce_zv);
777779

778780
if (ce->ce_flags & ZEND_ACC_PRELOADED) {
779781
Bucket *ce_bucket = (Bucket*)((uintptr_t)ce_zv - XtOffsetOf(Bucket, val));
@@ -809,14 +811,22 @@ static bool zend_optimizer_ignore_function(zval *fbc_zv, zend_string *filename)
809811

810812
zend_class_entry *zend_optimizer_get_class_entry(
811813
const zend_script *script, const zend_op_array *op_array, zend_string *lcname) {
812-
zend_class_entry *ce = script ? zend_hash_find_ptr(&script->class_table, lcname) : NULL;
813-
if (ce) {
814-
return ce;
814+
zval *ce_or_alias = script ? zend_hash_find(&script->class_table, lcname) : NULL;
815+
if (ce_or_alias) {
816+
if (EXPECTED(Z_TYPE_P(ce_or_alias) == IS_PTR)) {
817+
return Z_PTR_P(ce_or_alias);
818+
}
819+
ZEND_ASSERT(Z_TYPE_P(ce_or_alias) == IS_ALIAS_PTR);
820+
return Z_CLASS_ALIAS_P(ce_or_alias)->ce;
815821
}
816822

817823
zval *ce_zv = zend_hash_find(CG(class_table), lcname);
818824
if (ce_zv && !zend_optimizer_ignore_class(ce_zv, op_array ? op_array->filename : NULL)) {
819-
return Z_PTR_P(ce_zv);
825+
if (EXPECTED(Z_TYPE_P(ce_zv) == IS_PTR)) {
826+
return Z_PTR_P(ce_zv);
827+
}
828+
ZEND_ASSERT(Z_TYPE_P(ce_zv) == IS_ALIAS_PTR);
829+
return Z_CLASS_ALIAS_P(ce_zv)->ce;
820830
}
821831

822832
if (op_array && op_array->scope && zend_string_equals_ci(op_array->scope->name, lcname)) {

ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ $ext = new ReflectionExtension('reflection');
88
var_dump($ext->getClasses());
99
?>
1010
--EXPECTF--
11-
array(26) {
11+
array(27) {
1212
["ReflectionException"]=>
1313
object(ReflectionClass)#%d (1) {
1414
["name"]=>
@@ -139,4 +139,9 @@ array(26) {
139139
["name"]=>
140140
string(16) "PropertyHookType"
141141
}
142+
["ReflectionClassAlias"]=>
143+
object(ReflectionClass)#%d (1) {
144+
["name"]=>
145+
string(20) "ReflectionClassAlias"
146+
}
142147
}

0 commit comments

Comments
 (0)