Skip to content

Commit 243f8e1

Browse files
committed
Add test for autoload during constant resolution.
1 parent 7d5a966 commit 243f8e1

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

Zend/tests/gh10232.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
Weird behaviour when a file is autoloaded in assignment of a constant
3+
--XFAIL--
4+
This issue is not fixed yet.
5+
--FILE--
6+
<?php
7+
8+
set_include_path('gh10232-nonexistent') or exit(1);
9+
chdir(__DIR__) or exit(1);
10+
11+
spl_autoload_register(function () {
12+
trigger_error(__LINE__);
13+
$ex = new Exception();
14+
echo 'Exception on line ', $ex->getLine(), "\n";
15+
require_once __DIR__ . '/gh10232/constant_def.inc';
16+
}, true);
17+
18+
19+
class ConstantRef
20+
{
21+
public const VALUE = ConstantDef::VALUE;
22+
}
23+
24+
ConstantRef::VALUE;
25+
26+
?>
27+
--EXPECTF--
28+
Notice: 7 in %sgh10232.php on line 7
29+
Exception on line 8
30+
31+
Notice: constant_def.inc in %sconstant_def.inc on line 3
32+
Exception in constant_def.inc on line 4
33+
34+
Notice: required.inc in %srequired.inc on line 3
35+
Exception in required.inc on line 4

Zend/tests/gh10232/constant_def.inc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
trigger_error(basename(__FILE__));
4+
$ex = new Exception();
5+
echo 'Exception in ', basename($ex->getFile()), ' on line ', $ex->getLine(), "\n";
6+
7+
require_once 'required.inc'; // The script of the same directory.
8+
9+
class ConstantDef
10+
{
11+
const VALUE = true;
12+
}

Zend/tests/gh10232/required.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
trigger_error(basename(__FILE__));
4+
$ex = new Exception();
5+
echo 'Exception in ', basename($ex->getFile()), ' on line ', $ex->getLine(), "\n";

0 commit comments

Comments
 (0)