1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace LaravelUi5\OData\Edm\Contracts;
6:
7: use LaravelUi5\OData\Edm\Contracts\Type\TypeInterface;
8:
9: /**
10: * A function overload as defined in CSDL.
11: *
12: * Functions are side-effect-free callables that return a value.
13: * They may be bound to an entity type, entity set, singleton, or
14: * the service root (unbound). Multiple overloads sharing the same
15: * name may coexist; each overload is represented by a distinct
16: * instance of this interface.
17: *
18: * Actions are explicitly out of scope for this read-only interface
19: * layer.
20: *
21: * @see OData CSDL XML v4.01 §12.3 (Function)
22: * @see OData CSDL XML v4.01 §12.4 (Function Overloads)
23: */
24: interface FunctionInterface extends NamedElementInterface, AnnotatableInterface, AnnotationTargetInterface
25: {
26: /**
27: * Whether this overload is bound to a specific type or set.
28: *
29: * When true, the first parameter is the binding parameter and
30: * constrains the context in which the function may be invoked.
31: *
32: * @see OData CSDL XML v4.01 §12.5
33: */
34: public function isBound(): bool;
35:
36: /**
37: * Whether the result of this function may be further composed
38: * with URL path segments, system query options, or operations.
39: *
40: * A composable function returning a collection can be followed
41: * by $filter, $orderby, and similar; a composable function
42: * returning a single entity can be followed by navigation
43: * property segments.
44: *
45: * @see OData CSDL XML v4.01 §12.7
46: */
47: public function isComposable(): bool;
48:
49: /**
50: * The return type of this function. Null only when the function
51: * is declared without a return type, which the spec permits but
52: * is unusual for well-formed services.
53: *
54: * @see OData CSDL XML v4.01 §12.8
55: */
56: public function getReturnType(): ?TypeInterface;
57:
58: /**
59: * Whether the return type is a collection.
60: */
61: public function returnsCollection(): bool;
62:
63: /**
64: * Whether a null return value is permitted.
65: */
66: public function isReturnTypeNullable(): bool;
67:
68: /**
69: * All parameters of this function overload, in declaration order.
70: *
71: * For bound functions the binding parameter is at index 0.
72: *
73: * @return list<FunctionParameterInterface>
74: * @see OData CSDL XML v4.01 §12.9
75: */
76: public function getParameters(): array;
77:
78: /**
79: * Returns the parameter with the given name, or null if absent.
80: */
81: public function getParameter(string $name): ?FunctionParameterInterface;
82:
83: /**
84: * For bound functions, the entity set path that identifies which
85: * entity set in the container holds the return values, or null
86: * when not applicable or not declared.
87: *
88: * Use the returned object's typed accessors to resolve the path
89: * programmatically against the container's navigation property
90: * bindings during query plan generation.
91: *
92: * @see OData CSDL XML v4.01 §12.6
93: */
94: public function getEntitySetPath(): ?EntitySetPathInterface;
95: }
96: