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 b5ffac7

Browse files
Add ReflectionClassConstant::isDeprecated() (#14086)
This is in preparation for #11293 and for consistency with ReflectionConstant::isDeprecated() that was added in #13669.
1 parent d26617f commit b5ffac7

File tree

7 files changed

+55
-2
lines changed

7 files changed

+55
-2
lines changed

‎UPGRADING‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ PHP 8.4 UPGRADE NOTES
263263
. ReflectionClassConstant::__toString() and ReflectionProperty::__toString()
264264
now returns the attached doc comments.
265265
. ReflectionConstant was introduced.
266+
. ReflectionClassConstant::isDeprecated() was introduced.
266267

267268
- Standard:
268269
. stream_bucket_make_writeable() and stream_bucket_new() will now return a

‎ext/reflection/php_reflection.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4067,6 +4067,20 @@ ZEND_METHOD(ReflectionClassConstant, isEnumCase)
40674067
RETURN_BOOL(ZEND_CLASS_CONST_FLAGS(ref) & ZEND_CLASS_CONST_IS_CASE);
40684068
}
40694069

4070+
ZEND_METHOD(ReflectionClassConstant, isDeprecated)
4071+
{
4072+
reflection_object *intern;
4073+
zend_constant *ref;
4074+
4075+
if (zend_parse_parameters_none() == FAILURE) {
4076+
RETURN_THROWS();
4077+
}
4078+
4079+
GET_REFLECTION_OBJECT_PTR(ref);
4080+
4081+
RETURN_BOOL(ZEND_CLASS_CONST_FLAGS(ref) & ZEND_ACC_DEPRECATED);
4082+
}
4083+
40704084
/* {{{ reflection_class_object_ctor */
40714085
static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_object)
40724086
{

‎ext/reflection/php_reflection.stub.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,8 @@ public function getAttributes(?string $name = null, int $flags = 0): array {}
554554

555555
public function isEnumCase(): bool {}
556556

557+
public function isDeprecated(): bool {}
558+
557559
public function hasType(): bool {}
558560

559561
public function getType(): ?ReflectionType {}

‎ext/reflection/php_reflection_arginfo.h‎

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ext/zend_test/test.stub.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class _ZendTestClass implements _ZendTestInterface {
3838
*/
3939
public const int|string TYPED_CLASS_CONST3 = UNKNOWN;
4040

41+
/**
42+
* @deprecated
43+
*/
44+
public const int ZEND_TEST_DEPRECATED = 42;
45+
4146
/** @var mixed */
4247
public static $_StaticProp;
4348
public static int $staticIntProp = 123;

‎ext/zend_test/test_arginfo.h‎

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
ReflectionClassConstant::isDeprecated()
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
8+
$r = new ReflectionClassConstant('_ZendTestClass', 'ZEND_TEST_DEPRECATED');
9+
var_dump($r->isDeprecated());
10+
11+
$r = new ReflectionClassConstant('_ZendTestClass', 'TYPED_CLASS_CONST2');
12+
var_dump($r->isDeprecated());
13+
14+
?>
15+
--EXPECTF--
16+
bool(true)
17+
bool(false)

0 commit comments

Comments
(0)

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