Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions build/psalm/OcpSinceChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/public/Console/IOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, iterable|string> $nodes
* @since 36.0.0
* @since 35.0.2
*/
public function writeTree(iterable $nodes, string $root = ''): void;

Expand Down
2 changes: 1 addition & 1 deletion lib/public/FilesMetadata/IFilesMetadataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/public/FilesMetadata/Model/IFilesMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading