Skip to content

Commit b6cf5d3

Browse files
committed
add tests for autoloading
1 parent 33c01ca commit b6cf5d3

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Zend/zend_compile.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9205,9 +9205,6 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
92059205
// if a class is private or protected, we need to require the correct scope
92069206
ce->required_scope = propFlags & (ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED) ? CG(active_class_entry) : NULL;
92079207
ce->required_scope_absolute = propFlags & ZEND_ACC_PRIVATE ? true : false;
9208-
if (ce->required_scope) {
9209-
ce->required_scope->refcount ++;
9210-
}
92119208

92129209
// ensure the class is treated as a top-level class and not an anon class
92139210
toplevel = true;

tests/classes/inner_classes.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
class inner_classes {
4+
public class Point {
5+
public function __construct(public int $x, public int $y) {}
6+
}
7+
8+
private class Line {}
9+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
ensure private autoloading works
3+
--FILE--
4+
<?php
5+
spl_autoload_register(static function ($class_name) {
6+
require_once(__DIR__ . '/' . $class_name . '.inc');
7+
echo 'autoload(' . $class_name . ")\n";
8+
});
9+
10+
$line = new inner_classes:>Line();
11+
var_dump($line);
12+
?>
13+
--EXPECTF--
14+
autoload(inner_classes)
15+
16+
Fatal error: Class 'inner_classes:>Line' is private in %s on line %d

0 commit comments

Comments
 (0)