Skip to content

Add ReflectionClassConstant::isDeprecated() #14086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ PHP 8.4 UPGRADE NOTES
. ReflectionClassConstant::__toString() and ReflectionProperty::__toString()
now returns the attached doc comments.
. ReflectionConstant was introduced.
. ReflectionClassConstant::isDeprecated() was introduced.

- Standard:
. stream_bucket_make_writeable() and stream_bucket_new() will now return a
Expand Down
14 changes: 14 additions & 0 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -4067,6 +4067,20 @@ ZEND_METHOD(ReflectionClassConstant, isEnumCase)
RETURN_BOOL(ZEND_CLASS_CONST_FLAGS(ref) & ZEND_CLASS_CONST_IS_CASE);
}

ZEND_METHOD(ReflectionClassConstant, isDeprecated)
{
reflection_object *intern;
zend_constant *ref;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}

GET_REFLECTION_OBJECT_PTR(ref);

RETURN_BOOL(ZEND_CLASS_CONST_FLAGS(ref) & ZEND_ACC_DEPRECATED);
}

/* {{{ reflection_class_object_ctor */
static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_object)
{
Expand Down
2 changes: 2 additions & 0 deletions ext/reflection/php_reflection.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ public function getAttributes(?string $name = null, int $flags = 0): array {}

public function isEnumCase(): bool {}

public function isDeprecated(): bool {}

public function hasType(): bool {}

public function getType(): ?ReflectionType {}
Expand Down
6 changes: 5 additions & 1 deletion ext/reflection/php_reflection_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ext/zend_test/test.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class _ZendTestClass implements _ZendTestInterface {
*/
public const int|string TYPED_CLASS_CONST3 = UNKNOWN;

/**
* @deprecated
*/
public const int ZEND_TEST_DEPRECATED = 42;

/** @var mixed */
public static $_StaticProp;
public static int $staticIntProp = 123;
Expand Down
12 changes: 11 additions & 1 deletion ext/zend_test/test_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions ext/zend_test/tests/class_constant_deprecated.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
ReflectionClassConstant::isDeprecated()
--EXTENSIONS--
zend_test
--FILE--
<?php

$r = new ReflectionClassConstant('_ZendTestClass', 'ZEND_TEST_DEPRECATED');
var_dump($r->isDeprecated());

$r = new ReflectionClassConstant('_ZendTestClass', 'TYPED_CLASS_CONST2');
var_dump($r->isDeprecated());

?>
--EXPECTF--
bool(true)
bool(false)
Loading