Skip to content

Commit b59f8c3

Browse files
committed
Include zend_attributes.h conditionally based on attribute usage
1 parent c45b2be commit b59f8c3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

build/gen_stub.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4553,7 +4553,7 @@ public function generateCDeclarations(): string {
45534553
return $code;
45544554
}
45554555

4556-
4556+
45574557
/**
45584558
* @param array<string, ConstInfo> $allConstInfos
45594559
* @return array{string, string}
@@ -4669,9 +4669,12 @@ function (FuncInfo $funcInfo) use (&$generatedFunctionDeclarations) {
46694669
. "#endif /* {$headerName} */\n";
46704670
}
46714671

4672+
$shouldIncludeAttributes = preg_match('/zend_add_(class|function|parameter|property|class_constant|global_constant)_attribute\(/', $code);
4673+
46724674
$code = "/* This is a generated file, edit {$stubFilenameWithoutExtension}.stub.php instead.\n"
46734675
. " * Stub hash: $stubHash"
46744676
. ($hasDeclFile ? "\n * Has decl header: yes */\n" : " */\n")
4677+
. ($shouldIncludeAttributes ? "\n#include \"zend_attributes.h\"\n" : "")
46754678
. $code;
46764679

46774680
return [$code, $declCode];

0 commit comments

Comments
 (0)