@@ -4050,6 +4050,36 @@ class FileInfo {
4050
4050
public bool $legacyArginfoGeneration = false;
4051
4051
private ?int $minimumPhpVersionIdCompatibility = null;
4052
4052
4053
+ /** @param array<int, DocCommentTag> $fileTags */
4054
+ public function __construct(array $fileTags) {
4055
+ foreach ($fileTags as $tag) {
4056
+ if ($tag->name === 'generate-function-entries') {
4057
+ $this->generateFunctionEntries = true;
4058
+ $this->declarationPrefix = $tag->value ? $tag->value . " " : "";
4059
+ } else if ($tag->name === 'generate-legacy-arginfo') {
4060
+ if ($tag->value && !in_array((int) $tag->value, ALL_PHP_VERSION_IDS, true)) {
4061
+ throw new Exception(
4062
+ "Legacy PHP version must be one of: \"" . PHP_70_VERSION_ID . "\" (PHP 7.0), \"" . PHP_80_VERSION_ID . "\" (PHP 8.0), " .
4063
+ "\"" . PHP_81_VERSION_ID . "\" (PHP 8.1), \"" . PHP_82_VERSION_ID . "\" (PHP 8.2), \"" . PHP_83_VERSION_ID . "\" (PHP 8.3), " .
4064
+ "\"" . PHP_84_VERSION_ID . "\" (PHP 8.4), \"" . PHP_85_VERSION_ID . "\" (PHP 8.5), \"" . $tag->value . "\" provided"
4065
+ );
4066
+ }
4067
+
4068
+ $this->minimumPhpVersionIdCompatibility = ($tag->value ? (int) $tag->value : PHP_70_VERSION_ID);
4069
+ } else if ($tag->name === 'generate-class-entries') {
4070
+ $this->generateClassEntries = true;
4071
+ $this->declarationPrefix = $tag->value ? $tag->value . " " : "";
4072
+ } else if ($tag->name === 'undocumentable') {
4073
+ $this->isUndocumentable = true;
4074
+ }
4075
+ }
4076
+
4077
+ // Generating class entries require generating function/method entries
4078
+ if ($this->generateClassEntries && !$this->generateFunctionEntries) {
4079
+ $this->generateFunctionEntries = true;
4080
+ }
4081
+ }
4082
+
4053
4083
/**
4054
4084
* @return iterable<FuncInfo>
4055
4085
*/
@@ -4101,10 +4131,6 @@ public function __clone()
4101
4131
}
4102
4132
}
4103
4133
4104
- public function setMinimumPhpVersionIdCompatibility(?int $minimumPhpVersionIdCompatibility) {
4105
- $this->minimumPhpVersionIdCompatibility = $minimumPhpVersionIdCompatibility;
4106
- }
4107
-
4108
4134
public function getMinimumPhpVersionIdCompatibility(): ?int {
4109
4135
// Non-legacy arginfo files are always PHP 8.0+ compatible
4110
4136
if (!$this->legacyArginfoGeneration &&
@@ -4918,37 +4944,8 @@ protected function pName_FullyQualified(Name\FullyQualified $node): string {
4918
4944
$stmts = $parser->parse($code);
4919
4945
$nodeTraverser->traverse($stmts);
4920
4946
4921
- $fileInfo = new FileInfo;
4922
- $fileDocComments = getFileDocComments($stmts);
4923
- if ($fileDocComments !== []) {
4924
- $fileTags = parseDocComments($fileDocComments);
4925
- foreach ($fileTags as $tag) {
4926
- if ($tag->name === 'generate-function-entries') {
4927
- $fileInfo->generateFunctionEntries = true;
4928
- $fileInfo->declarationPrefix = $tag->value ? $tag->value . " " : "";
4929
- } else if ($tag->name === 'generate-legacy-arginfo') {
4930
- if ($tag->value && !in_array((int) $tag->value, ALL_PHP_VERSION_IDS, true)) {
4931
- throw new Exception(
4932
- "Legacy PHP version must be one of: \"" . PHP_70_VERSION_ID . "\" (PHP 7.0), \"" . PHP_80_VERSION_ID . "\" (PHP 8.0), " .
4933
- "\"" . PHP_81_VERSION_ID . "\" (PHP 8.1), \"" . PHP_82_VERSION_ID . "\" (PHP 8.2), \"" . PHP_83_VERSION_ID . "\" (PHP 8.3), " .
4934
- "\"" . PHP_84_VERSION_ID . "\" (PHP 8.4), \"" . PHP_85_VERSION_ID . "\" (PHP 8.5), \"" . $tag->value . "\" provided"
4935
- );
4936
- }
4937
-
4938
- $fileInfo->setMinimumPhpVersionIdCompatibility($tag->value ? (int) $tag->value : PHP_70_VERSION_ID);
4939
- } else if ($tag->name === 'generate-class-entries') {
4940
- $fileInfo->generateClassEntries = true;
4941
- $fileInfo->declarationPrefix = $tag->value ? $tag->value . " " : "";
4942
- } else if ($tag->name === 'undocumentable') {
4943
- $fileInfo->isUndocumentable = true;
4944
- }
4945
- }
4946
- }
4947
-
4948
- // Generating class entries require generating function/method entries
4949
- if ($fileInfo->generateClassEntries && !$fileInfo->generateFunctionEntries) {
4950
- $fileInfo->generateFunctionEntries = true;
4951
- }
4947
+ $fileTags = parseDocComments(getFileDocComments($stmts));
4948
+ $fileInfo = new FileInfo($fileTags);
4952
4949
4953
4950
handleStatements($fileInfo, $stmts, $prettyPrinter);
4954
4951
return $fileInfo;
0 commit comments