@@ -1176,6 +1176,7 @@ class FuncInfo {
11761176 /** @var FramelessFunctionInfo[] */
11771177 private array $ framelessFunctionInfos ;
11781178 private ?ExposedDocComment $ exposedDocComment ;
1179+ private bool $ isMutating ;
11791180
11801181 /**
11811182 * @param ArgInfo[] $args
@@ -1199,7 +1200,8 @@ public function __construct(
11991200 ?int $ minimumPhpVersionIdCompatibility ,
12001201 array $ attributes ,
12011202 array $ framelessFunctionInfos ,
1202- ?ExposedDocComment $ exposedDocComment
1203+ ?ExposedDocComment $ exposedDocComment ,
1204+ bool $ isMutating ,
12031205 ) {
12041206 $ this ->name = $ name ;
12051207 $ this ->classFlags = $ classFlags ;
@@ -1218,6 +1220,7 @@ public function __construct(
12181220 $ this ->attributes = $ attributes ;
12191221 $ this ->framelessFunctionInfos = $ framelessFunctionInfos ;
12201222 $ this ->exposedDocComment = $ exposedDocComment ;
1223+ $ this ->isMutating = $ isMutating ;
12211224 if ($ return ->tentativeReturnType && $ this ->isFinalMethod ()) {
12221225 throw new Exception ("Tentative return inapplicable for final method " );
12231226 }
@@ -1518,6 +1521,10 @@ private function getArginfoFlagsByPhpVersions(): array
15181521 $ flags [] = "ZEND_ACC_DEPRECATED " ;
15191522 }
15201523
1524+ if ($ this ->isMutating ) {
1525+ $ flags [] = "ZEND_ACC_MUTATING " ;
1526+ }
1527+
15211528 foreach ($ this ->attributes as $ attr ) {
15221529 switch ($ attr ->class ) {
15231530 case "Deprecated " :
@@ -4344,6 +4351,7 @@ function parseFunctionLike(
43444351 $docParamTypes = [];
43454352 $refcount = null;
43464353 $framelessFunctionInfos = [];
4354+ $isMutating = false;
43474355
43484356 if ($comments) {
43494357 $tags = parseDocComments($comments);
@@ -4404,6 +4412,10 @@ function parseFunctionLike(
44044412 case 'frameless-function':
44054413 $framelessFunctionInfos[] = new FramelessFunctionInfo($tag->getValue());
44064414 break;
4415+
4416+ case 'mutating':
4417+ $isMutating = true;
4418+ break;
44074419 }
44084420 }
44094421 }
@@ -4507,7 +4519,8 @@ function parseFunctionLike(
45074519 $minimumPhpVersionIdCompatibility,
45084520 AttributeInfo::createFromGroups($func->attrGroups),
45094521 $framelessFunctionInfos,
4510- ExposedDocComment::extractExposedComment($comments)
4522+ ExposedDocComment::extractExposedComment($comments),
4523+ $isMutating,
45114524 );
45124525 } catch (Exception $e) {
45134526 throw new Exception($name . "(): " .$e->getMessage());
0 commit comments