Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 68c45e2

Browse files
Handle constants declared with const
1 parent dcf8a63 commit 68c45e2

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
@@ -8218,6 +8218,13 @@ ZEND_VM_HANDLER(143, ZEND_DECLARE_CONST, CONST, CONST)
82188218
ZEND_CONSTANT_SET_FLAGS(&c, 0, PHP_USER_CONSTANT);
82198219
c.name = zend_string_copy(Z_STR_P(name));
82208220

8221+
zend_string *filename = zend_get_executed_filename_ex();
8222+
if (filename == NULL) {
8223+
c.filename = NULL;
8224+
} else {
8225+
c.filename = zend_string_copy(filename);
8226+
}
8227+
82218228
if (zend_register_constant(&c) == FAILURE) {
82228229
}
82238230

‎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)

AltStyle によって変換されたページ (->オリジナル) /