-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(OCP): Consumable vs. Implementable public API #53072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\AppFramework\Attribute; | ||
|
|
||
| use Attribute; | ||
|
|
||
| /** | ||
| * Abstract base attribute to declare an API's stability. | ||
| * | ||
| * @since 32.0.0 | ||
| */ | ||
| #[Consumable(since: '32.0.0')] | ||
| abstract class ASince { | ||
| /** | ||
| * @param string $since For shipped apps and server code such as core/ and lib/, | ||
| * this should be the server version. For other apps it | ||
| * should be the semantic app version. | ||
| */ | ||
| public function __construct( | ||
| protected string $since, | ||
nickvergessen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) { | ||
| } | ||
|
|
||
| public function getSince(): string { | ||
| return $this->since; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\AppFramework\Attribute; | ||
|
|
||
| use Attribute; | ||
|
|
||
| /** | ||
| * Attribute to declare that the exception is "catchable" by apps. | ||
| * | ||
| * @since 32.0.0 | ||
| */ | ||
| #[Attribute(Attribute::TARGET_ALL | Attribute::IS_REPEATABLE)] | ||
| #[Consumable(since: '32.0.0')] | ||
| #[Implementable(since: '32.0.0')] | ||
| class Catchable extends ASince { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\AppFramework\Attribute; | ||
|
|
||
| use Attribute; | ||
|
|
||
| /** | ||
| * Attribute to declare that the API stability is limited to "consuming" the | ||
| * class, interface, enum, etc. Apps are not allowed to implement or replace them. | ||
| * | ||
| * For events use @see \OCP\AppFramework\Attribute\Listenable | ||
| * For exceptions use @see \OCP\AppFramework\Attribute\Catchable | ||
| * | ||
| * @since 32.0.0 | ||
| */ | ||
| #[Attribute(Attribute::TARGET_ALL | Attribute::IS_REPEATABLE)] | ||
| #[Consumable(since: '32.0.0')] | ||
| #[Implementable(since: '32.0.0')] | ||
nickvergessen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| class Consumable extends ASince { | ||
nickvergessen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\AppFramework\Attribute; | ||
|
|
||
| use Attribute; | ||
|
|
||
| /** | ||
| * Attribute to declare that the event is "dispatchable" by apps. | ||
| * | ||
| * @since 32.0.0 | ||
| */ | ||
| #[Attribute(Attribute::TARGET_ALL | Attribute::IS_REPEATABLE)] | ||
| #[Consumable(since: '32.0.0')] | ||
| #[Implementable(since: '32.0.0')] | ||
| class Dispatchable extends ASince { | ||
| } |
38 changes: 38 additions & 0 deletions
38
lib/public/AppFramework/Attribute/ExceptionalImplementable.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\AppFramework\Attribute; | ||
|
|
||
| use Attribute; | ||
|
|
||
| /** | ||
| * Attribute to declare that the API marked as Consumable/Listenable/Catchable | ||
| * has an exception and is Implementable/Dispatchable/Throwable by a dedicated | ||
| * app. Changes to such an API have to be communicated to the affected app maintainers. | ||
| * | ||
| * @since 32.0.0 | ||
| */ | ||
| #[Attribute(Attribute::TARGET_ALL | Attribute::IS_REPEATABLE)] | ||
| #[Consumable(since: '32.0.0')] | ||
| #[Implementable(since: '32.0.0')] | ||
| class ExceptionalImplementable { | ||
| public function __construct( | ||
| protected string $app, | ||
| protected ?string $class = null, | ||
| ) { | ||
| } | ||
|
|
||
| public function getApp(): string { | ||
| return $this->app; | ||
| } | ||
|
|
||
| public function getClass(): ?string { | ||
| return $this->class; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\AppFramework\Attribute; | ||
|
|
||
| use Attribute; | ||
|
|
||
| /** | ||
| * Attribute to declare that the API stability is limited to "implementing" the | ||
| * class, interface, enum, etc. | ||
| * | ||
| * For events use @see \OCP\AppFramework\Attribute\Dispatchable | ||
| * For exceptions use @see \OCP\AppFramework\Attribute\Throwable | ||
| * | ||
| * @since 32.0.0 | ||
| */ | ||
| #[Attribute(Attribute::TARGET_ALL | Attribute::IS_REPEATABLE)] | ||
| #[Consumable(since: '32.0.0')] | ||
| #[Implementable(since: '32.0.0')] | ||
| class Implementable extends ASince { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\AppFramework\Attribute; | ||
|
|
||
| use Attribute; | ||
|
|
||
| /** | ||
| * Attribute to declare that the event is "listenable" by apps. | ||
| * | ||
| * @since 32.0.0 | ||
| */ | ||
| #[Attribute(Attribute::TARGET_ALL | Attribute::IS_REPEATABLE)] | ||
| #[Consumable(since: '32.0.0')] | ||
| #[Implementable(since: '32.0.0')] | ||
| class Listenable extends ASince { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\AppFramework\Attribute; | ||
|
|
||
| use Attribute; | ||
|
|
||
| /** | ||
| * Attribute to declare that the exception is "throwable" by apps. | ||
| * | ||
| * @since 32.0.0 | ||
| */ | ||
| #[Attribute(Attribute::TARGET_ALL | Attribute::IS_REPEATABLE)] | ||
| #[Consumable(since: '32.0.0')] | ||
| #[Implementable(since: '32.0.0')] | ||
| class Throwable extends ASince { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.