1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace LaravelUi5\OData\Edm\Contracts;
6:
7: use LaravelUi5\OData\Edm\Contracts\Annotation\AnnotationInterface;
8:
9: /**
10: * Contract for every model element that may carry annotations.
11: *
12: * In CSDL virtually every construct — types, properties, container
13: * members, parameters, the schema itself — is annotatable. This
14: * interface is mixed in wherever the spec permits annotations.
15: *
16: * The annotation representation is intentionally simplified at this
17: * stage and will be refined collaboratively once the structural
18: * interfaces are complete.
19: *
20: * Term names in annotations are always stored in fully qualified form,
21: * e.g. "com.sap.vocabularies.UI.v1.LineItem" rather than "UI.LineItem".
22: * The builder is responsible for resolving aliases to their full namespace
23: * before storing. Implementations of getAnnotation() must accept both
24: * alias-qualified and fully qualified term names as input and resolve
25: * aliases against the schema's declared namespace map before matching.
26: *
27: * @see OData CSDL XML v4.01 §14.2 (Annotation)
28: */
29: interface AnnotatableInterface
30: {
31: /**
32: * All annotations applied to this model element, keyed by
33: * the qualified term name, e.g. "Org.OData.Core.V1.Description".
34: *
35: * Returns an empty array when no annotations are present.
36: *
37: * @return list<AnnotationInterface>
38: */
39: public function getAnnotations(): array;
40:
41: /**
42: * Returns the first annotation for the given term name, optionally
43: * filtered by qualifier. Returns null when no matching annotation
44: * is present.
45: *
46: * Accepts both fully qualified term names
47: * ("com.sap.vocabularies.UI.v1.LineItem") and alias-qualified names
48: * ("UI.LineItem"). Implementations must resolve alias-qualified names
49: * against the alias map derived from the enclosing schema's references
50: * before matching. Internally, annotations are always stored under
51: * their fully qualified term name.
52: */
53: public function getAnnotation(string $term, ?string $qualifier = null): ?AnnotationInterface;
54: }
55: