diff --git a/build/psalm/OcpSinceChecker.php b/build/psalm/OcpSinceChecker.php index 9323b07feb7a6..964693d216e7f 100644 --- a/build/psalm/OcpSinceChecker.php +++ b/build/psalm/OcpSinceChecker.php @@ -140,6 +140,9 @@ private static function checkClassComment(ClassLike $stmt, FileSource $statement ) ); } + foreach ($parsedDocblock->tags['since'] ?? [] as $since) { + self::checkSinceIsReleasable(trim($since), $statementsSource, $stmt); + } if (isset($parsedDocblock->tags['depreacted'])) { IssueBuffer::maybeAdd( @@ -184,6 +187,9 @@ private static function checkStatementComment(Stmt $stmt, FileSource $statements ) ); } + foreach ($parsedDocblock->tags['since'] ?? [] as $since) { + self::checkSinceIsReleasable(trim($since), $statementsSource, $stmt); + } if (isset($parsedDocblock->tags['depreacted'])) { IssueBuffer::maybeAdd( @@ -213,9 +219,46 @@ private static function checkAttributeHasValidSinceVersion(\PhpParser\Node\Attri new CodeLocation($statementsSource, $stmt) ) ); + } else { + self::checkSinceIsReleasable($arg->value->value, $statementsSource, $stmt); } } } } } + + /** + * A since version must not be newer than the next patch release of the + * current branch, so backports with an unadjusted since fail + */ + private static function checkSinceIsReleasable(string $since, FileSource $statementsSource, \PhpParser\Node $stmt): void { + // Backports may list multiple versions: "33.0.1, 32.0.7" + if (!preg_match('/^\d+(\.\d+)*(\s*,\s*\d+(\.\d+)*)*/', $since, $list)) { + return; + } + + $maxVersion = self::getMaxSinceVersion(); + foreach (preg_split('/\s*,\s*/', $list[0]) as $version) { + if (version_compare($version, $maxVersion, '<=')) { + return; + } + } + + IssueBuffer::maybeAdd( + new InvalidDocblock( + 'Since version ' . $list[0] . ' is newer than the next release ' . $maxVersion . ' of this branch, please adjust it to the version the change is released in.', + new CodeLocation($statementsSource, $stmt) + ) + ); + } + + private static function getMaxSinceVersion(): string { + static $maxVersion = null; + if ($maxVersion === null) { + require __DIR__ . '/../../version.php'; + /** @var array{0: int, 1: int, 2: int, 3: int} $OC_Version */ + $maxVersion = $OC_Version[0] . '.' . $OC_Version[1] . '.' . ($OC_Version[2] + 1); + } + return $maxVersion; + } } diff --git a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php index 7de45f4b5deb7..8727789e737be 100644 --- a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php +++ b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php @@ -163,7 +163,7 @@ public function registerSearchProvider(string $class): void; * * @return void * - * @since 36.0.0 + * @since 35.0.2 */ public function registerAccountScopedSearchProvider(string $class): void; diff --git a/lib/public/Console/IOutput.php b/lib/public/Console/IOutput.php index e70ad39a4eece..8bc1adc769623 100644 --- a/lib/public/Console/IOutput.php +++ b/lib/public/Console/IOutput.php @@ -91,7 +91,7 @@ public function writeTableInOutputFormat(array $items): void; * as-is. For JSON, this is the nested structure itself, wrapped under $root when it is not empty. * * @param iterable $nodes - * @since 36.0.0 + * @since 35.0.2 */ public function writeTree(iterable $nodes, string $root = ''): void; diff --git a/lib/public/FilesMetadata/IFilesMetadataManager.php b/lib/public/FilesMetadata/IFilesMetadataManager.php index ce8a3e73e0ee6..11c1c4933d0c1 100644 --- a/lib/public/FilesMetadata/IFilesMetadataManager.php +++ b/lib/public/FilesMetadata/IFilesMetadataManager.php @@ -76,7 +76,7 @@ public function getMetadata(int $fileId, bool $generate = false): IFilesMetadata * * @return IFilesMetadata * @throws FilesMetadataNotFoundException if not found - * @since 36.0.0 + * @since 35.0.3 */ public function getMetadataForNode(Node $node, bool $generate = false): IFilesMetadata; diff --git a/lib/public/FilesMetadata/Model/IFilesMetadata.php b/lib/public/FilesMetadata/Model/IFilesMetadata.php index e5394a49379b1..ba503eb54da4f 100644 --- a/lib/public/FilesMetadata/Model/IFilesMetadata.php +++ b/lib/public/FilesMetadata/Model/IFilesMetadata.php @@ -49,7 +49,7 @@ public function getFileId(): int; * returns the storage id linked to this metadata * * @return int - * @since 36.0.0 + * @since 35.0.3 */ public function getStorageId(): int;