Skip to content

Commit e0af7c3

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix delayed early binding class redeclaration error
2 parents 730f32b + e349913 commit e0af7c3

4 files changed

+20
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
class Bar extends Foo {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
class Bar extends Foo {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Delayed early binding throws class redeclaration error
3+
--EXTENSIONS--
4+
opcache
5+
--FILE--
6+
<?php
7+
class Foo {}
8+
include __DIR__ . '/delayed_early_binding_redeclaration-1.inc';
9+
include __DIR__ . '/delayed_early_binding_redeclaration-2.inc';
10+
var_dump(class_exists(Bar::class));
11+
?>
12+
--EXPECTF--
13+
Fatal error: Cannot declare class Bar, because the name is already in use in %sdelayed_early_binding_redeclaration-2.inc on line %d

ext/opcache/zend_accelerator_util_funcs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ static void zend_accel_do_delayed_early_binding(
363363
ce = zend_try_early_bind(orig_ce, parent_ce, early_binding->lcname, zv);
364364
}
365365
}
366-
}
367-
if (ce && early_binding->cache_slot != (uint32_t) -1) {
368-
*(void**)((char*)run_time_cache + early_binding->cache_slot) = ce;
366+
if (ce && early_binding->cache_slot != (uint32_t) -1) {
367+
*(void**)((char*)run_time_cache + early_binding->cache_slot) = ce;
368+
}
369369
}
370370
}
371371
CG(compiled_filename) = orig_compiled_filename;

0 commit comments

Comments
 (0)