Skip to content

Commit 6193b67

Browse files
Handle constants declared with const
1 parent b17a353 commit 6193b67

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

Zend/zend_vm_def.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8232,6 +8232,13 @@ ZEND_VM_HANDLER(143, ZEND_DECLARE_CONST, CONST, CONST)
82328232
ZEND_CONSTANT_SET_FLAGS(&c, 0, PHP_USER_CONSTANT);
82338233
c.name = zend_string_copy(Z_STR_P(name));
82348234

8235+
zend_string *filename = zend_get_executed_filename_ex();
8236+
if (filename == NULL) {
8237+
c.filename = NULL;
8238+
} else {
8239+
c.filename = zend_string_copy(filename);
8240+
}
8241+
82358242
if (zend_register_constant(&c) == FAILURE) {
82368243
}
82378244

Zend/zend_vm_execute.h

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/reflection/tests/ReflectionConstant_getFileName.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ define('IN_CURRENT_FILE', 42);
1212
$reflectionConstant = new ReflectionConstant('IN_CURRENT_FILE');
1313
var_dump($reflectionConstant->getFileName());
1414

15-
$reflectionConstant = new ReflectionConstant('INCLUDED_CONSTANT');
15+
$reflectionConstant = new ReflectionConstant('INCLUDED_CONSTANT_DEFINED');
16+
var_dump($reflectionConstant->getFileName());
17+
18+
$reflectionConstant = new ReflectionConstant('INCLUDED_CONSTANT_AST');
1619
var_dump($reflectionConstant->getFileName());
1720

1821
?>
1922
--EXPECTF--
2023
bool(false)
2124
string(%d) "%sReflectionConstant_getFileName.php"
2225
string(%d) "%sincluded5.inc"
26+
string(%d) "%sincluded5.inc"

ext/reflection/tests/included5.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<?php
2-
define('INCLUDED_CONSTANT', 'Foo');
2+
define('INCLUDED_CONSTANT_DEFINED', 'Foo');
3+
4+
const INCLUDED_CONSTANT_AST = 'Bar';
35
?>

0 commit comments

Comments
 (0)