Skip to content

Commit f7e7e5f

Browse files
Merge pull request #13450 from nextcloud/feat/dev/consumable-api
feat(developer): Document Consumable vs. Implementable OCP
2 parents 1c3cba2 + 155d4c2 commit f7e7e5f

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_32.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ Removed APIs
3333
Back-end changes
3434
----------------
3535

36+
- OCP API split into consumable and implementable:
37+
For a more informed background see `RFC: Split OCP into Consumable and Implementable <https://github.com/nextcloud/standards/issues/15>`_ for more information.
38+
Short summary:
39+
40+
- **Consumable:** Interfaces, Enums and classes that have the ``OCP\AppFramework\Attribute\Consumable`` attribute, must only be consumed by apps and can not be implemented by apps themselves.
41+
This means the server side can extend the interface with new methods or reduce returned types of existing methods without it being consider an API break.
42+
However argument types of existing methods can **not** be reduced.
43+
Same rules apply to ``OCP\EventsDispatcher\Event`` that have the ``OCP\AppFramework\Attribute\Listenable`` attribute and ``Exception`` with the ``OCP\AppFramework\Attribute\Catchable`` attribute.
44+
- **Implementable:** Interfaces, Enums and classes that have the ``OCP\AppFramework\Attribute\Implementable`` attribute, can be implemented by apps.
45+
This means the server side can **not** extend the interface with new methods or reduce returned types of existing methods without it being consider an API break.
46+
However argument types of existing methods can be reduced.
47+
Same rules apply to ``OCP\EventsDispatcher\Event`` that have the ``OCP\AppFramework\Attribute\Dispatchable`` attribute and ``Exception`` with the ``OCP\AppFramework\Attribute\Throwable`` attribute.
48+
- **ExceptionalImplementable:** Despite not being implementable for all apps, some interfaces can have the ``OCP\AppFramework\Attribute\ExceptionalImplementable`` attribute indicating that they are implementable by a single app (or multiple).
49+
In those cases the general ``OCP\AppFramework\Attribute\Consumable`` rules apply, but the app maintainers or repository of named exceptions have to be informed during the process of a pull request, leaving them enough time to align with the upcoming change.
50+
51+
- These new attributes will be applied on a "defacto standard" basis to the best of our knowledge.
52+
In case an API was flagged unexpectedly, leave a comment on the respective pull request in the server repository asking for clarification.
53+
3654
Added APIs
3755
^^^^^^^^^^
3856

developer_manual/digging_deeper/api.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,30 @@ PHP public API
88
The public API is contained in the OCP namespace. See the `OCP API reference
99
<https://nextcloud-server.netlify.app/>`_ for further details.
1010

11+
The API is split into two categories. Those are indicated by attributes.
12+
13+
``Consumable``, ``Listenable`` and ``Catchable``
14+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
16+
Interfaces, Enums and classes that have the ``OCP\AppFramework\Attribute\Consumable`` attribute, must only be consumed by apps and can not be implemented by apps themselves.
17+
This means the server side can extend the interface with new methods or reduce returned types of existing methods without it being consider an API break.
18+
However argument types of existing methods can **not** be reduced.
19+
Same rules apply to ``OCP\EventsDispatcher\Event`` that have the ``OCP\AppFramework\Attribute\Listenable`` attribute and ``Exception`` with the ``OCP\AppFramework\Attribute\Catchable`` attribute.
20+
21+
``Implementable``, ``Dispatchable`` and ``Throwable``
22+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23+
24+
Interfaces, Enums and classes that have the ``OCP\AppFramework\Attribute\Implementable`` attribute, can be implemented by apps.
25+
This means the server side can **not** extend the interface with new methods or reduce returned types of existing methods without it being consider an API break.
26+
However argument types of existing methods can be reduced.
27+
Same rules apply to ``OCP\EventsDispatcher\Event`` that have the ``OCP\AppFramework\Attribute\Dispatchable`` attribute and ``Exception`` with the ``OCP\AppFramework\Attribute\Throwable`` attribute.
28+
29+
``ExceptionalImplementable``
30+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31+
32+
Despite not being implementable for all apps, some interfaces can have the ``OCP\AppFramework\Attribute\ExceptionalImplementable`` attribute indicating that they are implementable by a single app (or multiple).
33+
In those cases the general ``OCP\AppFramework\Attribute\Consumable`` rules apply, but the app maintainers or repository of named exceptions have to be informed during the process of a pull request, leaving them enough time to align with the upcoming change.
34+
1135

1236
PHP unstable API
1337
----------------

0 commit comments

Comments
 (0)