Skip to content

Commit ce49812

Browse files
committed
Add support for #[\Deprecated] to stubs
1 parent 2be5d73 commit ce49812

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

build/gen_stub.php

+7
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,13 @@ private function getArginfoFlagsByPhpVersions(): array
15791579
$flags[] = "ZEND_ACC_DEPRECATED";
15801580
}
15811581

1582+
foreach ($this->attributes as $attr) {
1583+
if ($attr->class === "Deprecated") {
1584+
$flags[] = "ZEND_ACC_DEPRECATED";
1585+
break;
1586+
}
1587+
}
1588+
15821589
$php82AndAboveFlags = $flags;
15831590
if ($this->isMethod() === false && $this->supportsCompileTimeEval) {
15841591
$php82AndAboveFlags[] = "ZEND_ACC_COMPILE_TIME_EVAL";

ext/zend_test/test.c

+5
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ static ZEND_FUNCTION(zend_test_deprecated)
121121
zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &arg1);
122122
}
123123

124+
static ZEND_FUNCTION(zend_test_deprecated_attr)
125+
{
126+
ZEND_PARSE_PARAMETERS_NONE();
127+
}
128+
124129
/* Create a string without terminating null byte. Must be terminated with
125130
* zend_terminate_string() before destruction, otherwise a warning is issued
126131
* in debug builds. */

ext/zend_test/test.stub.php

+3
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ function zend_test_compile_string(string $source_string, string $filename, int $
194194
/** @deprecated */
195195
function zend_test_deprecated(mixed $arg = null): void {}
196196

197+
#[\Deprecated]
198+
function zend_test_deprecated_attr(): void {}
199+
197200
/** @alias zend_test_void_return */
198201
function zend_test_aliased(): void {}
199202

ext/zend_test/test_arginfo.h

+13-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
#[\Deprecated]: Works in stubs.
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
zend_test_deprecated();
8+
zend_test_deprecated_attr();
9+
?>
10+
--EXPECTF--
11+
Deprecated: Function zend_test_deprecated() is deprecated in %s on line %d
12+
13+
Deprecated: Function zend_test_deprecated_attr() is deprecated in %s on line %d

0 commit comments

Comments
 (0)