Skip to content

Commit a707f87

Browse files
committed
Implement feedback
1 parent 30800c6 commit a707f87

7 files changed

+59
-1
lines changed

ext/reflection/php_reflection.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7229,6 +7229,8 @@ ZEND_METHOD(ReflectionConstant, __construct)
72297229

72307230
intern->ptr = const_;
72317231
intern->ref_type = REF_TYPE_OTHER;
7232+
7233+
ZVAL_STR_COPY(reflection_prop_name(object), const_name);
72327234
}
72337235

72347236
ZEND_METHOD(ReflectionConstant, getName)

ext/reflection/php_reflection.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,8 @@ public function getTrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT): array {
836836
*/
837837
final class ReflectionConstant
838838
{
839+
public string $name;
840+
839841
public function __construct(string $name) {}
840842

841843
public function getName(): string {}

ext/reflection/php_reflection_arginfo.h

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
var_dump(ReflectionConstant)
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
8+
define('RT_CONST', 42);
9+
const CT_CONST = 43;
10+
11+
var_dump(new ReflectionConstant('ZEND_CONSTANT_A'));
12+
var_dump(new ReflectionConstant('ZEND_TEST_DEPRECATED'));
13+
var_dump(new ReflectionConstant('RT_CONST'));
14+
var_dump(new ReflectionConstant('CT_CONST'));
15+
16+
?>
17+
--EXPECT--
18+
object(ReflectionConstant)#1 (1) {
19+
["name"]=>
20+
string(15) "ZEND_CONSTANT_A"
21+
}
22+
object(ReflectionConstant)#1 (1) {
23+
["name"]=>
24+
string(20) "ZEND_TEST_DEPRECATED"
25+
}
26+
object(ReflectionConstant)#1 (1) {
27+
["name"]=>
28+
string(8) "RT_CONST"
29+
}
30+
object(ReflectionConstant)#1 (1) {
31+
["name"]=>
32+
string(8) "CT_CONST"
33+
}

ext/reflection/tests/ReflectionConstant_getName.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ define('RT_CONST', 42);
1515
$reflectionConstant = new ReflectionConstant('RT_CONST');
1616
var_dump($reflectionConstant->getName());
1717

18+
define('CT_CONST', 43);
19+
$reflectionConstant = new ReflectionConstant('CT_CONST');
20+
var_dump($reflectionConstant->getName());
21+
1822
?>
1923
--EXPECT--
2024
string(15) "ZEND_CONSTANT_A"
2125
string(20) "ZEND_TEST_DEPRECATED"
2226
string(8) "RT_CONST"
27+
string(8) "CT_CONST"

ext/reflection/tests/ReflectionConstant_getValue.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ define('RT_CONST', 42);
1515
$reflectionConstant = new ReflectionConstant('RT_CONST');
1616
var_dump($reflectionConstant->getValue());
1717

18+
define('CT_CONST', 43);
19+
$reflectionConstant = new ReflectionConstant('CT_CONST');
20+
var_dump($reflectionConstant->getValue());
21+
1822
?>
1923
--EXPECT--
2024
string(6) "global"
2125
int(42)
2226
int(42)
27+
int(43)

ext/reflection/tests/ReflectionConstant_isDeprecated.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ define('RT_CONST', 42);
1515
$reflectionConstant = new ReflectionConstant('RT_CONST');
1616
var_dump($reflectionConstant->isDeprecated());
1717

18+
const CT_CONST = 43;
19+
$reflectionConstant = new ReflectionConstant('CT_CONST');
20+
var_dump($reflectionConstant->isDeprecated());
21+
1822
?>
1923
--EXPECT--
2024
bool(false)
2125
bool(true)
2226
bool(false)
27+
bool(false)

0 commit comments

Comments
 (0)